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.
|
"Join the selected lines.
|
||||||
|
|
||||||
This advice improves on `evil-join' by removing comment delimiters when joining
|
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"
|
Adapted from https://github.com/emacs-evil/evil/issues/606"
|
||||||
;; But revert to the default we're not in a comment, where
|
(if-let* (((not (= (line-end-position) (point-max))))
|
||||||
;; `fill-region-as-paragraph' is too greedy.
|
(cend (save-excursion (goto-char end) (line-end-position)))
|
||||||
(if (not (doom-point-in-comment-p (min (max beg (1+ (point))) end)))
|
(cbeg (save-excursion
|
||||||
(funcall fn beg end)
|
(goto-char beg)
|
||||||
(let* ((count (count-lines beg end))
|
(and (doom-point-in-comment-p
|
||||||
(count (if (> count 1) (1- count) count))
|
(save-excursion
|
||||||
(fixup-mark (make-marker)))
|
(goto-char (line-beginning-position 2))
|
||||||
(unwind-protect
|
(skip-syntax-forward " \t")
|
||||||
(dotimes (var count)
|
(point)))
|
||||||
(if (and (bolp) (eolp))
|
(or (comment-search-backward (line-beginning-position) t)
|
||||||
(join-line 1)
|
(comment-search-forward (line-end-position) t)
|
||||||
(let* ((end (line-beginning-position 3))
|
(and (doom-point-in-comment-p beg)
|
||||||
(fill-column (1+ (- end beg))))
|
(stringp comment-continue)
|
||||||
(set-marker fixup-mark (line-end-position))
|
(or (search-forward comment-continue (line-end-position) t)
|
||||||
(fill-region-as-paragraph beg end nil t)
|
beg)))))))
|
||||||
(goto-char fixup-mark)
|
(let* ((count (count-lines beg end))
|
||||||
(fixup-whitespace))))
|
(count (if (> count 1) (1- count) count))
|
||||||
(set-marker fixup-mark nil)))))
|
(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
|
;;;###autoload
|
||||||
(defun +evil--fix-dabbrev-in-minibuffer-h ()
|
(defun +evil--fix-dabbrev-in-minibuffer-h ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue