[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to put this in a macro
From: |
Barry Margolin |
Subject: |
Re: How to put this in a macro |
Date: |
Tue, 04 May 2010 15:44:54 -0000 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <87pr1zw164.fsf@linux-lqcw.site>,
Cecil Westerhof <Cecil@decebal.nl> wrote:
> In my code I use the following code on several places:
> (if (equal start end)
> (setq start (point-min)
> end (point-max))
> (setq start (or start (point-min)))
> (setq end (or end (point-max))))
>
> I think it would be good to put this in a macro. How would I write a
> macro for this code?
>
> Or could it be done with a function?
(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))))
You then use this as:
(canonicalize-start-end start end)
--
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 ***
- How to put this in a macro, Cecil Westerhof, 2010/05/04
- Re: How to put this in a macro, José A . Romero L ., 2010/05/04
- Re: How to put this in a macro,
Barry Margolin <=
- Re: How to put this in a macro, Cecil Westerhof, 2010/05/04
- Re: How to put this in a macro, José A . Romero L ., 2010/05/04
- Re: How to put this in a macro, Cecil Westerhof, 2010/05/04
- Re: How to put this in a macro, José A . Romero L ., 2010/05/04
- Re: How to put this in a macro, Cecil Westerhof, 2010/05/04
- Re: How to put this in a macro, José A . Romero L ., 2010/05/04
- Re: How to put this in a macro, Barry Margolin, 2010/05/04
- Re: How to put this in a macro, José A . Romero L ., 2010/05/04
- Re: How to put this in a macro, Barry Margolin, 2010/05/04
- Re: How to put this in a macro, Cecil Westerhof, 2010/05/04