From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: How to put this in a macro Date: Sat, 17 Apr 2010 11:14:38 -0400 Organization: A noiseless patient Spider Message-ID: References: <87pr1zw164.fsf@linux-lqcw.site> <87d3xywpm6.fsf@linux-lqcw.site> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1273009324 19756 80.91.229.12 (4 May 2010 21:42:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 4 May 2010 21:42:04 +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 May 04 23:42:03 2010 connect(): No such file or directory 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.69) (envelope-from ) id 1O9PsQ-0004Up-Ud for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 23:42:03 +0200 Original-Received: from localhost ([127.0.0.1]:59119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9PsQ-0006DU-Cp for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 17:42:02 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!feeder.eternal-september.org!eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Injection-Date: Sat, 17 Apr 2010 15:14:37 +0000 (UTC) Injection-Info: barmar.motzarella.org; posting-host="+bxBiZT/p0ZLLuDb5H+JCw"; logging-data="13560"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196uUaKwOvKGlkv2KtRu/qk" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:Z5Pb0BD0d70FM1X0z8IPMu0oKPQ= Original-Xref: usenet.stanford.edu gnu.emacs.help:177752 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:73198 Archived-At: In article , José A. Romero L. wrote: > On 17 Kwi, 08:38, Cecil Westerhof wrote: > > Barry Margolin writes: > > > (defmacro canonicalize-start-end (start-var end-var) > > >   `(if (equal ,start-var ,end-var) > > >        (setq ,start-var (point-min) > > >              ,end-var (point-max)) > > >      (setq ,start-var (or ,start-var (point-min)) > > >            ,end-var (or ,end-var (point-max)))) > > > > This gives an error: > >     Debugger entered--Lisp error: (void-variable start-var) > >       (list (quote equal) start-var end-var) > (...) > > Makes sense. In general writing things like `(setq ,foo bar) is (if > possible at all) asking for trouble -- what would happen when foo is > nil, or 5? My macro requires that the parameters be variables, not expressions. > > Maybe you could do something like this: > > (defmacro cw/set-bounds (start-sym end-sym) > `(if (equal (symbol-value ,start-sym) (symbol-value ,end-sym)) > (progn > (set ,start-sym (point-min)) > (set ,end-sym (point-max))) > (progn > (set ,start-sym (or start (point-min))) > (set ,end-sym (or end (point-max)))))) > > and use it as: > > (cw/set-bounds 'start 'end) > > i.e. passing the symbols of the variables you want to set. If you call it like that, it can be a function, not a macro. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***