Override default move-beginning-of-line behavior

This commit is contained in:
Bozhidar Batsov 2013-05-23 11:27:01 +03:00
parent 0e4b66d07a
commit 3e3d022b89
2 changed files with 38 additions and 0 deletions

View file

@ -117,6 +117,32 @@ Passes ARG to command `kill-whole-line' when provided."
(kill-whole-line arg)
(back-to-indentation))
(defun prelude-move-beginning-of-line (arg)
"Move point back to indentation of beginning of line.
Move point to the first non-whitespace character on this line.
If point is already there, move to the beginning of the line.
Effectively toggle between the first non-whitespace character and
the beginning of the line.
If ARG is not nil or 1, move forward ARG - 1 lines first. If
point reaches the beginning or end of the buffer, stop there."
(interactive "^p")
(setq arg (or arg 1))
;; Move lines first
(when (/= arg 1)
(let ((line-move-visual nil))
(forward-line (1- arg))))
(let ((orig-point (point)))
(back-to-indentation)
(when (= orig-point (point))
(move-beginning-of-line 1))))
(global-set-key [remap move-beginning-of-line]
'prelude-move-beginning-of-line)
(defun prelude-indent-buffer ()
"Indent the currently visited buffer."
(interactive)