[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wrapper for query-replace does not use query-replace-history
From: |
Barry Margolin |
Subject: |
Re: Wrapper for query-replace does not use query-replace-history |
Date: |
Thu, 11 Jun 2009 20:45:15 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
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 ***