Skip to content

Instantly share code, notes, and snippets.

@johnmastro
Created May 23, 2015 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmastro/3696434d62ecba67326b to your computer and use it in GitHub Desktop.
Save johnmastro/3696434d62ecba67326b to your computer and use it in GitHub Desktop.
add-mc-cmds.el
;; Just doodling on the topic of somewhat automatically initializing
;; `mc/cmds-to-run-for-all'.
;;
;; I always find the prompts a bit distracting when working on a new computer
;; but the file `multiple-cursors' maintains, .mc-lists.el, doesn't seem very
;; well-suited to version control.
(require 'pcase)
(defvar mc-paredit&sp-cmds-to-run-for-all-regexp
(concat "\\`\\(paredit\\|sp\\)-"
(regexp-opt '("forward" "backward" "open" "close"
"wrap" "splice" "split" "join" "raise" "kill"
"semicolon" "doublequote" "backslash" "newline")
t))
"Regexp matching `paredit' and `smartparens' commands to be
added to `mc/cmds-to-run-for-all'.")
(defun add-mc-cmds (regexp type)
"Add all commands matching REGEXP to the `multiple-cursors' list for TYPE.
TYPE must be either `for-all' or `once'."
(let ((list (pcase type
(`for-all 'mc/cmds-to-run-for-all)
(`once 'mc/cmds-to-run-once)
(_ (error "Unknown command type: '%s'" type)))))
(mapatoms (lambda (sym)
(when (and (commandp sym)
(string-match-p regexp (symbol-name sym)))
(add-to-list list sym)))
obarray)))
;; (add-mc-cmds mc-paredit&sp-cmds-to-run-for-all-regexp 'for-all)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment