From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.help Subject: Re: macro-replacement with quotes Date: Mon, 25 Jan 2016 10:17:26 +0000 Message-ID: <87zivut13d.fsf@russet.org.uk> References: <87powq3amm.fsf@russet.org.uk> <87d1sqd36h.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1453719006 31373 80.91.229.3 (25 Jan 2016 10:50:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jan 2016 10:50:06 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 25 11:50:06 2016 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 1aNeij-0006rb-EP for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Jan 2016 11:50:05 +0100 Original-Received: from localhost ([::1]:37117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNeii-00065Z-So for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Jan 2016 05:50:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNeiX-000657-Kx for help-gnu-emacs@gnu.org; Mon, 25 Jan 2016 05:49:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNeiU-0006Nm-DO for help-gnu-emacs@gnu.org; Mon, 25 Jan 2016 05:49:53 -0500 Original-Received: from cheviot12.ncl.ac.uk ([128.240.234.12]:54769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNeiU-0006NF-6R for help-gnu-emacs@gnu.org; Mon, 25 Jan 2016 05:49:50 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot12.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1aNeD9-0001pX-9w; Mon, 25 Jan 2016 10:17:27 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1aNeD8-0007nu-U3; Mon, 25 Jan 2016 10:17:26 +0000 In-Reply-To: <87d1sqd36h.fsf@mbork.pl> (Marcin Borkowski's message of "Sun, 24 Jan 2016 23:26:46 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.12 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:108843 Archived-At: Marcin Borkowski writes: > On 2016-01-24, at 22:56, Phillip Lord wrote: > >> Is it possible to build a list within a macro which contains backquote, >> quote or comma symbols in it? >> >> Specifically, I was thinking of building a macro which expands to a >> pcase form, but I need the ` symbol in the expansion. > > I'm not sure whether this would help (I know next to nothing about > pcase), but would \` and \, suffice for you? > > If I do M-: (read) and type `(a ,b), I get (\` (a (\, b))), which seems > to be equivalent to `(a ,b) in terms of `eval'. Dunno about pcase, > though. > >> Phil > > Best, Hmm, yes, you are right. I didn't realise that (\` x) was equivalent to `x, but this works... (pcase 10 ((\` (\, a)) a)) And this... (defun quote-and-comma-arg (def) (list '\` (list (list '\, (car def))))) (defmacro p-test (def) `(pcase 10 (,(quote-and-comma-arg def) ,(car def)))) (p-test (a)) expands to (pcase 10 (`(,a) a)) which returns "10". The joy of lisp!