From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Julien Cubizolles Newsgroups: gmane.emacs.help Subject: Using lisp code in query-replace-regexp Date: Tue, 04 Nov 2014 15:49:22 +0100 Message-ID: <87mw87owb1.fsf@free.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1415112615 28335 80.91.229.3 (4 Nov 2014 14:50:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Nov 2014 14:50:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 04 15:50:09 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XlfQu-0001UM-Qw for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Nov 2014 15:50:08 +0100 Original-Received: from localhost ([::1]:40935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlfQu-0007mh-Gz for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Nov 2014 09:50:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlfQb-0007m5-5V for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 09:49:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlfQT-0006or-Lf for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 09:49:49 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:43387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlfQT-0006od-F8 for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 09:49:41 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XlfQM-0001AW-E6 for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 15:49:35 +0100 Original-Received: from gas45-3-82-244-252-119.fbx.proxad.net ([82.244.252.119]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Nov 2014 15:49:34 +0100 Original-Received: from j.cubizolles by gas45-3-82-244-252-119.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Nov 2014 15:49:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 18 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: gas45-3-82-244-252-119.fbx.proxad.net User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:fkBHZs/PX6JZK+WeXQHM6qIoJ+A= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100729 Archived-At: 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.