From a017927c9ff627a0adf19ac3720bf6b2e77e5da5 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 9 Apr 2019 14:57:29 -0400 Subject: Fix up Eshell 'require's after previous dependency reshuffle. * lisp/eshell/em-unix.el: * lisp/eshell/em-script.el: * lisp/eshell/em-pred.el: * lisp/eshell/em-dirs.el: * lisp/eshell/em-alias.el: Fix up 'require's to silence byte-compiler. * lisp/eshell/esh-util.el (eshell-read-hosts-file): Don't limit number of entries per line. Preserve the structure. (eshell-read-hosts): Adjust accordingly. --- lisp/eshell/em-alias.el | 8 ++++---- lisp/eshell/em-banner.el | 2 +- lisp/eshell/em-cmpl.el | 2 +- lisp/eshell/em-dirs.el | 11 +++-------- lisp/eshell/em-glob.el | 2 +- lisp/eshell/em-hist.el | 2 +- lisp/eshell/em-pred.el | 8 +++----- lisp/eshell/em-prompt.el | 2 +- lisp/eshell/em-rebind.el | 2 +- lisp/eshell/em-script.el | 10 +++++----- lisp/eshell/em-smart.el | 2 +- lisp/eshell/em-term.el | 2 +- lisp/eshell/em-tramp.el | 2 +- lisp/eshell/em-unix.el | 5 ++--- lisp/eshell/esh-arg.el | 2 +- lisp/eshell/esh-cmd.el | 2 +- lisp/eshell/esh-ext.el | 2 +- lisp/eshell/esh-io.el | 2 +- lisp/eshell/esh-mode.el | 2 +- lisp/eshell/esh-proc.el | 2 +- lisp/eshell/esh-util.el | 18 ++++++++---------- lisp/eshell/esh-var.el | 2 +- 22 files changed, 41 insertions(+), 51 deletions(-) diff --git a/lisp/eshell/em-alias.el b/lisp/eshell/em-alias.el index dbffd52aa76..c465d464d6a 100644 --- a/lisp/eshell/em-alias.el +++ b/lisp/eshell/em-alias.el @@ -90,7 +90,7 @@ ;;; Code: -(require 'eshell) +(require 'esh-mode) ;;;###autoload (progn @@ -141,12 +141,12 @@ file named by `eshell-aliases-file'.") (defvar eshell-failed-commands-alist nil "An alist of command name failures.") -(defun eshell-alias-initialize () +(defun eshell-alias-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the alias handling code." (make-local-variable 'eshell-failed-commands-alist) - (add-hook 'eshell-alternate-command-hook 'eshell-fix-bad-commands t t) + (add-hook 'eshell-alternate-command-hook #'eshell-fix-bad-commands t t) (eshell-read-aliases-list) - (add-hook 'eshell-named-command-hook 'eshell-maybe-replace-by-alias t t) + (add-hook 'eshell-named-command-hook #'eshell-maybe-replace-by-alias t t) (make-local-variable 'eshell-complex-commands) (add-to-list 'eshell-complex-commands 'eshell-command-aliased-p)) diff --git a/lisp/eshell/em-banner.el b/lisp/eshell/em-banner.el index 4a0b265ae0e..c284c1bd70d 100644 --- a/lisp/eshell/em-banner.el +++ b/lisp/eshell/em-banner.el @@ -71,7 +71,7 @@ This can be any sexp, and should end with at least two newlines." :type 'hook :group 'eshell-banner) -(defun eshell-banner-initialize () +(defun eshell-banner-initialize () ;Called from `eshell-mode' via intern-soft! "Output a welcome banner on initialization." ;; it's important to use `eshell-interactive-print' rather than ;; `insert', because `insert' doesn't know how to interact with the diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 25a6e88c8e6..e3bfd8d9d48 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -244,7 +244,7 @@ to writing a completion function." (let ((completion-at-point-functions '(lisp-completion-at-point))) (completion-at-point))) -(defun eshell-cmpl-initialize () +(defun eshell-cmpl-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the completions module." (set (make-local-variable 'pcomplete-command-completion-function) eshell-command-completion-function) diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 93b10b59948..c28fd72f45c 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -42,15 +42,11 @@ ;;; Code: -(require 'eshell) +(require 'esh-mode) ;For eshell-directory-name +(require 'esh-var) ;For eshell-variable-aliases-list (require 'ring) (require 'esh-opt) -(declare-function eshell-apply-indices "esh-var") -(defvar eshell-variable-aliases-list) -(defvar eshell-directory-name) -(defvar eshell-mode) - ;;;###autoload (progn (defgroup eshell-dirs nil @@ -174,9 +170,8 @@ Thus, this does not include the current directory.") ;;; Functions: -(defun eshell-dirs-initialize () +(defun eshell-dirs-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the builtin functions for Eshell." - (require 'esh-var) (make-local-variable 'eshell-variable-aliases-list) (setq eshell-variable-aliases-list (append diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el index f03243a6af4..99c52ea0d30 100644 --- a/lisp/eshell/em-glob.el +++ b/lisp/eshell/em-glob.el @@ -125,7 +125,7 @@ This option slows down recursive glob processing by quite a bit." ;;; Functions: -(defun eshell-glob-initialize () +(defun eshell-glob-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the extended globbing code." ;; it's important that `eshell-glob-chars-list' come first (when (boundp 'eshell-special-chars-outside-quoting) diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index bc0da96c588..614faaa131e 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -216,7 +216,7 @@ Returns non-nil if INPUT is blank." Returns nil if INPUT is prepended by blank space, otherwise non-nil." (not (string-match-p "\\`\\s-+" input))) -(defun eshell-hist-initialize () +(defun eshell-hist-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the history management code for one Eshell buffer." (when (eshell-using-module 'eshell-cmpl) (add-hook 'pcomplete-try-first-hook diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index dd3351b14d3..9bc856a2966 100644 --- a/lisp/eshell/em-pred.el +++ b/lisp/eshell/em-pred.el @@ -46,9 +46,7 @@ ;;; Code: -(require 'esh-util) -(require 'esh-arg) -(eval-when-compile (require 'eshell)) +(require 'esh-mode) ;;;###autoload (progn @@ -247,10 +245,10 @@ EXAMPLES: (lambda () (insert eshell-modifier-help-string))))) -(defun eshell-pred-initialize () +(defun eshell-pred-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the predicate/modifier code." (add-hook 'eshell-parse-argument-hook - 'eshell-parse-arg-modifier t t) + #'eshell-parse-arg-modifier t t) (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help) (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help)) diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index a3035205adb..adc68b6c856 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -99,7 +99,7 @@ arriving, or after." ;;; Functions: -(defun eshell-prompt-initialize () +(defun eshell-prompt-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the prompting code." (unless eshell-non-interactive-p (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t) diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el index 9cb16174f20..a817edbcc99 100644 --- a/lisp/eshell/em-rebind.el +++ b/lisp/eshell/em-rebind.el @@ -145,7 +145,7 @@ This is default behavior of shells like bash." ;;; Functions: -(defun eshell-rebind-initialize () +(defun eshell-rebind-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the inputting code." (unless eshell-non-interactive-p (add-hook 'eshell-mode-hook 'eshell-setup-input-keymap nil t) diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el index bab26222baf..4a3b84e10e3 100644 --- a/lisp/eshell/em-script.el +++ b/lisp/eshell/em-script.el @@ -23,8 +23,7 @@ ;;; Code: -(require 'eshell) -(require 'esh-opt) +(require 'esh-mode) ;;;###autoload (progn @@ -57,7 +56,7 @@ This includes when running `eshell-command'." ;;; Functions: -(defun eshell-script-initialize () +(defun eshell-script-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the script parsing code." (make-local-variable 'eshell-interpreter-alist) (setq eshell-interpreter-alist @@ -73,13 +72,14 @@ This includes when running `eshell-command'." ;; to ruin it for other modules (let (eshell-inside-quote-regexp eshell-outside-quote-regexp) - (and (not eshell-non-interactive-p) + (and (not (bound-and-true-p eshell-non-interactive-p)) eshell-login-script (file-readable-p eshell-login-script) (eshell-do-eval (list 'eshell-commands (catch 'eshell-replace-command - (eshell-source-file eshell-login-script))) t)) + (eshell-source-file eshell-login-script))) + t)) (and eshell-rc-script (file-readable-p eshell-rc-script) (eshell-do-eval diff --git a/lisp/eshell/em-smart.el b/lisp/eshell/em-smart.el index 420f8850504..c7965b4187c 100644 --- a/lisp/eshell/em-smart.el +++ b/lisp/eshell/em-smart.el @@ -166,7 +166,7 @@ The options are `begin', `after' or `end'." ;;; Functions: -(defun eshell-smart-initialize () +(defun eshell-smart-initialize () ;Called from `eshell-mode' via intern-soft! "Setup Eshell smart display." (unless eshell-non-interactive-p ;; override a few variables, since they would interfere with the diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el index 9a9f23cddd9..dea90405ad7 100644 --- a/lisp/eshell/em-term.el +++ b/lisp/eshell/em-term.el @@ -147,7 +147,7 @@ behavior for short-lived processes, see bug#18108." ;;; Functions: -(defun eshell-term-initialize () +(defun eshell-term-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the `term' interface code." (make-local-variable 'eshell-interpreter-alist) (setq eshell-interpreter-alist diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el index 603b7627d5d..c7916360ee6 100644 --- a/lisp/eshell/em-tramp.el +++ b/lisp/eshell/em-tramp.el @@ -46,7 +46,7 @@ :tag "TRAMP Eshell features" :group 'eshell-module)) -(defun eshell-tramp-initialize () +(defun eshell-tramp-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the TRAMP-using commands code." (when (eshell-using-module 'eshell-cmpl) (add-hook 'pcomplete-try-first-hook diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el index e4c4265d702..25221817218 100644 --- a/lisp/eshell/em-unix.el +++ b/lisp/eshell/em-unix.el @@ -35,8 +35,7 @@ ;;; Code: -(require 'eshell) -(require 'esh-opt) +(require 'esh-mode) (require 'pcomplete) ;;;###autoload @@ -140,7 +139,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine." ;;; Functions: -(defun eshell-unix-initialize () +(defun eshell-unix-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the UNIX support/emulation code." (when (eshell-using-module 'eshell-cmpl) (add-hook 'pcomplete-try-first-hook diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index 3ba4c935a72..026edc59808 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el @@ -157,7 +157,7 @@ treated as a literal character." ;;; Functions: -(defun eshell-arg-initialize () +(defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the argument parsing code." ;; This is supposedly run after enabling esh-mode, when eshell-mode-map ;; already exists. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 7b05cfbc341..6e03bda22b7 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -287,7 +287,7 @@ otherwise t.") "Return currently running command process, if non-Lisp." eshell-last-async-proc) -(defun eshell-cmd-initialize () +(defun eshell-cmd-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the Eshell command processing module." (set (make-local-variable 'eshell-current-command) nil) (set (make-local-variable 'eshell-command-name) nil) diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el index ae8bf846249..978fc55c4de 100644 --- a/lisp/eshell/esh-ext.el +++ b/lisp/eshell/esh-ext.el @@ -172,7 +172,7 @@ external version." ;;; Functions: -(defun eshell-ext-initialize () +(defun eshell-ext-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the external command handling code." (add-hook 'eshell-named-command-hook #'eshell-explicit-command nil t)) diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 1a6c71eda03..ce1d021384d 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -169,7 +169,7 @@ not be added to this variable." ;;; Functions: -(defun eshell-io-initialize () +(defun eshell-io-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the I/O subsystem code." (add-hook 'eshell-parse-argument-hook 'eshell-parse-redirection nil t) diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 1f86dacd96c..cff29bed1b6 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -412,7 +412,7 @@ and the hook `eshell-exit-hook'." (when (and load-hook (boundp load-hook)) (if (memq initfunc (symbol-value load-hook)) (setq initfunc nil)) (run-hooks load-hook)) - ;; So we don't need the -initialize functions on the hooks (b#5375). + ;; So we don't need the -initialize functions on the hooks (bug#5375). (and initfunc (fboundp initfunc) (funcall initfunc)))) (if eshell-send-direct-to-subprocesses diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index d9a6eef7169..d538ae32b37 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -121,7 +121,7 @@ PROC and STATUS to functions on the latter." (eshell-reset-after-proc status) (run-hook-with-args 'eshell-kill-hook proc status)) -(defun eshell-proc-initialize () +(defun eshell-proc-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the process handling code." (make-local-variable 'eshell-process-list) ;; This is supposedly run after enabling esh-mode, when eshell-command-map diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 118978e77d0..6f355c70a42 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -478,24 +478,22 @@ list." (insert-file-contents (or filename eshell-hosts-file)) (goto-char (point-min)) (while (re-search-forward - "^\\([^#[:space:]]+\\)\\s-+\\(\\S-+\\)\\(\\s-*\\(\\S-+\\)\\)?" nil t) - (if (match-string 1) - (cl-pushnew (match-string 1) hosts :test #'equal)) - (if (match-string 2) - (cl-pushnew (match-string 2) hosts :test #'equal)) - (if (match-string 4) - (cl-pushnew (match-string 4) hosts :test #'equal)))) - (sort hosts #'string-lessp))) + ;; "^ \t\\([^# \t\n]+\\)[ \t]+\\([^ \t\n]+\\)\\([ \t]*\\([^ \t\n]+\\)\\)?" + "^[ \t]*\\([^# \t\n]+\\)[ \t]+\\([^ \t\n].+\\)" nil t) + (push (cons (match-string 1) + (split-string (match-string 2))) + hosts))) + (nreverse hosts))) (defun eshell-read-hosts (file result-var timestamp-var) - "Read the contents of /etc/passwd for user names." + "Read the contents of /etc/hosts for host names." (if (or (not (symbol-value result-var)) (not (symbol-value timestamp-var)) (time-less-p (symbol-value timestamp-var) (file-attribute-modification-time (file-attributes file)))) (progn - (set result-var (eshell-read-hosts-file file)) + (set result-var (apply #'nconc (eshell-read-hosts-file file))) (set timestamp-var (current-time)))) (symbol-value result-var)) diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 82e0f7135ba..b08a5d242fe 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -199,7 +199,7 @@ function), and the arguments passed to this function would be the list ;;; Functions: -(defun eshell-var-initialize () +(defun eshell-var-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the variable handle code." ;; Break the association with our parent's environment. Otherwise, ;; changing a variable will affect all of Emacs. -- cgit v1.2.1