Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions modules/config/default/+emacs-bindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@
(:when (modulep! :editor multiple-cursors)
(:prefix-map ("m" . "multiple-cursors")
:desc "Edit lines" "l" #'mc/edit-lines
:desc "Mark next" "n" #'mc/mark-next-like-this
:desc "Unmark next" "N" #'mc/unmark-next-like-this
:desc "Mark previous" "p" #'mc/mark-previous-like-this
:desc "Unmark previous" "P" #'mc/unmark-previous-like-this
:desc "Mark next" "n" #'+mc/transient-mark-next-like-this
:desc "Unmark next" "N" #'+mc/transient-unmark-next-like-this
:desc "Mark previous" "p" #'+mc/transient-mark-previous-like-this
:desc "Unmark previous" "P" #'+mc/transient-unmark-previous-like-this
:desc "Mark all" "t" #'mc/mark-all-like-this
:desc "Mark all DWIM" "m" #'mc/mark-all-like-this-dwim
:desc "Edit line endings" "e" #'mc/edit-ends-of-lines
Expand Down Expand Up @@ -543,7 +543,11 @@
"C-c h" #'+ein/hydra/body)

;;; expand-region
"C-=" #'er/expand-region
"C-=" (cmd! (call-interactively #'er/expand-region)
(set-transient-map +er-transient-map t))

;; multiple-cursors
"C-+" #'mc/mark-next-like-this

;;; flycheck
(:after flycheck
Expand Down
15 changes: 14 additions & 1 deletion modules/config/default/+emacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@
(delete-selection-mode +1)

(use-package! expand-region
:commands (er/contract-region er/mark-symbol er/mark-word)
:commands (er/expand-region er/contract-region er/mark-symbol er/mark-word)
:init
(setq expand-region-fast-keys-enabled nil)
:config
;; Configure the transient map called when expanding a region
(setq +er-transient-map
(let ((t-map (make-sparse-keymap)))
(define-key t-map (kbd "C-=") #'er/expand-region)
(define-key t-map (kbd "=") #'er/expand-region)
(define-key t-map (kbd "C--") #'er/contract-region)
(define-key t-map (kbd "-") #'er/contract-region)
(define-key t-map (kbd "C-0") (cmd! (er/expand-region 0)))
(define-key t-map (kbd "0") (cmd! (er/expand-region 0)))
t-map))
;; Custom expansion quitting
(defadvice! doom--quit-expand-region-a (&rest _)
"Properly abort an expand-region region."
:before '(evil-escape doom/escape)
Expand Down
28 changes: 28 additions & 0 deletions modules/editor/multiple-cursors/autoload/vanilla-mc.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;;; editor/multiple-cursors/autoload/vanilla-mc.el -*- lexical-binding: t; -*-
;;;###if (not (modulep! :editor evil))

;;;###autoload
(defun +mc/transient-call (func)
(require 'multiple-cursors)
(set-transient-map +mc-transient-map t)
(call-interactively func))

;;;###autoload
(defun +mc/transient-mark-next-like-this ()
(interactive)
(+mc/transient-call #'mc/mark-next-like-this))

;;;###autoload
(defun +mc/transient-unmark-next-like-this ()
(interactive)
(+mc/transient-call #'mc/unmark-next-like-this))

;;;###autoload
(defun +mc/transient-mark-previous-like-this ()
(interactive)
(+mc/transient-call #'mc/mark-previous-like-this))

;;;###autoload
(defun +mc/transient-unmark-previous-like-this ()
(interactive)
(+mc/transient-call #'mc/unmark-previous-like-this))
20 changes: 19 additions & 1 deletion modules/editor/multiple-cursors/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,25 @@
;; Can't use `mc/cmds-to-run-once' because mc-lists.el overwrites it
(add-to-list 'mc--default-cmds-to-run-once 'swiper-mc)

;; TODO multiple-cursors config for Emacs users?
;; Use transient commands with vanilla Emacs.
(when (not (modulep! :editor evil))
;; Transient map used to better control multiple-cursors in vanilla Emacs.
;; This map is disabled if a key not in the map is pressed (e.g., "q").
(setq +mc-transient-map
(let ((t-map (make-sparse-keymap)))
(define-key t-map (kbd "n") #'mc/mark-next-like-this)
(define-key t-map (kbd "N") #'mc/unmark-next-like-this)
(define-key t-map (kbd "p") #'mc/mark-previous-like-this)
(define-key t-map (kbd "P") #'mc/unmark-previous-like-this)
t-map))
;; All functions called from the transient map need to be named (i.e., not
;; be lambdas). These functions need to be further added to the "run once"
;; category to avoid duplicating calls.
(mapc (lambda (func) (add-to-list 'mc--default-cmds-to-run-once func))
'(+mc/transient-mark-next-like-this
+mc/transient-mark-previous-like-this
+mc/transient-unmark-next-like-this
+mc/transient-unmark-previous-like-this)))

;; mc doesn't play well with evil, this attempts to assuage some of its
;; problems so that any plugins that depend on multiple-cursors (which I have
Expand Down