Improve visual-line-mode support in doom/backward-to-bol-or-indent #396
This commit is contained in:
parent
1e9b492399
commit
7c48e7e5cc
1 changed files with 12 additions and 10 deletions
|
@ -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 ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue