diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-12-01 11:22:51 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-12-01 11:22:51 +0100 |
commit | 203b9795a5e258f4eb979228efdea35120f7e9d9 (patch) | |
tree | 51835a761eb62656e673cae61fbf723f8a604b6a | |
parent | 8a7ebce5c536141264511a6bcb4692383c18ab14 (diff) |
emacs: Rework multiple cursors section
-rw-r--r-- | .config/emacs/editing.el | 2 | ||||
-rw-r--r-- | .config/emacs/modules/mm-completion.el | 37 | ||||
-rw-r--r-- | .config/emacs/modules/mm-editing.el | 65 |
3 files changed, 54 insertions, 50 deletions
diff --git a/.config/emacs/editing.el b/.config/emacs/editing.el index 72d5b48..9fb2acb 100644 --- a/.config/emacs/editing.el +++ b/.config/emacs/editing.el @@ -231,7 +231,6 @@ This function is identical to `mm-search-forward-char' with N negated." THING is any symbol that can be given to ‘bounds-of-thing-at-point’. If there is an active region, the next THING will be marked." - (require 'multiple-cursors) (let ((bounds (bounds-of-thing-at-point thing))) (if (null bounds) (progn @@ -260,7 +259,6 @@ If there is an active region, the next THING will be marked." With prefix arg N, the regions are rotated N places (backwards if N is negative)." (interactive "p") - (require 'multiple-cursors) (when (= (mc/num-cursors) 1) (user-error "Cannot transpose with only one cursor.")) (unless (use-region-p) diff --git a/.config/emacs/modules/mm-completion.el b/.config/emacs/modules/mm-completion.el index 85763b7..f60ae42 100644 --- a/.config/emacs/modules/mm-completion.el +++ b/.config/emacs/modules/mm-completion.el @@ -87,23 +87,26 @@ ;;; Completion Popups -(use-package corfu - :ensure t - :hook prog-mode - :bind ( :map corfu-map - ("C-<return>" . newline)) - :custom - (corfu-auto t) - (corfu-cycle t) - (corfu-auto-prefix 1) - (corfu-auto-delay .1) - (corfu-min-width 20) - :config - ;; I complete with RET and this interferes with ‘tempel-next’ - (keymap-unset corfu-map "TAB" :remove) - (with-eval-after-load 'savehist - (corfu-history-mode) - (add-to-list 'savehist-additional-variables 'corfu-history))) +(mm-comment + (use-package corfu + :ensure t + :hook prog-mode + :bind ( :map corfu-map + ("C-<return>" . newline)) + :custom + (corfu-auto t) + (corfu-cycle t) + (corfu-auto-prefix 1) + (corfu-auto-delay .1) + (corfu-min-width 20) + :config + ;; I complete with RET and this interferes with ‘tempel-next’ + (keymap-unset corfu-map "TAB" :remove) + (with-eval-after-load 'savehist + (corfu-history-mode) + (add-to-list 'savehist-additional-variables 'corfu-history)) + (with-eval-after-load 'multiple-cursors + (add-to-list 'mc/unsupported-minor-modes #'corfu-mode)))) ;;; Save Minibuffer History diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el index 50a31c9..910a80d 100644 --- a/.config/emacs/modules/mm-editing.el +++ b/.config/emacs/modules/mm-editing.el @@ -150,7 +150,6 @@ region are marked, otherwise all matches in the buffer are marked." (or (use-region-end) (point-max)) (read-string (format-prompt ,(concat "Match " noun) nil)))) - (require 'multiple-cursors) (if (string-empty-p ,noun-symbol) (message "Command aborted") (catch 'mm--no-match @@ -177,45 +176,49 @@ region are marked, otherwise all matches in the buffer are marked." (mm--define-mc-marking-command mm-mark-all-in-region-regexp re-search-forward "regexp") -(defun mm-silent-mc-load (args) - "Advice to `load' to force it to be silent. The `multiple-cursors' -package loads an `.mc-lists.el' file without passing `:nomessage' which -causes messages to be sent in the minibuffer and *Messages* buffer. This -forces that to not happen." - (when (and (boundp 'mc/list-file) - (string= (car args) mc/list-file)) - (pcase (length args) - (1 (setq args (list (car args) nil :nomessage))) - (2 (add-to-list 'args :nomessage :append)) - (_ (setf (caddr args) :nomessage))) - (advice-remove #'load #'mm-silent-mc-load)) - args) +(mm-comment + (defun mm-silent-mc-load (args) + "Advice to `load' to force it to be silent. +The `multiple-cursors' package loads an `.mc-lists.el' file without +passing `:nomessage' which causes messages to be sent in the minibuffer +and *Messages* buffer. This forces that to not happen." + (when (and (boundp 'mc/list-file) + (string= (file-truename (car args)) + (file-truename mc/list-file))) + (pcase (length args) + (1 (setq args (list (car args) nil :nomessage))) + (2 (add-to-list 'args :nomessage :append)) + (_ (setf (caddr args) :nomessage))) + (advice-remove #'load #'mm-silent-mc-load)) + args)) (use-package multiple-cursors :ensure t - :defer 2 :bind (("C->" . #'mc/mark-next-like-this) ("C-<" . #'mc/mark-previous-like-this) ("C-M-<" . #'mc/mark-all-like-this-dwim) ("C-M->" . #'mc/edit-lines) - ("C-$" . #'mm-mark-all-in-region) + :map search-map + ("$" . #'mm-mark-all-in-region) ("M-$" . #'mm-mark-all-in-region-regexp)) + :commands ( mm-mark-all-in-region mm-mark-all-in-region-regexp + mm-add-cursor-to-next-thing mm-transpose-cursor-regions) :init - (advice-add #'load :filter-args #'mm-silent-mc-load) - (with-eval-after-load 'multiple-cursors-core - (dolist (command #'(backward-delete-char - capitalize-dwim - delete-backward-char - delete-forward-char - downcase-dwim - upcase-dwim)) - (add-to-list 'mc/cmds-to-run-for-all command)) - (dolist (command #'(helpful-callable - helpful-key - helpful-symbol - helpful-variable)) - (add-to-list 'mc/cmds-to-run-once command)) - (add-to-list 'mc/unsupported-minor-modes #'corfu-mode)) + (mm-comment + (advice-add #'load :filter-args #'mm-silent-mc-load) + (with-eval-after-load 'multiple-cursors-core + (dolist (command #'(backward-delete-char + capitalize-dwim + delete-backward-char + delete-forward-char + downcase-dwim + upcase-dwim)) + (add-to-list 'mc/cmds-to-run-for-all command)) + (dolist (command #'(helpful-callable + helpful-key + helpful-symbol + helpful-variable)) + (add-to-list 'mc/cmds-to-run-once command)))) :config (keymap-unset mc/keymap "<return>" :remove)) |