From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Is it possible for a macro to expand to nothing? Date: Mon, 23 Nov 2009 10:51:20 -0800 Message-ID: <203744A26D4D497A84DC56F99826973B@us.oracle.com> References: <87vdh1ccra.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1259004501 25369 80.91.229.12 (23 Nov 2009 19:28:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Nov 2009 19:28:21 +0000 (UTC) To: "'Pascal J. Bourguignon'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 23 20:28:14 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NCea5-00028w-Ij for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 20:28:14 +0100 Original-Received: from localhost ([127.0.0.1]:53196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCea5-0006FW-16 for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 14:28:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NCeZh-0006Eh-Du for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 14:27:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NCeZc-0006C5-Eb for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 14:27:48 -0500 Original-Received: from [199.232.76.173] (port=36144 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCeZc-0006Bz-9e for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 14:27:44 -0500 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:56026 helo=rgminet12.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NCeZb-0003Uu-Pr for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 14:27:44 -0500 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rgminet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nANJRZdD028173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Nov 2009 19:27:36 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nANIjtOk027265; Mon, 23 Nov 2009 19:29:33 GMT Original-Received: from abhmt006.oracle.com by acsmt355.oracle.com with ESMTP id 544985631259002279; Mon, 23 Nov 2009 10:51:19 -0800 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 23 Nov 2009 10:51:19 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <87vdh1ccra.fsf@galatea.local> Thread-Index: AcpsbGuKOEUD1YGOQuCvDbxxSjVRggAAKWIA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: acsmt355.oracle.com [141.146.40.155] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090205.4B0AE22A.00AA:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70056 Archived-At: > >> you can do that by producing nil and then using ,@ inside a > >> backquote. IOW, instead of inserting nil, you splice it in, > >> which means inserting nothing. > That wouldn't work, backquote is a quote. Sorry, but it works just fine. I do this all the time. You snipped out the code I suggested. Here it is again, with `and' substituted for `ifdef' (which is undefined). (defmacro titi (fn) `(defun ,fn () (setq bar 1) ,@(and baz '((setq bar 2))))) (let ((baz nil)) (titi foo)) (symbol-function 'foo) -> (lambda nil (setq bar 1)) (let ((baz t)) (titi foo)) (symbol-function 'foo) -> (lambda nil (setq bar 1) (setq bar 2)) That looks to me like just what Alan asked for.