Save users own white/black lists in .mc-lists.el

This commit is contained in:
Magnar Sveen 2012-07-20 22:55:08 +02:00
parent 15e88c6df9
commit 84ef509350

View File

@ -177,10 +177,12 @@ cursor with updated info."
(defun mc/prompt-for-inclusion-in-whitelist (original-command)
"Asks the user, then adds the command either to the once-list or the all-list."
(if (y-or-n-p (format "Do %S for all cursors?" original-command))
(let ((all-p (y-or-n-p (format "Do %S for all cursors?" original-command))))
(if all-p
(add-to-list 'mc/cmds-to-run-for-all original-command)
(add-to-list 'mc/cmds-to-run-once original-command)
nil))
(add-to-list 'mc/cmds-to-run-once original-command))
(mc/save-lists)
all-p))
(defun mc/num-cursors ()
"The number of cursors (real and fake) in the buffer."
@ -364,27 +366,37 @@ from being executed if in multiple-cursors-mode."
smart-down)
"Default set of commands that should be mirrored by all cursors")
(defvar mc/list-file "~/.emacs.d/.mc-lists.el"
"The position of the file that keeps track of your preferences
for running commands with multiple cursors.")
(defun mc/save-lists ()
(with-temp-file mc/list-file
(emacs-lisp-mode)
(insert ";; This file is automatically generated by the multiple-cursors extension.")
(newline)
(insert ";; It keeps track of your preferences for running commands with multiple cursors.")
(newline)
(newline)
(insert "(setq mc/cmds-to-run-for-all '(")
(mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent)) mc/cmds-to-run-for-all)
(when mc/cmds-to-run-for-all
(next-line -1)
(end-of-line))
(insert "))")
(newline)
(newline)
(insert "(setq mc/cmds-to-run-once '(")
(mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent)) mc/cmds-to-run-once)
(when mc/cmds-to-run-once
(next-line -1)
(end-of-line))
(insert "))")
(newline)))
(defvar mc/cmds-to-run-for-all nil
"Commands to run for all cursors in multiple-cursors-mode")
(setq mc/cmds-to-run-for-all '(save-region-or-current-line
kill-region-or-backward-word
change-number-at-point
dired-back-to-start-of-files
yank-indented
wrap-region-trigger
yas/expand
org-shiftright
sgml-slash
slime-space
js2-beginning-of-line
js2-end-of-line
js2-insert-and-indent
js2r-inline-var
c-electric-delete-forward
c-electric-backspace
c-electric-paren
c-electric-semi&comma))
(load mc/list-file t) ;; load, but no errors if it does not exist yet please
(provide 'multiple-cursors-core)