[Top][All Lists]

[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 <address@hidden>,
 Cecil Westerhof <address@hidden> 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, address@hidden
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 ***

reply via email to

[Prev in Thread] Current Thread [Next in Thread]