mirror of
https://github.com/correl/dotfiles.git
synced 2024-12-18 11:06:17 +00:00
[emacs] Smarter move to beginning of line
From emacsredux.com
This commit is contained in:
parent
2d34efccf0
commit
1a487e5f8d
1 changed files with 26 additions and 0 deletions
26
.emacs.d/init.d/smarter-move-beginning-of-line.el
Normal file
26
.emacs.d/init.d/smarter-move-beginning-of-line.el
Normal file
|
@ -0,0 +1,26 @@
|
|||
(defun smarter-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))))
|
||||
|
||||
;; remap C-a to `smarter-move-beginning-of-line'
|
||||
(global-set-key [remap move-beginning-of-line]
|
||||
'smarter-move-beginning-of-line)
|
Loading…
Reference in a new issue