From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Allow for result arg in seq-doseq ? Date: Mon, 8 Aug 2016 20:52:53 +0900 (JST) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1470657275 21457 195.159.176.226 (8 Aug 2016 11:54:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 8 Aug 2016 11:54:35 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Emacs developers To: nicolas@petton.fr Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 08 13:54:30 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWj8Q-0003ko-8D for ged-emacs-devel@m.gmane.org; Mon, 08 Aug 2016 13:54:23 +0200 Original-Received: from localhost ([::1]:56587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWj8M-0006vq-UM for ged-emacs-devel@m.gmane.org; Mon, 08 Aug 2016 07:54:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWj78-0006sb-5f for emacs-devel@gnu.org; Mon, 08 Aug 2016 07:53:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWj74-0002Ep-25 for emacs-devel@gnu.org; Mon, 08 Aug 2016 07:53:01 -0400 Original-Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWj73-0002Ef-Qo for emacs-devel@gnu.org; Mon, 08 Aug 2016 07:52:57 -0400 Original-Received: by mail-pf0-x243.google.com with SMTP id i6so24943363pfe.0 for ; Mon, 08 Aug 2016 04:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:user-agent:mime-version; bh=ZinBpzoFtwFAVpLaz9cZpQDse1qRybuv0fyhMmheZM0=; b=TvgM2ilQg8HwdwZu7oG5nvYjZwv9RU2CIZfukNwvQ6hI2OPF2DevN8N/K3ZS6mXp/d NX0F93Ot3iqwfmJRYIxr26XmIF6LKzEZVe1U6/TUFzSqA7V4Yw3vHR2m87pTCbNXl8Yj 6iDrSS0WcevklucA7zWsWmfP+iqfrTE8hYsyWiVNjfHymgR9TiFrvERWlcKjfen2Ui51 z1/vTxzHe0fMT+rRrsBzg8sxusBlbK56eEjpgf9JOqK4GgAIBV3g98kgkF8YFMtEBaRT +BAwCCCcff60ppnI9be21nCZghO8+USco5+OZkgoRB7j+Jw3CWg25HnsRQohFjtejK6f DrbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:message-id:user-agent :mime-version; bh=ZinBpzoFtwFAVpLaz9cZpQDse1qRybuv0fyhMmheZM0=; b=l2imM4T/pNcu5csDeqxDIV5GjQG0iAnlqTllmlkXM1sbdOKEhIAEyNL3KadJ0YB7Ra UfNGiHzJjimlVtADsjzsEQC7tOgKAqrlq/plVrjlpJvdX4WLsFL9bAVJt4DRkMpGVoPt UwITzawKKCOD18FFyW1ZdzL7XFpzepqvfYjyXIyrPKGMN0kyzQZR8HWbHi02QM4sAxY7 Vx56/XEHZyPm08TmAOn/1BAQOHb2dlIoNzCxNO2b+IcL2ykO8HMz3gFHrGbnICwigPpL Agts181357vchyj+eFtj2OFAdjNDFNSQ7qppEri5dOX4HZNqDXNZIP928+TDikGjaqXy OyLQ== X-Gm-Message-State: AEkooutWVv1uMd0XB3ZrwckRunxq58SkAMbN6Opuy/6nd2MAgmWQfHvVPaDECqjnWrZEpg== X-Received: by 10.98.57.90 with SMTP id g87mr161957119pfa.106.1470657176875; Mon, 08 Aug 2016 04:52:56 -0700 (PDT) Original-Received: from calancha-pc (152021171106.wi-fi.kddi.com. [106.171.21.152]) by smtp.gmail.com with ESMTPSA id n9sm47764201paz.13.2016.08.08.04.52.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Aug 2016 04:52:56 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::243 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:206479 Archived-At: Dear Nico, Currently seq-doseq unconditionally returns the input sequence. Do you think might be useful to allow for an arg RESULT in the SPEC as `dolist' does? I mean something as follows: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index e5004f8..109f547 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -62,14 +62,19 @@ (defmacro seq-doseq (spec &rest body) "Loop over a sequence. Evaluate BODY with VAR bound to each element of SEQUENCE, in turn. +Return RESULT if non-nil, otherwise return SEQUENCE. Similar to `dolist' but can be applied to lists, strings, and vectors. -\(fn (VAR SEQUENCE) BODY...)" +\(fn (VAR SEQUENCE [RESULT]) BODY...)" (declare (indent 1) (debug ((symbolp form &optional form) body))) - `(seq-do (lambda (,(car spec)) - ,@body) - ,(cadr spec))) + `(progn + (seq-do (lambda (,(car spec)) + ,@body) + ,(cadr spec)) + ,(if (cddr spec) + (car (cddr spec)) + (cadr spec)))) (pcase-defmacro seq (&rest patterns) "Build a `pcase' pattern that matches elements of SEQUENCE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.1.50 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6) of 2016-08-07 Repository revision: b593ea1f9b7068c03fe6527a3cb6d5e1b2cd9736