Refactor & fix doom/forward-to-last-non-comment-or-eol
This commit is contained in:
parent
7c48e7e5cc
commit
dadfeec506
1 changed files with 23 additions and 23 deletions
|
@ -33,30 +33,30 @@ beginning of the line. The opposite of
|
|||
|
||||
;;;###autoload
|
||||
(defun doom/forward-to-last-non-comment-or-eol ()
|
||||
"Move forward to the last non-blank character in the line, ignoring comments
|
||||
and trailing whitespace. If already there, move to the real end of the line.
|
||||
If already there, do nothing."
|
||||
"Jumps between the last non-blank, non-comment character in the line and the
|
||||
true end of the line. The opposite of `doom/backward-to-bol-or-indent'."
|
||||
(interactive)
|
||||
(let* ((point (point))
|
||||
(eol (save-excursion (end-of-visual-line) (point)))
|
||||
(bol (save-excursion (beginning-of-visual-line) (point)))
|
||||
(eoc (or (if (not comment-use-syntax)
|
||||
(let ((eol (save-excursion (end-of-visual-line) (point))))
|
||||
(if (and (sp-point-in-comment) (not (= (point) eol)))
|
||||
(goto-char eol)
|
||||
(let* ((bol (save-excursion (beginning-of-visual-line) (point)))
|
||||
(boc (or (save-excursion
|
||||
(if (not comment-use-syntax)
|
||||
(progn
|
||||
(goto-char bol)
|
||||
(when (re-search-forward comment-start-skip eol t)
|
||||
(or (match-end 1) (match-beginning 0)))
|
||||
(save-excursion
|
||||
(or (match-end 1) (match-beginning 0))))
|
||||
(goto-char eol)
|
||||
(while (and (sp-point-in-comment)
|
||||
(> (point) point))
|
||||
(> (point) bol))
|
||||
(backward-char))
|
||||
(when (> (point) point)
|
||||
(skip-chars-backward " " bol)
|
||||
(point))))
|
||||
eol))
|
||||
(goto-char-fn (if (featurep 'evil) #'evil-goto-char #'goto-char)))
|
||||
(if (= eoc point)
|
||||
(funcall goto-char-fn eol)
|
||||
(unless (= eol point)
|
||||
(funcall goto-char-fn eoc)))))
|
||||
(point)))
|
||||
eol)))
|
||||
(cond ((= boc (point))
|
||||
(goto-char eol))
|
||||
((/= bol boc)
|
||||
(goto-char boc)))))))
|
||||
|
||||
(defun doom--surrounded-p ()
|
||||
(and (looking-back "[[{(]\\(\s+\\|\n\\)?\\(\s\\|\t\\)*" (line-beginning-position))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue