From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Wrapper for query-replace does not use query-replace-history Date: Thu, 11 Jun 2009 20:45:15 -0400 Organization: A noiseless patient Spider Message-ID: References: <2cccace8-2617-40bd-ba82-9163412ba3db@e21g2000yqb.googlegroups.com> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1244770844 20480 80.91.229.12 (12 Jun 2009 01:40:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Jun 2009 01:40:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 12 03:40:42 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MEvl4-0004Vh-1y for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Jun 2009 03:40:42 +0200 Original-Received: from localhost ([127.0.0.1]:47143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MEvl3-0003xo-5w for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Jun 2009 21:40:41 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!feeder.motzarella.org!news.motzarella.org!motzarella.org!news.eternal-september.org!barmar.motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-X-Trace: news.eternal-september.org U2FsdGVkX18Lki1pDFqIJXdEOj4TOkVc4uuq47E9Cu6ZlIi9AMewAmINF22HccqdIcMITM3tzNIYqCJvgbBQsndkJQ9BHhQn6VPAXZmF3GN+XIXAfXqv/C1BT3FM6SHPQt+hf7iia4g= Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Fri, 12 Jun 2009 00:45:15 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19KciKnBBHjtnSYa7nTrCHoVKXqyTT8Ycs= Cancel-Lock: sha1:14EVqmR7MVPmgLU6abtwe2vm+SI= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Mail-Copies-To: nobody Original-Xref: news.stanford.edu gnu.emacs.help:169956 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65179 Archived-At: In article <2cccace8-2617-40bd-ba82-9163412ba3db@e21g2000yqb.googlegroups.com>, Nordlöw 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 ***