Created
September 10, 2013 19:52
-
-
Save zot/6514671 to your computer and use it in GitHub Desktop.
kluge to clean up phi-search results in multiple-cursor mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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