help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wrapper for query-replace does not use query-replace-history


From: Nordlöw
Subject: Wrapper for query-replace does not use query-replace-history
Date: Thu, 11 Jun 2009 00:48:31 -0700 (PDT)
User-agent: G2/1.0

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)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]