* Wrapper for query-replace does not use query-replace-history
@ 2009-06-11 7:48 Nordlöw
2009-06-12 0:45 ` Barry Margolin
0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2009-06-11 7:48 UTC (permalink / raw)
To: help-gnu-emacs
Hey I have a built a convenience wrapper for query-replace-regexp that
surrounds it argument with beginning and end of symbol regexps. I want
it to modify query-replace-history but it doesn't. Why?
/Nordlöw
Code follows.
(defun build-symbol-regexp (id)
"Matches an ID as single word symbol (or C identifier) that
does not respect underscore."
(concat "\\_<" id "\\_>"))
;; In Emacs-Lisp mode minus-sign is not allowed before or after.
(defun query-replace-symbol (source dest)
"Rename a symbol (currently C-style) string symbol (identifier)
which unique name
is determined by SOURCE replacing it with DEST."
(interactive "sQuery replace symbol (identifier): \nsReplace with:
")
(query-replace-regexp (build-symbol-regexp
(regexp-quote source)) ;quote string to
regexp
(concat dest)))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Wrapper for query-replace does not use query-replace-history
2009-06-11 7:48 Wrapper for query-replace does not use query-replace-history Nordlöw
@ 2009-06-12 0:45 ` Barry Margolin
0 siblings, 0 replies; 2+ messages in thread
From: Barry Margolin @ 2009-06-12 0:45 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]
In article
<2cccace8-2617-40bd-ba82-9163412ba3db@e21g2000yqb.googlegroups.com>,
Nordlöw <per.nordlow@gmail.com> wrote:
> Hey I have a built a convenience wrapper for query-replace-regexp that
> surrounds it argument with beginning and end of symbol regexps. I want
> it to modify query-replace-history but it doesn't. Why?
History is maintained by the prompting part of the UI. Since your
function never calls query-replace-read-from or query-replace-read-to to
read the arguments interactively, history isn't updated. See the source
code for query-replace.
>
> /Nordlöw
>
> Code follows.
>
> (defun build-symbol-regexp (id)
> "Matches an ID as single word symbol (or C identifier) that
> does not respect underscore."
> (concat "\\_<" id "\\_>"))
>
> ;; In Emacs-Lisp mode minus-sign is not allowed before or after.
> (defun query-replace-symbol (source dest)
> "Rename a symbol (currently C-style) string symbol (identifier)
> which unique name
> is determined by SOURCE replacing it with DEST."
> (interactive "sQuery replace symbol (identifier): \nsReplace with:
> ")
> (query-replace-regexp (build-symbol-regexp
> (regexp-quote source)) ;quote string to
> regexp
> (concat dest)))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-12 0:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-11 7:48 Wrapper for query-replace does not use query-replace-history Nordlöw
2009-06-12 0:45 ` Barry Margolin
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.