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

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

Re: Using lisp code in query-replace-regexp


From: Andreas Röhler
Subject: Re: Using lisp code in query-replace-regexp
Date: Tue, 04 Nov 2014 19:38:01 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.2.0

On 04.11.2014 15:49, Julien Cubizolles wrote:
I can use the following replace string (for lack of a better term) with
query-replace-regexp

--8<---------------cut here---------------start------------->8---
\,(if (equal \2 nil) "+" (concat "+ " \2 " ::"))
--8<---------------cut here---------------end--------------->8---

How can I input it in a lisp function like:

--8<---------------cut here---------------start------------->8---
(defun jc-item-to-plus (Begin End)
   "Replace \\item by +"
   (interactive "r")
   (query-replace-regexp Begin End "some_standard_regexp" (if (equal \2 nil) "+" (concat "+ 
" \2 " ::")))
   )
--8<---------------cut here---------------end--------------->8---

Julien.




When writing a program, for example start with

(narrow-to-region beg end)
(goto-char (point-min))
(while (re-search-forward RE end)
(replace-match ...

etc.



reply via email to

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