* bug#20430: 24.5; Enhancement request: extra hook for query-replace and friends
@ 2015-04-26 9:02 Chris, Poole <chris
2015-06-02 22:50 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Chris, Poole <chris @ 2015-04-26 9:02 UTC (permalink / raw)
To: 20430
Would be very useful to have a hook that's called when the next
potential match item is shown with isearch, query-replace, etc.
Hook should run after point is moved to the next search hit and before
reading your input char.
Explanation and justification comes from answer to my question:
http://emacs.stackexchange.com/a/10903/7132
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#20430: 24.5; Enhancement request: extra hook for query-replace and friends
2015-04-26 9:02 bug#20430: 24.5; Enhancement request: extra hook for query-replace and friends Chris, Poole <chris
@ 2015-06-02 22:50 ` Juri Linkov
2015-12-24 0:41 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2015-06-02 22:50 UTC (permalink / raw)
To: chris; +Cc: 20430
> Would be very useful to have a hook that's called when the next
> potential match item is shown with isearch, query-replace, etc.
>
> Hook should run after point is moved to the next search hit and before
> reading your input char.
>
> Explanation and justification comes from answer to my question:
> http://emacs.stackexchange.com/a/10903/7132
It's possible to recenter in query-replace by adding an advice
on isearch-search-fun-default like it was possible to recenter
in isearch by advising isearch-update. To make it simpler,
a special hook `isearch-update-post-hook' was already added, so
a similar hook `replace-update-post-hook' could be added for
query-replace as well:
diff --git a/lisp/replace.el b/lisp/replace.el
index 1bf1343..fc47dda 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1978,6 +1978,9 @@ passed in. If LITERAL is set, no checking is done, anyway."
(when backward (goto-char (nth 0 match-data)))
noedit)
+(defvar replace-update-post-hook nil
+ "Function(s) to call after query-replace has found matches in the buffer.")
+
(defvar replace-search-function nil
"Function to use when searching for strings to replace.
It is used by `query-replace' and `replace-string', and is called
@@ -2274,6 +2276,7 @@ make, or the user didn't cancel the call."
(match-substitute-replacement next-replacement
nocasify literal))
next-replacement)))
+ (run-hooks 'replace-update-post-hook)
(message message
(query-replace-descr from-string)
(query-replace-descr replacement-presentation)))
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-24 0:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-26 9:02 bug#20430: 24.5; Enhancement request: extra hook for query-replace and friends Chris, Poole <chris
2015-06-02 22:50 ` Juri Linkov
2015-12-24 0:41 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).