emacs-devel
[Top][All Lists]
Advanced

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

Re: rx: Adding custom sexps to work with.


From: Andreas Schwab
Subject: Re: rx: Adding custom sexps to work with.
Date: Sun, 03 Oct 2010 21:10:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Fabian Ezequiel Gallina <address@hidden> writes:

> (defmacro python-rx (&rest body-forms)
>   "Python mode especialized rx macro which supports common python
> named regexps."
>   `(let ((rx-constituents (append ',python-rx-constituents rx-constituents)))
>        (rx ,@body-forms)))

You need to install the binding while the macro is expanded, not making
it part of the expansion.  For the rest just copy the rx macro:

(defmacro python-rx (&rest regexps)
  "Python mode especialized rx macro which supports common python named 
regexps."
  (let ((rx-constituents (append python-rx-constituents rx-constituents)))
    (cond ((null regexps)
           (error "No regexp"))
          ((cdr regexps)
           (rx-to-string `(and ,@regexps) t))
          (t
           (rx-to-string (car regexps) t)))))

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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