Gnasty doom evil-join

This commit is contained in:
MitchMarq42 2022-10-26 09:44:13 -08:00
parent 71744e4b95
commit dd2d9fab4b

View File

@ -28,26 +28,51 @@ Made solely to reduce lines in the init-file."
(interactive)
(evil-next-line)
(scroll-up-line))
;; Make evil-join combine lines. Taken from https://github.com/hlissner/doom-emacs/commit/40cf6139ed53b635fec37ce623c4b1093c78a11e
;; (evil-define-operator +evil-join-a (beg end)
;; Make evil-join combine lines. Taken from https://github.com/doomemacs/doomemacs/blob/master/modules/editor/evil/autoload/advice.el#L180
;;;###autoload (autoload '+evil-join-a "lisp/mitch-defuns" nil nil)
;; (defun +evil-join-a (fn beg end)
;; "Join the selected lines.
;; This advice improves on `evil-join' by removing comment delimiters when joining
;; commented lines, by using `fill-region-as-paragraph'.
;; From https://github.com/emacs-evil/evil/issues/606"
;; :motion evil-line
;; commented lines, without `fill-region-as-paragraph'.
;; 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)))
;; (dotimes (var count)
;; (if (and (bolp) (eolp))
;; (uncomment-region (line-beginning-position 2)
;; (save-excursion
;; (goto-char cend)
;; (line-end-position 0)))
;; (unwind-protect
;; (dotimes (_ count)
;; (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))))
;; (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)))
;; (advice-add #'evil-join :override #'+evil-join-a)
)
(defun mitch/visual-setup ()