Improve visual-line-mode support in doom/backward-to-bol-or-indent #396

This commit is contained in:
Henrik Lissner 2018-02-01 14:43:28 -05:00
parent 1e9b492399
commit 7c48e7e5cc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -17,17 +17,19 @@
;;;###autoload ;;;###autoload
(defun doom/backward-to-bol-or-indent () (defun doom/backward-to-bol-or-indent ()
"Move back to the current line's indentation. If already there, move to the "Jump between the indentation column (first non-whitespace character) and the
beginning of the line instead. If at bol, do nothing." beginning of the line. The opposite of
`doom/forward-to-last-non-comment-or-eol'."
(interactive) (interactive)
(if (bound-and-true-p visual-line-mode) (let ((pos (point))
(beginning-of-visual-line) (indent (save-excursion
(let ((ci (current-indentation)) (beginning-of-visual-line)
(cc (current-column))) (skip-chars-forward " \t\r")
(cond ((or (> cc ci) (= cc 0)) (point))))
(back-to-indentation)) (cond ((or (> pos indent) (= pos (line-beginning-position)))
((<= cc ci) (goto-char indent))
(beginning-of-visual-line)))))) ((<= pos indent)
(beginning-of-visual-line)))))
;;;###autoload ;;;###autoload
(defun doom/forward-to-last-non-comment-or-eol () (defun doom/forward-to-last-non-comment-or-eol ()