From: Tino Calancha <tino.calancha@gmail.com>
To: nicolas@petton.fr
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Allow for result arg in seq-doseq ?
Date: Mon, 8 Aug 2016 20:52:53 +0900 (JST) [thread overview]
Message-ID: <alpine.DEB.2.20.1608082050480.11872@calancha-pc> (raw)
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
next reply other threads:[~2016-08-08 11:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 11:52 Tino Calancha [this message]
2016-08-08 11:58 ` Allow for result arg in seq-doseq ? Nicolas Petton
2016-08-08 12:07 ` Tino Calancha
2016-08-08 13:16 ` Stefan Monnier
2016-08-08 13:25 ` Tino Calancha
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1608082050480.11872@calancha-pc \
--to=tino.calancha@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=nicolas@petton.fr \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.