From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Is it possible for a macro to expand to nothing? Date: Mon, 23 Nov 2009 20:09:34 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1259010190 12683 80.91.229.12 (23 Nov 2009 21:03:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Nov 2009 21:03:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 23 22:03:03 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 1NCg3f-0000xX-QT for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 22:02:52 +0100 Original-Received: from localhost ([127.0.0.1]:56412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCg3f-0006H8-EK for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 16:02:51 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news2.euro.net!newsfeed.freenet.de!news.tu-darmstadt.de!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Original-NNTP-Posting-Host: marvin.muc.de Original-X-Trace: colin2.muc.de 1259006974 98104 2001:608:1000::2 (23 Nov 2009 20:09:34 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: Mon, 23 Nov 2009 20:09:34 +0000 (UTC) User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386)) Original-Xref: news.stanford.edu gnu.emacs.help:174989 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:70061 Archived-At: Hi, Drew! Drew Adams wrote: >> I think I want to be able to do this: >> (defun foo () >> (setq bar 1) >> (ifdef baz (setq bar 2))) >> , and if baz is nil at compile time, this function should be >> identical to >> (defun foo () >> (setq bar 1)) > (defmacro titi (fn) > `(defun ,fn () > (setq bar 1) > ,@(ifdef baz '((setq bar 2)))))) > Assuming that ifdef returns nil if baz is nil, that should give you > (defun foo () (setq bar 1)). If baz is not nil, it should give you > this: > (defun foo () > (setq bar 1) > (setq bar 2)) > Or something like that. Wow, you're a genius, Drew! It's a little bit ugly having to write a defmacro around a defun, but only a very very little. The way you've described actually looks fairly obviousi now, but these things always do after somebody bright has just shown you them. Thanks again! -- Alan Mackenzie (Nuremberg, Germany).