--- Begin Message ---
Subject: |
Add flatten-list? |
Date: |
Wed, 07 Nov 2018 13:46:29 -0600 |
User-agent: |
mu4e 1.1.0; emacs 27.0.50 |
Could we add a new function `flatten-list'? There seems to be a need for
it. Inside Emacs itself, I see at least four implementations of the same
basic thing:
- eshell-flatten-list
- message-flatten-list
- lpr-flatten-list
- js--flatten-list
And there are many more in the various 3rd-party packages.
I was thinking of putting it in subr.el. What do you think?
Thanks,
Alex
diff --git a/lisp/subr.el b/lisp/subr.el
index 41dc9aa45f..3ea75ddf56 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -5447,5 +5447,14 @@ This function is called from lisp/Makefile and
leim/Makefile."
(setq file (concat (substring file 1 2) ":" (substring file 2))))
file)
+(defun flatten-list (list)
+ "Take LIST and \"flatten\" it.
+The result will be a list containing all the elements of LIST.
+\(flatten-list \\='(1 (2 3 (4 5 (6))) 7))
+=> (1 2 3 4 5 6 7)"
+ (cond ((null list) nil)
+ ((consp list) (append (flatten-list (car list))
+ (flatten-list (cdr list))))
+ (t (list list))))
;;; subr.el ends here
signature.asc
Description: PGP signature
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#33309: [PATCH] flatten-list |
Date: |
Mon, 17 Dec 2018 12:33:58 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Version: 27.1
Alex Branham <address@hidden> writes:
Hi Alex,
> Thanks, changed. Updated patch attached.
There haven't been further comments, so I have pushed your patch to
master. Tramp is also adapted. Closing the bug.
> Alex
Best regards, Michael.
--- End Message ---