From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: macro-replacement with quotes Date: Mon, 25 Jan 2016 12:10:38 +0100 Message-ID: <874me1didt.fsf@mbork.pl> References: <87powq3amm.fsf@russet.org.uk> <87d1sqd36h.fsf@mbork.pl> <87zivut13d.fsf@russet.org.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1453720276 19617 80.91.229.3 (25 Jan 2016 11:11:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jan 2016 11:11:16 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Phillip Lord Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 25 12:11:08 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 1aNf36-0008HJ-GR for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Jan 2016 12:11:08 +0100 Original-Received: from localhost ([::1]:37260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNf35-0006lS-P9 for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Jan 2016 06:11:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNf2q-0006iU-Rn for help-gnu-emacs@gnu.org; Mon, 25 Jan 2016 06:10:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNf2m-0002v7-Ce for help-gnu-emacs@gnu.org; Mon, 25 Jan 2016 06:10:52 -0500 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:58224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNf2m-0002v1-5B for help-gnu-emacs@gnu.org; Mon, 25 Jan 2016 06:10:48 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 6CA9A8F201D; Mon, 25 Jan 2016 12:10:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ox4TA47LaDOW; Mon, 25 Jan 2016 12:10:39 +0100 (CET) Original-Received: from localhost (unknown [109.232.24.28]) by mail.mojserwer.eu (Postfix) with ESMTPSA id D71178F201C; Mon, 25 Jan 2016 12:10:38 +0100 (CET) User-agent: mu4e 0.9.13; emacs 25.1.50.1 In-reply-to: <87zivut13d.fsf@russet.org.uk> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 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:108844 Archived-At: On 2016-01-25, at 11:17, Phillip Lord wrote: > 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! Glad that it helped. It occurred to me now that another way might be to use something like ``(a b), which apparently yields a similar result, but less of a pain to type. Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University