From: Paul Eggert Date: Mon, 17 Dec 2018 18:19:23 +0000 (-0800) Subject: Some more flatten-tree aliases X-Git-Tag: emacs-27.0.90~3974 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ef144113f3473f39d3df3e96e780c832e0d5420e;p=emacs.git Some more flatten-tree aliases * lisp/allout.el (allout-flatten): * lisp/progmodes/hideif.el (hif-flatten): Now an obsolete alias for flatten-tree. All callers changed. * lisp/org/org-protocol.el (org-protocol-flatten): Make it an alias for flatten-tree if available. * lisp/progmodes/js.el (js--flatten-list): Remove alias. We shouldn’t need obsolete function aliases for private functions. --- diff --git a/lisp/allout.el b/lisp/allout.el index a123ece9b95..242b1f2c87f 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -4351,7 +4351,7 @@ subtopics into siblings of the item." (let ((children-chart (allout-chart-subtree 1))) (if (listp (car children-chart)) ;; whoops: - (setq children-chart (allout-flatten children-chart))) + (setq children-chart (flatten-tree children-chart))) (save-excursion (dolist (child-point children-chart) (goto-char child-point) @@ -6547,14 +6547,7 @@ If BEG is bigger than END we return 0." (apply 'concat (mapcar (lambda (char) (if (= char ?%) "%%" (char-to-string char))) string))) -;;;_ : lists -;;;_ > allout-flatten (list) -(defun allout-flatten (list) - "Return a list of all atoms in list." - ;; classic. - (cond ((null list) nil) - ((atom (car list)) (cons (car list) (allout-flatten (cdr list)))) - (t (append (allout-flatten (car list)) (allout-flatten (cdr list)))))) +(define-obsolete-function-alias 'allout-flatten #'flatten-tree "27.1") ;;;_ : Compatibility: ;;;_ : xemacs undo-in-progress provision: (unless (boundp 'undo-in-progress) diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el index 33957ee3269..bb88c2fe1fd 100644 --- a/lisp/org/org-protocol.el +++ b/lisp/org/org-protocol.el @@ -349,17 +349,20 @@ returned list." ret) l))) -(defun org-protocol-flatten (list) - "Transform LIST into a flat list. +(if (fboundp 'flatten-tree) + (defalias 'org-protocol-flatten 'flatten-tree) + (defun org-protocol-flatten (list) + "Transform LIST into a flat list. Greedy handlers might receive a list like this from emacsclient: \((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")) where \"/dir/\" is the absolute path to emacsclients working directory. This function transforms it into a flat list." - (if (null list) () - (if (listp list) - (append (org-protocol-flatten (car list)) (org-protocol-flatten (cdr list))) - (list list)))) + (if (null list) () + (if (listp list) + (append (org-protocol-flatten (car list)) + (org-protocol-flatten (cdr list))) + (list list))))) (defun org-protocol-parse-parameters (info &optional new-style default-order) "Return a property list of parameters from INFO. diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el index 62e8c453389..84cbb6e6d17 100644 --- a/lisp/progmodes/hideif.el +++ b/lisp/progmodes/hideif.el @@ -672,12 +672,7 @@ that form should be displayed.") result)) (nreverse result))) -(defun hif-flatten (l) - "Flatten a tree." - (apply #'nconc - (mapcar (lambda (x) (if (listp x) - (hif-flatten x) - (list x))) l))) +(define-obsolete-function-alias 'hif-flatten #'flatten-tree "27.1") (defun hif-expand-token-list (tokens &optional macroname expand_list) "Perform expansion on TOKENS till everything expanded. @@ -748,7 +743,7 @@ detecting self-reference." expanded)) - (hif-flatten (nreverse expanded))))) + (flatten-tree (nreverse expanded))))) (defun hif-parse-exp (token-list &optional macroname) "Parse the TOKEN-LIST. @@ -1166,7 +1161,7 @@ preprocessing token" (setq actual-parms (cdr actual-parms))) ;; Replacement completed, flatten the whole token list - (setq macro-body (hif-flatten macro-body)) + (setq macro-body (flatten-tree macro-body)) ;; Stringification and token concatenation happens here (hif-token-concatenation (hif-token-stringification macro-body))))) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index ddba7636b4a..11ccb5fc527 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -623,8 +623,6 @@ then the \".\"s will be lined up: "Parse state at `js--last-parse-pos'.") (make-variable-buffer-local 'js--state-at-last-parse-pos) -(define-obsolete-function-alias 'js--flatten-list #'flatten-tree "27.1") - (defun js--maybe-join (prefix separator suffix &rest list) "Helper function for `js--update-quick-match-re'. If LIST contains any element that is not nil, return its non-nil