help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to put this in a macro


From: Cecil Westerhof
Subject: Re: How to put this in a macro
Date: Tue, 04 May 2010 15:45:00 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Cecil Westerhof <Cecil@decebal.nl> writes:

> Almost. It looks like the following does what I want:
>     (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-sym (point-min)))
>            (set ,end-sym (or ,end-sym (point-max))))))
>

Almost. It should be:
    (defmacro dcbl-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 (symbol-value ,start-sym) (point-min)))
           (set ,end-sym   (or (symbol-value ,end-sym)   (point-max))))
           (if (> (symbol-value ,start-sym) (symbol-value ,end-sym))
               (let ((temp (symbol-value ,start-sym)))
                 (set ,start-sym (symbol-value ,end-sym))
                 (set ,end-sym   temp)))))

I also make sure now that start is not after end.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


reply via email to

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