parent
4903db036d
commit
45c759d7d7
1 changed files with 40 additions and 20 deletions
|
@ -183,27 +183,47 @@ more information on modifiers."
|
|||
"Join the selected lines.
|
||||
|
||||
This advice improves on `evil-join' by removing comment delimiters when joining
|
||||
commented lines, by using `fill-region-as-paragraph'.
|
||||
commented lines, without `fill-region-as-paragraph'.
|
||||
|
||||
From https://github.com/emacs-evil/evil/issues/606"
|
||||
;; But revert to the default we're not in a comment, where
|
||||
;; `fill-region-as-paragraph' is too greedy.
|
||||
(if (not (doom-point-in-comment-p (min (max beg (1+ (point))) end)))
|
||||
(funcall fn beg end)
|
||||
(let* ((count (count-lines beg end))
|
||||
(count (if (> count 1) (1- count) count))
|
||||
(fixup-mark (make-marker)))
|
||||
(unwind-protect
|
||||
(dotimes (var count)
|
||||
(if (and (bolp) (eolp))
|
||||
(join-line 1)
|
||||
(let* ((end (line-beginning-position 3))
|
||||
(fill-column (1+ (- end beg))))
|
||||
(set-marker fixup-mark (line-end-position))
|
||||
(fill-region-as-paragraph beg end nil t)
|
||||
(goto-char fixup-mark)
|
||||
(fixup-whitespace))))
|
||||
(set-marker fixup-mark nil)))))
|
||||
Adapted from https://github.com/emacs-evil/evil/issues/606"
|
||||
(if-let* (((not (= (line-end-position) (point-max))))
|
||||
(cend (save-excursion (goto-char end) (line-end-position)))
|
||||
(cbeg (save-excursion
|
||||
(goto-char beg)
|
||||
(and (doom-point-in-comment-p
|
||||
(save-excursion
|
||||
(goto-char (line-beginning-position 2))
|
||||
(skip-syntax-forward " \t")
|
||||
(point)))
|
||||
(or (comment-search-backward (line-beginning-position) t)
|
||||
(comment-search-forward (line-end-position) t)
|
||||
(and (doom-point-in-comment-p beg)
|
||||
(stringp comment-continue)
|
||||
(or (search-forward comment-continue (line-end-position) t)
|
||||
beg)))))))
|
||||
(let* ((count (count-lines beg end))
|
||||
(count (if (> count 1) (1- count) count))
|
||||
(fixup-mark (make-marker)))
|
||||
(uncomment-region (line-beginning-position 2)
|
||||
(save-excursion
|
||||
(goto-char cend)
|
||||
(line-end-position 0)))
|
||||
(unwind-protect
|
||||
(dotimes (_ count)
|
||||
(join-line 1)
|
||||
(save-match-data
|
||||
(when (or (and comment-continue
|
||||
(not (string-empty-p comment-continue))
|
||||
(looking-at (concat "\\(\\s-*" (regexp-quote comment-continue) "\\) ")))
|
||||
(and comment-start-skip
|
||||
(not (string-empty-p comment-start-skip))
|
||||
(looking-at (concat "\\(\\s-*" comment-start-skip "\\)"))))
|
||||
(replace-match "" t nil nil 1)
|
||||
(just-one-space))))
|
||||
(set-marker fixup-mark nil)))
|
||||
;; But revert to the default we're not in a comment, where
|
||||
;; `fill-region-as-paragraph' is too greedy.
|
||||
(funcall fn beg end)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +evil--fix-dabbrev-in-minibuffer-h ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue