Thread View: net.emacs
1 messages
1 total messages
Started by king
Thu, 06 Nov 1986 23:06
minor mod to query-replace
Author: king
Date: Thu, 06 Nov 1986 23:06
Date: Thu, 06 Nov 1986 23:06
51 lines
1938 bytes
1938 bytes
From: king@kestrel.ARPA (Dick King)
First fix isearch as follows: first 3 lines
(defun isearch (forward &optional regexp prompt)
(let ((search-string "")
(search-message (or prompt ""))
(search message used to initialize to "")
last line
(message "")
search-last-string))
instead of
(message "")))
. This produces a callable form of isearch that returns the pattern.
Then define
(defun query-replace (from-string to-string &optional arg)
"\
Replace some occurrences of FROM-STRING with TO-STRING.
As each match is found, the user must type a character saying
what to do with it. For directions, type \\[help-command] at that time.
Preserves case in each replacement if case-replace and case-fold-search
are non-nil and FROM-STRING has no uppercase letters.
Third arg DELIMITED (prefix arg if interactive) non-nil means replace
only matches surrounded by word boundaries."
(interactive
(let* ((search-exit-char ?\r)
(point-orig (point))
(pattern (isearch t nil "(Query replace) ")))
(goto-char (max point-orig (- (point) (length pattern))))
(list pattern
(read-string (format "Query replace %s with: " pattern))
current-prefix-arg)))
(perform-replace from-string to-string t nil arg))
and query-replace will do the first search incrementally.
Warning - if you do a delimited query replace, the incremental search
will not be delimited.
-dick
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads