[Top][All Lists]

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

Re: Sweeter Emacs Lisp

From: Juanma Barranquero
Subject: Re: Sweeter Emacs Lisp
Date: Sun, 14 Jul 2013 19:18:09 +0200

On Sun, Jul 14, 2013 at 7:14 PM, Josh <address@hidden> wrote:

> but that canonical versions of such generally useful
> functionality should be incorporated into the core where people could
> find and use them.

Certainly. aif/awhen/when-let/if-let is so useful that it surely has
been reimplemented a billion times. I have this in my .emacs

(cl-defmacro whereas ((var test) &rest body)
  "If TEST is non-nil, bind VAR to it and then run BODY.
Return the value returned by the last form in BODY.
Else, return nil.
\n(fn (VAR TEST) &rest BODY)"
  (declare (indent 1) (debug ((sexp form) body)))
  `(let ((,var ,test))
     (when ,var ,@body)))

(I don't know where the "whereas" name originated, but I know I copied
it from somewhere.)

reply via email to

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