Open nispio opened 9 years ago
You want something like this?
(defun phi-search-complete-with-selection ()
(interactive)
(phi-search-complete
`(lambda ()
(interactive)
(when (looking-back ,(buffer-string))
(push-mark (match-beginning 0) t t)
(goto-char (match-end 0))
(activate-mark)))))
That does exactly what I want, unless I invoke phi-search-mc/mark-all
first, and then it just makes a mess. Do you know how to fix it so that each cursor selects its own match?
@nispio Does this work for you?
(defun phi-search-complete-with-selection ()
(interactive)
(let ((query (buffer-string)))
(phi-search-complete)
(mc/execute-command-for-all-cursors
(lambda ()
(interactive)
(when (looking-back query)
(push-mark (match-beginning 0) t t)
(goto-char (match-end 0))
(activate-mark))))))
It does, thanks!
This implementation uses looking-back
which is in accordance with the current behavior of phi-search (https://github.com/zk-phi/phi-search/issues/28). So, I'll see how the issue is dealt with before making a PR.
Now that phi-search has changed the behavior I'll have to find out a way for this.
Any thoughts on how to get this working again?
Is there a way to call
phi-search-mc/mark-all
such that for each of the cursors the matching text stays selected after exitingphi-search
?I often find myself using
phi-search
to search for a regexp, and then callingphi-search-mc/mark-all
. When I closephi-search
, I have a cursor at each of the matches, but the match is not highlighted. Since I am using regexps, there is not easy way to re-highlight the match at each of the cursors, because each match may be different.