[Top][All Lists]

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

Re: Sweeter Emacs Lisp

From: Josh
Subject: Re: Sweeter Emacs Lisp
Date: Sun, 14 Jul 2013 09:18:37 -0700

On Sat, Jul 13, 2013 at 7:22 PM,  <address@hidden> wrote:
> may be time for Emacs Lisp to evolve and provide similar stuff making
> easier/more-fun to write code in it. Here's a detailed list with
> examples of what I would want to see as part of core Emacs Lisp:

I made a related suggestion recently, see the thread at

> + when-let, if-let:
>   ;; clojure.core/when-let
>   ;; ([bindings & body])
>   ;; Macro
>   ;;  bindings => binding-form test
>   ;;  When test is true, evaluates body with binding-form bound to the value 
> of test
>   ;;-------------------------
>   ;; clojure.core/if-let
>   ;; ([bindings then] [bindings then else & oldform])
>   ;; Macro
>   ;;  bindings => binding-form test
>   ;;  If test is true, evaluates then with binding-form bound to the value of
>   ;;  test, if not, yields else

I'm not very familiar with Clojure but these appear to be available
already in the form of two anaphoric macros that ship with Emacs
(`ibuffer-awhen' and `ibuffer-aif').  Unfortunately, being tucked away
as they are in ibuf-macs.el (which is not loaded by default), anyone
looking for this functionality with `apropos' or `info-apropos' would
find nothing and conclude that they did not exist yet, and as a result
needlessly re-implement them herself or drag in another library.

>     (let ((pos (re-search-backward "regex" nil t)))
>       (when pos
>         (list pos (match-string-no-properties 0))))
>     (when-let ((pos (re-search-backward "regex" nil t)))
>        (list pos (match-string-no-properties 0)))

(require 'ibuf-macs)
(ibuffer-awhen (re-search-backward "regex" nil t)
  (list it (match-string-no-properties 0)))


reply via email to

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