Skip to content

Instantly share code, notes, and snippets.

@zot
Created September 10, 2013 19:52
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 zot/6514671 to your computer and use it in GitHub Desktop.
Save zot/6514671 to your computer and use it in GitHub Desktop.
kluge to clean up phi-search results in multiple-cursor mode
(defvar my-phi-search-counter 0)
(defvar my-mc-cleanup-counter 0)
(defadvice phi-search-complete (around my-phi-search-cleanup)
ad-do-it
(cl-incf my-phi-search-counter))
(defadvice mc/execute-command-for-all-fake-cursors (around my-mc/execute-command-for-fake-all-cursors)
ad-do-it
(if (< my-mc-cleanup-counter my-phi-search-counter)
(mc/cleanup-fake-cursors)))
(ad-activate 'phi-search-complete)
(ad-activate 'mc/execute-command-for-all-fake-cursors)
(defun mc/cleanup-fake-cursors ()
(setq my-mc-cleanup-counter my-phi-search-counter)
(cl-mapc (lambda (el) (mc/remove-fake-cursor el))
(cl-reduce (lambda (result sublist)
(let ((pos (overlay-get (cl-first sublist) 'point)))
(if (cl-some (lambda (el) (equal pos (overlay-get el 'point))) (cl-rest sublist))
(cons (cl-first sublist) result)
result)))
(cl-maplist 'identity (mc/all-fake-cursors))
:initial-value nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment