New function flatten-tree
Co-authored-by: Basil L. Contovounesios <contovob@tcd.ie> * doc/lispref/lists.texi: Document `flatten-tree'. * lisp/progmodes/js.el (js--maybe-join): * lisp/printing.el (pr-switches): * lisp/lpr.el (lpr-print-region): * lisp/gnus/nnimap.el (nnimap-find-wanted-parts): * lisp/gnus/message.el (message-talkative-question): * lisp/gnus/gnus-sum.el (gnus-remove-thread) (gnus-thread-highest-number, gnus-thread-latest-date): * lisp/eshell/esh-util.el (eshell-flatten-and-stringify): * lisp/eshell/esh-opt.el (eshell-eval-using-options): * lisp/eshell/esh-ext.el (eshell-external-command): * lisp/eshell/em-xtra.el (eshell/expr): * lisp/eshell/em-unix.el (eshell/rm, eshell-mvcpln-template) (eshell/cat, eshell/make, eshell-poor-mans-grep, eshell-grep) (eshell/du, eshell/time, eshell/diff, eshell/locate): * lisp/eshell/em-tramp.el (eshell/su, eshell/sudo): * lisp/eshell/em-term.el (eshell-exec-visual): * lisp/eshell/em-dirs.el (eshell-dirs-substitute-cd, eshell/cd): * lisp/eshell/em-basic.el (eshell/printnl): Use new flatten-tree. * lisp/progmodes/js.el (js--flatten-list): * lisp/lpr.el (lpr-flatten-list): * lisp/gnus/message.el (message-flatten-list): * lisp/eshell/esh-util.el (eshell-flatten-list): Obsolete in favor of Emacs-wide `flatten-tree'. * lisp/subr.el (flatten-list): Alias to `flatten-tree' for discoverability. * lisp/subr.el (flatten-tree): New defun. * test/lisp/subr-tests.el (subr-tests-flatten-tree): New test.
This commit is contained in:
parent
09a6cc4778
commit
36b05dc842
19 changed files with 96 additions and 72 deletions
|
@ -285,15 +285,7 @@ Prepend remote identification of `default-directory', if any."
|
|||
,@forms)
|
||||
(setq list-iter (cdr list-iter)))))
|
||||
|
||||
(defun eshell-flatten-list (args)
|
||||
"Flatten any lists within ARGS, so that there are no sublists."
|
||||
(let ((new-list (list t)))
|
||||
(dolist (a args)
|
||||
(if (and (listp a)
|
||||
(listp (cdr a)))
|
||||
(nconc new-list (eshell-flatten-list a))
|
||||
(nconc new-list (list a))))
|
||||
(cdr new-list)))
|
||||
(define-obsolete-function-alias 'eshell-flatten-list #'flatten-tree "27.1")
|
||||
|
||||
(defun eshell-uniquify-list (l)
|
||||
"Remove occurring multiples in L. You probably want to sort first."
|
||||
|
@ -330,7 +322,7 @@ Prepend remote identification of `default-directory', if any."
|
|||
|
||||
(defsubst eshell-flatten-and-stringify (&rest args)
|
||||
"Flatten and stringify all of the ARGS into a single string."
|
||||
(mapconcat 'eshell-stringify (eshell-flatten-list args) " "))
|
||||
(mapconcat 'eshell-stringify (flatten-tree args) " "))
|
||||
|
||||
(defsubst eshell-directory-files (regexp &optional directory)
|
||||
"Return a list of files in the given DIRECTORY matching REGEXP."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue