-
Notifications
You must be signed in to change notification settings - Fork 37
/
evil-mc-setup.el
46 lines (35 loc) · 1.74 KB
/
evil-mc-setup.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;;; evil-mc-setup.el --- Sample setup for evil-mc -*- lexical-binding: t; -*-
;;; Commentary: Example of setting up evil-mc
;;; Code:
(when (fboundp 'add-to-load-path)
(add-to-load-path (file-name-directory (buffer-file-name))))
(require 'evil-mc)
(evil-define-local-var evil-mc-custom-paused nil
"Paused functionality when there are multiple cursors active.")
(defun evil-mc-pause-smartchr-for-mode (mode)
"Temporarily disables the smartchr keys for MODE."
(let ((m-mode (if (atom mode) mode (car mode)))
(s-mode (if (atom mode) mode (cdr mode))))
(let ((init (intern (concat "smartchr/init-" (symbol-name s-mode))))
(undo (intern (concat "smartchr/undo-" (symbol-name s-mode)))))
(when (eq major-mode m-mode)
(funcall undo)
(push `(lambda () (,init)) evil-mc-custom-paused)))))
(defun evil-mc-before-cursors-setup-hook ()
"Hook to run before any cursor is created.
Can be used to temporarily disable any functionality that doesn't
play well with `evil-mc'."
(mapc 'evil-mc-pause-smartchr-for-mode
'(web-mode js2-mode java-mode (enh-ruby-mode . ruby-mode) css-mode))
(when (boundp 'whitespace-cleanup-disabled)
(setq whitespace-cleanup-disabled t)
(push (lambda () (setq whitespace-cleanup-disabled nil)) evil-mc-custom-paused)))
(defun evil-mc-after-cursors-teardown-hook ()
"Hook to run after all cursors are deleted."
(dolist (fn evil-mc-custom-paused) (funcall fn))
(setq evil-mc-custom-paused nil))
(add-hook 'evil-mc-before-cursors-created 'evil-mc-before-cursors-setup-hook)
(add-hook 'evil-mc-after-cursors-deleted 'evil-mc-after-cursors-teardown-hook)
(defvar evil-mc-mode-line-prefix "ⓜ"
"Override of the default mode line string for `evil-mc-mode'.")
(global-evil-mc-mode 1)