unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Josh <josh@foxtail.org>
To: fgallina@gnu.org
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Sweeter Emacs Lisp
Date: Sun, 14 Jul 2013 09:18:37 -0700	[thread overview]
Message-ID: <CANdFEAF38JM-PN+bdrq2zX-7zsO_g369sJvaFOFZEpoa1X4Nqg@mail.gmail.com> (raw)
In-Reply-To: <8738rh6ftk.fsf@gnu.org>

On Sat, Jul 13, 2013 at 7:22 PM,  <fgallina@gnu.org> 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
http://lists.gnu.org/archive/html/emacs-devel/2013-06/msg01198.html.

> + 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)))

Josh



  parent reply	other threads:[~2013-07-14 16:18 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-14  2:22 Sweeter Emacs Lisp fgallina
2013-07-14 11:36 ` Dmitry Gutov
2013-07-14 11:53   ` Vitalie Spinu
2013-07-14 12:38     ` Aurélien Aptel
2013-07-14 13:25     ` Xue Fuqiao
2013-07-14 14:16     ` Pascal J. Bourguignon
2013-07-14 14:22 ` Lars Magne Ingebrigtsen
2013-07-14 16:27   ` Juanma Barranquero
2013-07-14 19:43     ` Lars Magne Ingebrigtsen
2013-07-15  3:20   ` Dmitry Gutov
2013-07-15  5:03     ` Stephen J. Turnbull
2013-07-16 20:23       ` Dmitry Gutov
2013-07-17 14:04         ` Lars Magne Ingebrigtsen
2013-07-17 15:07           ` Dmitry Gutov
2013-07-16  2:15   ` Miles Bader
2013-07-16  9:12     ` Stefan Monnier
2013-07-14 16:18 ` Josh [this message]
2013-07-14 16:30   ` Juanma Barranquero
2013-07-14 17:14     ` Josh
2013-07-14 17:18       ` Juanma Barranquero
2013-07-15  6:05         ` Lars Brinkhoff
2013-07-15  7:04   ` Stefan Monnier
2013-07-15 13:30     ` Bozhidar Batsov
2013-07-16  2:26       ` Miles Bader
2013-07-16  6:08         ` Thien-Thi Nguyen
2013-07-16 14:07           ` Drew Adams
2013-07-16  9:11       ` Stefan Monnier
2013-07-14 17:24 ` Andreas Schwab
2013-07-16  2:13 ` Miles Bader
2013-07-16  6:14   ` Stephen J. Turnbull
2013-07-16  9:07   ` Stefan Monnier
2013-07-16 11:09     ` Juanma Barranquero
2013-07-16 12:25       ` Andreas Schwab
2013-07-16 13:04         ` Thierry Volpiatto
2013-07-16 13:42         ` Juanma Barranquero
2013-07-16 14:38           ` Andreas Schwab
2013-07-16 14:42             ` Juanma Barranquero
2013-07-16 20:57       ` Stefan Monnier
2013-07-22 15:24 ` Stefan Monnier
2013-07-22 16:33   ` Thien-Thi Nguyen
2013-07-22 21:04     ` Stefan Monnier
2013-07-23  4:37       ` Thien-Thi Nguyen
2013-08-10  2:52         ` Stefan Monnier
2013-08-10 10:08         ` Pascal J. Bourguignon
2013-08-10 16:27           ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANdFEAF38JM-PN+bdrq2zX-7zsO_g369sJvaFOFZEpoa1X4Nqg@mail.gmail.com \
    --to=josh@foxtail.org \
    --cc=emacs-devel@gnu.org \
    --cc=fgallina@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).