From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Josh Newsgroups: gmane.emacs.devel Subject: Re: Sweeter Emacs Lisp Date: Sun, 14 Jul 2013 09:18:37 -0700 Message-ID: References: <8738rh6ftk.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1373818753 11933 80.91.229.3 (14 Jul 2013 16:19:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Jul 2013 16:19:13 +0000 (UTC) Cc: emacs-devel To: fgallina@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 14 18:19:15 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UyP0z-0005VG-5s for ged-emacs-devel@m.gmane.org; Sun, 14 Jul 2013 18:19:13 +0200 Original-Received: from localhost ([::1]:58627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyP0y-0007jU-OY for ged-emacs-devel@m.gmane.org; Sun, 14 Jul 2013 12:19:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyP0v-0007jD-BF for emacs-devel@gnu.org; Sun, 14 Jul 2013 12:19:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyP0u-00082o-6D for emacs-devel@gnu.org; Sun, 14 Jul 2013 12:19:09 -0400 Original-Received: from mail-qc0-f177.google.com ([209.85.216.177]:56662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyP0u-00082f-2J for emacs-devel@gnu.org; Sun, 14 Jul 2013 12:19:08 -0400 Original-Received: by mail-qc0-f177.google.com with SMTP id n1so5804158qcx.36 for ; Sun, 14 Jul 2013 09:19:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=laCpaInTxnH9ATl69Sfo9Lt98SQdJ4WJKXLm/pHJmiY=; b=I5U+3mwPLNd8uxExnNqVMDz3biRW1DzpO95HbEbOoXCjuYhs+BhnqIYnfW5KrOedAM D4EavwtubX5Yl0hlnGAY6wHx5xXmfHqoktsUC6IXBnBCQYElVhFkEqTCeprXA6gC4Hh1 BtGbgQJo83jBOX4cWOrYktsxMuLHzAmRiLU5Zm9J87EyFYiX6/dHae6c1Ed1eqgwvQln G+e+/msvCI5AIl14Q/78jZYJDCs6o2yV79BDl22r41l/UOGaR+SflANvyqbIkk+vrQXN JJQJUEELhQewOfSaQdXAEQ7I0pFMJ4hGLr29P5RF0YZgcs80grrJLq/PnSCixljEKWwo F7cw== X-Received: by 10.229.106.163 with SMTP id x35mr5572270qco.70.1373818747690; Sun, 14 Jul 2013 09:19:07 -0700 (PDT) Original-Received: by 10.49.30.41 with HTTP; Sun, 14 Jul 2013 09:18:37 -0700 (PDT) In-Reply-To: <8738rh6ftk.fsf@gnu.org> X-Google-Sender-Auth: -68MuTcvOEIS2ORZHmWRMR-rzPA X-Gm-Message-State: ALoCoQlFITw7WZzNURel+bnClwQi9gxcFg4J7R+GT7p5dxVdMMgkA3TWu1Hq6kvIiO0KFX95Zi/T X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.216.177 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:161875 Archived-At: On Sat, Jul 13, 2013 at 7:22 PM, 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