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,27 +28,52 @@ Made solely to reduce lines in the init-file."
(interactive) (interactive)
(evil-next-line) (evil-next-line)
(scroll-up-line)) (scroll-up-line))
;; Make evil-join combine lines. Taken from https://github.com/hlissner/doom-emacs/commit/40cf6139ed53b635fec37ce623c4b1093c78a11e ;; Make evil-join combine lines. Taken from https://github.com/doomemacs/doomemacs/blob/master/modules/editor/evil/autoload/advice.el#L180
;; (evil-define-operator +evil-join-a (beg end) ;;;###autoload (autoload '+evil-join-a "lisp/mitch-defuns" nil nil)
;; "Join the selected lines. ;; (defun +evil-join-a (fn beg end)
;; This advice improves on `evil-join' by removing comment delimiters when joining ;; "Join the selected lines.
;; commented lines, by using `fill-region-as-paragraph'. ;; This advice improves on `evil-join' by removing comment delimiters when joining
;; From https://github.com/emacs-evil/evil/issues/606" ;; commented lines, without `fill-region-as-paragraph'.
;; :motion evil-line ;; Adapted from https://github.com/emacs-evil/evil/issues/606"
;; (let* ((count (count-lines beg end)) ;; (if-let* (((not (= (line-end-position) (point-max))))
;; (count (if (> count 1) (1- count) count)) ;; (cend (save-excursion (goto-char end) (line-end-position)))
;; (fixup-mark (make-marker))) ;; (cbeg (save-excursion
;; (dotimes (var count) ;; (goto-char beg)
;; (if (and (bolp) (eolp)) ;; (and (doom-point-in-comment-p
;; (join-line 1) ;; (save-excursion
;; (let* ((end (line-beginning-position 3)) ;; (goto-char (line-beginning-position 2))
;; (fill-column (1+ (- end beg)))) ;; (skip-syntax-forward " \t")
;; (set-marker fixup-mark (line-end-position)) ;; (point)))
;; (fill-region-as-paragraph beg end nil t) ;; (or (comment-search-backward (line-beginning-position) t)
;; (goto-char fixup-mark) ;; (comment-search-forward (line-end-position) t)
;; (fixup-whitespace)))) ;; (and (doom-point-in-comment-p beg)
;; (set-marker fixup-mark nil))) ;; (stringp comment-continue)
;; (advice-add #'evil-join :override #'+evil-join-a) ;; (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)))
;; (advice-add #'evil-join :override #'+evil-join-a)
) )
(defun mitch/visual-setup () (defun mitch/visual-setup ()
"Commands to run when setting up any display. To be called in use-package "Commands to run when setting up any display. To be called in use-package