mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 19:40:24 +10:00
Updating Doom Emacs.
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
(message "evil-mc paused")
|
||||
(message "evil-mc resumed")))
|
||||
|
||||
;;;###autoload (autoload '+multiple-cursors/evil-mc-make-cursor-here "editor/multiple-cursors/autoload/evil-mc" nil t)
|
||||
(evil-define-command +multiple-cursors/evil-mc-make-cursor-here ()
|
||||
;;;###autoload (autoload '+multiple-cursors/evil-mc-toggle-cursor-here "editor/multiple-cursors/autoload/evil-mc" nil t)
|
||||
(evil-define-command +multiple-cursors/evil-mc-toggle-cursor-here ()
|
||||
"Create a cursor at point. If in visual block or line mode, then create
|
||||
cursors on each line of the selection, on the column of the cursor. Otherwise
|
||||
pauses cursors."
|
||||
@@ -22,7 +22,18 @@ pauses cursors."
|
||||
:keep-visual nil
|
||||
:evil-mc t
|
||||
(interactive)
|
||||
(cond ((memq evil-this-type '(block line))
|
||||
(cond ((and (evil-mc-has-cursors-p)
|
||||
(evil-normal-state-p)
|
||||
(let* ((pos (point))
|
||||
(cursor (cl-find-if (lambda (cursor)
|
||||
(eq pos (evil-mc-get-cursor-start cursor)))
|
||||
evil-mc-cursor-list)))
|
||||
(when cursor
|
||||
(evil-mc-delete-cursor cursor)
|
||||
(setq evil-mc-cursor-list (delq cursor evil-mc-cursor-list))
|
||||
t))))
|
||||
|
||||
((memq evil-this-type '(block line))
|
||||
(let ((col (evil-column))
|
||||
(line-at-pt (line-number-at-pos)))
|
||||
;; Fix off-by-one error
|
||||
@@ -51,39 +62,61 @@ pauses cursors."
|
||||
(evil-define-command +multiple-cursors:evil-mc (beg end type pattern &optional flags bang)
|
||||
"Create mc cursors at each match of PATTERN within BEG and END.
|
||||
|
||||
This leaves the cursor at the final match. If BANG, then treat PATTERN as
|
||||
literal. PATTERN is a delimited regexp (the same that :g or :s uses)."
|
||||
:move-point nil
|
||||
This leaves the cursor where the final cursor would be. If BANG, then treat
|
||||
PATTERN as literal. PATTERN is a delimited regexp (the same that :g or :s uses).
|
||||
FLAGS can be g and/or i; which mean the same thing they do in
|
||||
`evil-ex-substitute'."
|
||||
:evil-mc t
|
||||
:keep-visual t
|
||||
(interactive "<R><//!><!>")
|
||||
(unless (and (stringp pattern)
|
||||
(not (string-empty-p pattern)))
|
||||
(user-error "A regexp pattern is required"))
|
||||
(require 'evil-mc)
|
||||
(setq evil-mc-pattern
|
||||
(cons (evil-ex-make-search-pattern
|
||||
(if bang (regexp-quote pattern) pattern))
|
||||
(list beg end type)))
|
||||
(evil-with-restriction beg end
|
||||
(let ((point (point)))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (eq (evil-ex-find-next (evil-mc-get-pattern) 'forward t) t)
|
||||
(goto-char (1- (point)))
|
||||
(when (/= point (point))
|
||||
(evil-mc-run-cursors-before)
|
||||
(evil-mc-make-cursor-at-pos (point)))
|
||||
(goto-char
|
||||
(if (memq ?g flags)
|
||||
(line-beginning-position 2)
|
||||
(1+ (point))))))))
|
||||
(evil-exit-visual-state)
|
||||
(evil-mc-goto-cursor
|
||||
(if (= (evil-visual-direction) 1)
|
||||
(evil-mc-find-last-cursor)
|
||||
(evil-mc-find-first-cursor))
|
||||
nil)
|
||||
(evil-mc-undo-cursor-at-pos (point))
|
||||
(if (evil-mc-has-cursors-p)
|
||||
(evil-mc-print-cursors-info "Created")
|
||||
(evil-mc-message "No cursors were created")))
|
||||
(let ((m (evil-ex-make-pattern
|
||||
(if bang (regexp-quote pattern) pattern)
|
||||
(cond ((memq ?i flags) 'insensitive)
|
||||
((memq ?I flags) 'sensitive)
|
||||
((not +multiple-cursors-evil-mc-ex-case)
|
||||
evil-ex-search-case)
|
||||
(t +multiple-cursors-evil-mc-ex-case))
|
||||
(or (and +multiple-cursors-evil-mc-ex-global
|
||||
(not (memq ?g flags)))
|
||||
(and (not +multiple-cursors-evil-mc-ex-global)
|
||||
(memq ?g flags))))))
|
||||
(evil-mc-run-cursors-before)
|
||||
(setq evil-mc-pattern (cons m (list beg end type)))
|
||||
(evil-with-restriction beg end
|
||||
(goto-char beg)
|
||||
(while (eq (evil-ex-find-next m 'forward t) t)
|
||||
(evil-mc-make-cursor-at-pos (1- (point)))
|
||||
(unless (evil-ex-pattern-whole-line m)
|
||||
(goto-char (line-beginning-position 2)))))
|
||||
(evil-mc-goto-cursor
|
||||
(if (= (evil-visual-direction) 1)
|
||||
(evil-mc-find-last-cursor)
|
||||
(evil-mc-find-first-cursor))
|
||||
nil)
|
||||
(evil-mc-undo-cursor-at-pos (1- (point)))
|
||||
(if (evil-mc-has-cursors-p)
|
||||
(evil-mc-print-cursors-info "Created")
|
||||
(evil-mc-message "No cursors were created"))))
|
||||
|
||||
;;;###autoload (autoload '+multiple-cursors/evil-mc-undo-cursor "editor/multiple-cursors/autoload/evil-mc" nil t)
|
||||
(evil-define-command +multiple-cursors/evil-mc-undo-cursor ()
|
||||
"Undos last cursor, or all cursors in visual region."
|
||||
:repeat nil
|
||||
:evil-mc t
|
||||
(interactive)
|
||||
(if (evil-visual-state-p)
|
||||
(or (mapc (lambda (c)
|
||||
(evil-mc-delete-cursor c)
|
||||
(setq evil-mc-cursor-list (delq c evil-mc-cursor-list)))
|
||||
(cl-remove-if-not
|
||||
(lambda (pos)
|
||||
(and (>= pos evil-visual-beginning)
|
||||
(< pos evil-visual-end)))
|
||||
evil-mc-cursor-list
|
||||
:key #'evil-mc-get-cursor-start))
|
||||
(message "No cursors to undo in region"))
|
||||
(evil-mc-undo-last-added-cursor)))
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
;;; editor/multiple-cursors/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +multiple-cursors-evil-mc-ex-global t
|
||||
"TODO")
|
||||
|
||||
(defvar +multiple-cursors-evil-mc-ex-case nil
|
||||
"TODO")
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(use-package! evil-multiedit
|
||||
:when (featurep! :editor evil)
|
||||
:defer t
|
||||
@@ -57,7 +67,7 @@
|
||||
(company-complete-common . evil-mc-execute-default-complete)
|
||||
(doom/backward-to-bol-or-indent . evil-mc-execute-default-call)
|
||||
(doom/forward-to-last-non-comment-or-eol . evil-mc-execute-default-call)
|
||||
(doom/backward-kill-to-bol-and-indent . evil-mc-execute-default-call)
|
||||
(evil-delete-back-to-indentation . evil-mc-execute-default-call)
|
||||
;; Have evil-mc work with explicit `evil-escape' (on C-g)
|
||||
(evil-escape . evil-mc-execute-default-evil-normal-state)
|
||||
;; Add `evil-org' support
|
||||
@@ -72,12 +82,32 @@
|
||||
:test #'eq
|
||||
:key #'car))
|
||||
|
||||
;; HACK Allow these commands to be repeated by prefixing them with a numerical
|
||||
;; argument. See gabesoft/evil-mc#110
|
||||
(defadvice! +multiple-cursors--make-repeatable-a (orig-fn)
|
||||
:around '(evil-mc-make-and-goto-first-cursor
|
||||
evil-mc-make-and-goto-last-cursor
|
||||
evil-mc-make-and-goto-prev-cursor
|
||||
evil-mc-make-and-goto-next-cursor
|
||||
evil-mc-skip-and-goto-prev-cursor
|
||||
evil-mc-skip-and-goto-next-cursor
|
||||
evil-mc-make-and-goto-prev-match
|
||||
evil-mc-make-and-goto-next-match
|
||||
evil-mc-skip-and-goto-prev-match
|
||||
evil-mc-skip-and-goto-next-match)
|
||||
(dotimes (i (if (integerp current-prefix-arg) current-prefix-arg 1))
|
||||
(funcall orig-fn)))
|
||||
|
||||
;; If we're entering insert mode, it's a good bet that we want to start using
|
||||
;; our multiple cursors
|
||||
(add-hook 'evil-insert-state-entry-hook #'evil-mc-resume-cursors)
|
||||
|
||||
;; evil-escape's escape key sequence leaves behind extraneous characters
|
||||
(cl-pushnew 'evil-escape-mode evil-mc-incompatible-minor-modes)
|
||||
;; Lispy commands don't register on more than 1 cursor. Lispyville is fine
|
||||
;; though.
|
||||
(when (featurep! :editor lispy)
|
||||
(cl-pushnew 'lispy-mode evil-mc-incompatible-minor-modes))
|
||||
|
||||
(add-hook! 'doom-escape-hook
|
||||
(defun +multiple-cursors-escape-multiple-cursors-h ()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; editor/multiple-cursors/packages.el
|
||||
|
||||
(cond ((featurep! :editor evil)
|
||||
(package! evil-multiedit)
|
||||
(package! evil-mc))
|
||||
|
||||
((package! multiple-cursors)))
|
||||
(cond
|
||||
((featurep! :editor evil)
|
||||
(package! evil-multiedit :pin "9f271e0e6048297692f80ed6c5ae8994ac523abc")
|
||||
(package! evil-mc :pin "4d4c0172e4c7f80acc1d0e73d5fb3e536929b262"))
|
||||
|
||||
((package! multiple-cursors :pin "b880554d04b8f61165afba7d4de19ac9e39bb7ab")))
|
||||
|
||||
Reference in New Issue
Block a user