From a9eeff78d5bdcb9e03055376705e8f31fe145b79 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 4 Mar 2011 19:53:41 -0800 Subject: [PATCH] Make eshell-for obsolete (replaced by dolist) * eshell/esh-util.el (eshell-for): Make it obsolete. * eshell/em-alias.el (eshell/alias, eshell-alias-completions): * eshell/em-dirs.el (eshell-save-some-last-dir): * eshell/em-hist.el (eshell-save-some-history, eshell-hist-parse-modifier): * eshell/em-ls.el (eshell-ls-dir, eshell-ls-files, eshell-ls-entries): * eshell/em-unix.el (eshell/cat, eshell/du, eshell/su): * eshell/esh-cmd.el (eshell-invoke-directly, eshell-do-eval, eshell/which): * eshell/esh-ext.el (eshell-find-interpreter): * eshell/esh-mode.el (eshell-mode): * eshell/esh-module.el (eshell-unload-extension-modules): * eshell/esh-proc.el (eshell-process-interact): * eshell/esh-test.el (eshell-test): * eshell/esh-util.el (eshell-flatten-list, eshell-winnow-list): * eshell/esh-var.el (eshell/env, eshell-environment-variables) (eshell-variables-list): * eshell/eshell.el (eshell-unload-all-modules): Replace eshell-for with dolist. --- lisp/ChangeLog | 23 +++++++++++++++++++++++ lisp/eshell/em-alias.el | 4 ++-- lisp/eshell/em-dirs.el | 2 +- lisp/eshell/em-hist.el | 4 ++-- lisp/eshell/em-ls.el | 12 ++++++------ lisp/eshell/em-unix.el | 10 +++++----- lisp/eshell/esh-cmd.el | 6 +++--- lisp/eshell/esh-ext.el | 2 +- lisp/eshell/esh-mode.el | 6 +++--- lisp/eshell/esh-module.el | 2 +- lisp/eshell/esh-proc.el | 4 ++-- lisp/eshell/esh-test.el | 4 ++-- lisp/eshell/esh-util.el | 6 ++++-- lisp/eshell/esh-var.el | 7 +++---- lisp/eshell/eshell.el | 2 +- 15 files changed, 59 insertions(+), 35 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2fca345992d..9d4743107cf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,26 @@ +2011-03-05 Glenn Morris + + * eshell/esh-util.el (eshell-for): Make it obsolete. + * eshell/em-alias.el (eshell/alias, eshell-alias-completions): + * eshell/em-dirs.el (eshell-save-some-last-dir): + * eshell/em-hist.el (eshell-save-some-history) + (eshell-hist-parse-modifier): + * eshell/em-ls.el (eshell-ls-dir, eshell-ls-files) + (eshell-ls-entries): + * eshell/em-unix.el (eshell/cat, eshell/du, eshell/su): + * eshell/esh-cmd.el (eshell-invoke-directly, eshell-do-eval) + (eshell/which): + * eshell/esh-ext.el (eshell-find-interpreter): + * eshell/esh-mode.el (eshell-mode): + * eshell/esh-module.el (eshell-unload-extension-modules): + * eshell/esh-proc.el (eshell-process-interact): + * eshell/esh-test.el (eshell-test): + * eshell/esh-util.el (eshell-flatten-list, eshell-winnow-list): + * eshell/esh-var.el (eshell/env, eshell-environment-variables) + (eshell-variables-list): + * eshell/eshell.el (eshell-unload-all-modules): + Replace eshell-for with dolist. + 2011-03-04 Glenn Morris * vc/vc-bzr.el (vc-bzr-after-dir-status): Handle bzr 2.3.0. (Bug#8170) diff --git a/lisp/eshell/em-alias.el b/lisp/eshell/em-alias.el index aa138cb4dcb..9efa95fc9ab 100644 --- a/lisp/eshell/em-alias.el +++ b/lisp/eshell/em-alias.el @@ -156,7 +156,7 @@ command, which will automatically write them to the file named by (defun eshell/alias (&optional alias &rest definition) "Define an ALIAS in the user's alias list using DEFINITION." (if (not alias) - (eshell-for alias eshell-command-aliases-list + (dolist (alias eshell-command-aliases-list) (eshell-print (apply 'format "alias %s %s\n" alias))) (if (not definition) (setq eshell-command-aliases-list @@ -238,7 +238,7 @@ command, which will automatically write them to the file named by "Find all possible completions for NAME. These are all the command aliases which begin with NAME." (let (completions) - (eshell-for alias eshell-command-aliases-list + (dolist (alias eshell-command-aliases-list) (if (string-match (concat "^" name) (car alias)) (setq completions (cons (car alias) completions)))) completions)) diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 64555ab15ef..9165f69d0b1 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -233,7 +233,7 @@ Thus, this does not include the current directory.") (defun eshell-save-some-last-dir () "Save the list-dir-ring for any open Eshell buffers." - (eshell-for buf (buffer-list) + (dolist (buf (buffer-list)) (if (buffer-live-p buf) (with-current-buffer buf (if (and eshell-mode diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index 5ec529f4b8f..f9ddf3b679f 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -292,7 +292,7 @@ element, regardless of any text on the command line. In that case, (defun eshell-save-some-history () "Save the history for any open Eshell buffers." - (eshell-for buf (buffer-list) + (dolist (buf (buffer-list)) (if (buffer-live-p buf) (with-current-buffer buf (if (and eshell-mode @@ -730,7 +730,7 @@ matched." (narrow-to-region here (point)) (goto-char (point-min)) (let ((modifiers (cdr (eshell-parse-modifiers)))) - (eshell-for mod modifiers + (dolist (mod modifiers) (setq hist (funcall mod hist))) hist)) (delete-region here (point))))) diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el index 7714629f2fa..4ef259dee4b 100644 --- a/lisp/eshell/em-ls.el +++ b/lisp/eshell/em-ls.el @@ -561,7 +561,7 @@ relative to that directory." (when (or (eq listing-style 'long-listing) show-size) (let ((total 0.0)) (setq size-width 0) - (eshell-for e entries + (dolist (e entries) (if (nth 7 (cdr e)) (setq total (+ total (nth 7 (cdr e))) size-width @@ -651,7 +651,7 @@ Each member of FILES is either a string or a cons cell of the form (not (eq eshell-in-pipeline-p 'last)) (not (eq listing-style 'by-lines))) (memq listing-style '(long-listing single-column))) - (eshell-for file files + (dolist (file files) (if file (eshell-ls-file file size-width copy-fileinfo))) (let ((f files) @@ -676,7 +676,7 @@ Each member of FILES is either a string or a cons cell of the form (setcdr f (cddr f)))))) (if (not show-size) (setq display-files (mapcar 'eshell-ls-annotate files)) - (eshell-for file files + (dolist (file files) (let* ((str (eshell-ls-printable-size (nth 7 (cdr file)) t)) (len (length str))) (if (< len size-width) @@ -696,7 +696,7 @@ Each member of FILES is either a string or a cons cell of the form (columns (length col-widths)) (col-index 1) need-return) - (eshell-for file display-files + (dolist (file display-files) (let ((name (if (car file) (if show-size @@ -731,7 +731,7 @@ ROOT-DIR, if non-nil, specifies the root directory of the listing, to which non-absolute directory names will be made relative if ever they need to be printed." (let (dirs files show-names need-return (size-width 0)) - (eshell-for entry entries + (dolist (entry entries) (if (and (not dir-literal) (or (eshell-ls-filetype-p (cdr entry) ?d) (and (eshell-ls-filetype-p (cdr entry) ?l) @@ -757,7 +757,7 @@ need to be printed." (setq need-return t)) (setq show-names (or show-recursive (> (+ (length files) (length dirs)) 1))) - (eshell-for dir (eshell-ls-sort-entries dirs) + (dolist (dir (eshell-ls-sort-entries dirs)) (if (and need-return (not dir-literal)) (funcall insert-func "\n")) (eshell-ls-dir dir show-names diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el index dc5650d240e..3bb623c4c4e 100644 --- a/lisp/eshell/em-unix.el +++ b/lisp/eshell/em-unix.el @@ -587,7 +587,7 @@ symlink, then revert to the system's definition of cat." (setq args (eshell-stringify-list (eshell-flatten-list args))) (if (or eshell-in-pipeline-p (catch 'special - (eshell-for arg args + (dolist (arg args) (unless (or (and (stringp arg) (> (length arg) 0) (eq (aref arg 0) ?-)) @@ -610,12 +610,12 @@ symlink, then revert to the system's definition of cat." :show-usage :usage "[OPTION] FILE... Concatenate FILE(s), or standard input, to standard output.") - (eshell-for file args + (dolist (file args) (if (string= file "-") (throw 'eshell-external (eshell-external-command "cat" args)))) (let ((curbuf (current-buffer))) - (eshell-for file args + (dolist (file args) (with-temp-buffer (insert-file-contents file) (goto-char (point-min)) @@ -851,7 +851,7 @@ external command." (let ((ext-du (eshell-search-path "du"))) (if (and ext-du (not (catch 'have-ange-path - (eshell-for arg args + (dolist (arg args) (if (string-equal (file-remote-p (expand-file-name arg) 'method) "ftp") (throw 'have-ange-path t)))))) @@ -1055,7 +1055,7 @@ Become another USER during a login session.") "localhost")) (dir (or (file-remote-p default-directory 'localname) (expand-file-name default-directory)))) - (eshell-for arg args + (dolist (arg args) (if (string-equal arg "-") (setq login t) (setq user arg))) ;; `eshell-eval-using-options' does not handle "-". (if (member "-" orig-args) (setq login t)) diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 0567beb9a53..0a00300d19c 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -987,7 +987,7 @@ at the moment are: (not (member name eshell-complex-commands)) (catch 'simple (progn - (eshell-for pred eshell-complex-commands + (dolist (pred eshell-complex-commands) (if (and (functionp pred) (funcall pred name)) (throw 'simple nil))) @@ -1165,7 +1165,7 @@ be finished later after the completion of an asynchronous subprocess." (if (and (eq (car form) 'let) (not (eq (car (cadr args)) 'eshell-do-eval))) (eshell-manipulate "evaluating let args" - (eshell-for letarg (car args) + (dolist (letarg (car args)) (if (and (listp letarg) (not (eq (cadr letarg) 'quote))) (setcdr letarg @@ -1241,7 +1241,7 @@ be finished later after the completion of an asynchronous subprocess." (defun eshell/which (command &rest names) "Identify the COMMAND, and where it is located." - (eshell-for name (cons command names) + (dolist (name (cons command names)) (let (program alias direct) (if (eq (aref name 0) eshell-explicit-command-char) (setq name (substring name 1) diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el index 7128d7e4749..ebd20b90dd6 100644 --- a/lisp/eshell/esh-ext.el +++ b/lisp/eshell/esh-ext.el @@ -263,7 +263,7 @@ line of the form #!." (let ((finterp (catch 'found (ignore - (eshell-for possible eshell-interpreter-alist + (dolist (possible eshell-interpreter-alist) (cond ((functionp (car possible)) (and (funcall (car possible) file) diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 3735ee35fd5..3b566ead0e5 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -389,7 +389,7 @@ This is used by `eshell-watch-for-password-prompt'." ;; load extension modules into memory. This will cause any global ;; variables they define to be visible, since some of the core ;; modules sometimes take advantage of their functionality if used. - (eshell-for module eshell-modules-list + (dolist (module eshell-modules-list) (let ((module-fullname (symbol-name module)) module-shortname) (if (string-match "^eshell-\\(.*\\)" module-fullname) @@ -404,12 +404,12 @@ This is used by `eshell-watch-for-password-prompt'." (eshell-make-private-directory eshell-directory-name t)) ;; load core Eshell modules for this session - (eshell-for module (eshell-subgroups 'eshell) + (dolist (module (eshell-subgroups 'eshell)) (run-hooks (intern-soft (concat (symbol-name module) "-load-hook")))) ;; load extension modules for this session - (eshell-for module eshell-modules-list + (dolist (module eshell-modules-list) (let ((load-hook (intern-soft (concat (symbol-name module) "-load-hook")))) (if (and load-hook (boundp load-hook)) diff --git a/lisp/eshell/esh-module.el b/lisp/eshell/esh-module.el index 5a62c71355c..41f9e662a95 100644 --- a/lisp/eshell/esh-module.el +++ b/lisp/eshell/esh-module.el @@ -92,7 +92,7 @@ customization group. Example: `eshell-cmpl' for that module." (defun eshell-unload-extension-modules () "Unload any memory resident extension modules." - (eshell-for module (eshell-subgroups 'eshell-module) + (dolist (module (eshell-subgroups 'eshell-module)) (if (featurep module) (ignore-errors (message "Unloading %s..." (symbol-name module)) diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index f697a400556..8757f5d56a0 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -398,7 +398,7 @@ PROC is the process that's exiting. STRING is the exit message." If ALL is non-nil, background processes will be interacted with as well. If QUERY is non-nil, query the user with QUERY before calling FUNC." (let (defunct result) - (eshell-for entry eshell-process-list + (dolist (entry eshell-process-list) (if (and (memq (process-status (car entry)) '(run stop open closed)) (or all @@ -412,7 +412,7 @@ If QUERY is non-nil, query the user with QUERY before calling FUNC." ;; clean up the process list; this can get dirty if an error ;; occurred that brought the user into the debugger, and then they ;; quit, so that the sentinel was never called. - (eshell-for d defunct + (dolist (d defunct) (eshell-remove-process-entry d)) result)) diff --git a/lisp/eshell/esh-test.el b/lisp/eshell/esh-test.el index f5c55dd8ae7..73ba16116c0 100644 --- a/lisp/eshell/esh-test.el +++ b/lisp/eshell/esh-test.el @@ -166,9 +166,9 @@ (insert "Testing Eshell under " (emacs-version)) (switch-to-buffer test-buffer) (delete-other-windows)) - (eshell-for funcname (sort (all-completions "eshell-test--" + (dolist (funcname (sort (all-completions "eshell-test--" obarray 'functionp) - 'string-lessp) + 'string-lessp)) (with-current-buffer test-buffer (insert "\n")) (funcall (intern-soft funcname))) diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 2de147acb00..6b04b0e727b 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -296,10 +296,12 @@ Prepend remote identification of `default-directory', if any." (put 'eshell-for 'lisp-indent-function 2) +(make-obsolete 'eshell-for 'dolist "24.1") + (defun eshell-flatten-list (args) "Flatten any lists within ARGS, so that there are no sublists." (let ((new-list (list t))) - (eshell-for a args + (dolist (a args) (if (and (listp a) (listp (cdr a))) (nconc new-list (eshell-flatten-list a)) @@ -405,7 +407,7 @@ list." (unless (listp entries) (setq entries (list entries) listified t)) - (eshell-for entry entries + (dolist (entry entries) (unless (and exclude (string-match exclude entry)) (setq p predicates valid (null p)) (while p diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 4c42b305ec2..8fb08963192 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -351,8 +351,7 @@ This function is explicit for adding to `eshell-parse-argument-hook'." '((?h "help" nil nil "show this usage screen") :external "env" :usage "") - (eshell-for setting (sort (eshell-environment-variables) - 'string-lessp) + (dolist (setting (sort (eshell-environment-variables) 'string-lessp)) (eshell-buffered-print setting "\n")) (eshell-flush))) @@ -374,7 +373,7 @@ This function is explicit for adding to `eshell-parse-argument-hook'." This involves setting any variable aliases which affect the environment, as specified in `eshell-variable-aliases-list'." (let ((process-environment (eshell-copy-environment))) - (eshell-for var-alias eshell-variable-aliases-list + (dolist (var-alias eshell-variable-aliases-list) (if (nth 2 var-alias) (setenv (car var-alias) (eshell-stringify @@ -623,7 +622,7 @@ For example, to retrieve the second element of a user's record in "Generate list of applicable variables." (let ((argname pcomplete-stub) completions) - (eshell-for alias eshell-variable-aliases-list + (dolist (alias eshell-variable-aliases-list) (if (string-match (concat "^" argname) (car alias)) (setq completions (cons (car alias) completions)))) (sort diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el index 7690a102a9b..cda1eea2c55 100644 --- a/lisp/eshell/eshell.el +++ b/lisp/eshell/eshell.el @@ -474,7 +474,7 @@ Emacs." ;; if the user set `eshell-prefer-to-shell' to t, but never loaded ;; Eshell, then `eshell-subgroups' will be unbound (when (fboundp 'eshell-subgroups) - (eshell-for module (eshell-subgroups 'eshell) + (dolist (module (eshell-subgroups 'eshell)) ;; this really only unloads as many modules as possible, ;; since other `require' references (such as by customizing ;; `eshell-prefer-to-shell' to a non-nil value) might make it -- 2.11.4.GIT