[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sweeter Emacs Lisp
From: |
Stefan Monnier |
Subject: |
Re: Sweeter Emacs Lisp |
Date: |
Fri, 09 Aug 2013 22:52:02 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> (defmacro cool-cond (&rest clauses)
> (let ((rev (reverse clauses))
> one elab)
> (while (setq one (pop rev))
> (setq elab (pcase one
> (`(let ,var ,exp)
> `((t (let ((,var ,exp))
> (cond ,@elab)))))
> (`(let ,var)
> `((t (let (,var)
> (cond ,@elab)))))
> (_ (cons one elab)))))
> `(cond ,@elab)))
That sounds about right. Two remaining problems:
- Easy one: improve the macro to reduce the nesting depth (consecutive
`let's should be turned into a single let*, and consecutive non-lets
should be together in a single `cond'). You can probably use
macroexp-let* and macroexp-if for that.
- Hard one: come up with a better name.
Stefan
- Re: Sweeter Emacs Lisp,
Stefan Monnier <=