all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: Wrapper for query-replace does not use query-replace-history
Date: Thu, 11 Jun 2009 20:45:15 -0400	[thread overview]
Message-ID: <barmar-890155.20451511062009@mara100-84.onlink.net> (raw)
In-Reply-To: 2cccace8-2617-40bd-ba82-9163412ba3db@e21g2000yqb.googlegroups.com

[-- 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 ***


      reply	other threads:[~2009-06-12  0:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-11  7:48 Wrapper for query-replace does not use query-replace-history Nordlöw
2009-06-12  0:45 ` Barry Margolin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-890155.20451511062009@mara100-84.onlink.net \
    --to=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.