summaryrefslogtreecommitdiff
path: root/lisp/eshell/esh-util.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2020-09-02 02:45:39 +0200
committerStefan Kangas <stefan@marxist.se>2020-09-21 20:38:56 +0200
commitfb68645b5a258c98acc11efdc3caae80683cc6b0 (patch)
treed301a59e36103264a11aa28f846ee88f7001b22e /lisp/eshell/esh-util.el
parent600d3f0669742b398d91c421e335fc6680f6fdc0 (diff)
downloademacs-fb68645b5a258c98acc11efdc3caae80683cc6b0.tar.gz
Move several completions from eshell to pcomplete (Bug#10585)
* lisp/eshell/em-unix.el (eshell-complete-hostname) (pcomplete/ftp, pcomplete/ncftp, pcomplete/ping) (pcomplete/rlogin, pcomplete/telnet, pcomplete/rsh): Move from here... * lisp/pcmpl-unix.el (pcmpl-unix-complete-hostname) (pcomplete/ftp, pcomplete/ncftp, pcomplete/ping) (pcomplete/rlogin, pcomplete/telnet, pcomplete/rsh): ...to here. Make old names into aliases. * lisp/eshell/esh-util.el (eshell-hosts-file) (eshell-host-names, eshell-host-timestamp) (eshell-read-hosts-file, eshell-read-hosts) (eshell-read-host-names): Move from here... * lisp/pcomplete.el (pcomplete-hosts-file) (pcomplete--host-name-cache) (pcomplete--host-name-cache-timestamp) (pcomplete-read-hosts-file, pcomplete-read-hosts) (pcomplete-read-host-names): ...to here. Make old names into aliases. * lisp/eshell/em-unix.el (eshell-complete-host-reference): Update caller.
Diffstat (limited to 'lisp/eshell/esh-util.el')
-rw-r--r--lisp/eshell/esh-util.el59
1 files changed, 23 insertions, 36 deletions
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index ab030ede05b..0122f9be488 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -51,9 +51,15 @@ similarly to external commands, as far as successful result output."
:group 'eshell-util)
(defcustom eshell-hosts-file "/etc/hosts"
- "The name of the /etc/hosts file."
+ "The name of the /etc/hosts file.
+Use `pcomplete-hosts-file' instead; this variable is obsolete and
+has no effect."
:type '(choice (const :tag "No hosts file" nil) file)
:group 'eshell-util)
+;; Don't make it into an alias, because it doesn't really work with
+;; custom and risks creating duplicate entries. Just point users to
+;; the other variable, which is less frustrating.
+(make-obsolete-variable 'eshell-hosts-file nil "28.1")
(defcustom eshell-handle-errors t
"If non-nil, Eshell will handle errors itself.
@@ -127,11 +133,14 @@ function `string-to-number'."
(defvar eshell-user-timestamp nil
"A timestamp of when the user file was read.")
-(defvar eshell-host-names nil
- "A cache the names of frequently accessed hosts.")
+;;; Obsolete variables:
-(defvar eshell-host-timestamp nil
- "A timestamp of when the hosts file was read.")
+(define-obsolete-variable-alias 'eshell-host-names
+ 'pcomplete--host-name-cache "28.1")
+(define-obsolete-variable-alias 'eshell-host-timestamp
+ 'pcomplete--host-name-cache-timestamp "28.1")
+(defvar pcomplete--host-name-cache)
+(defvar pcomplete--host-name-cache-timestamp)
;;; Functions:
@@ -479,37 +488,15 @@ list."
(defalias 'eshell-user-name 'user-login-name)
-(defun eshell-read-hosts-file (filename)
- "Read in the hosts from FILENAME, default `eshell-hosts-file'."
- (let (hosts)
- (with-temp-buffer
- (insert-file-contents (or filename eshell-hosts-file))
- (goto-char (point-min))
- (while (re-search-forward
- ;; "^ \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/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 (apply #'nconc (eshell-read-hosts-file file)))
- (set timestamp-var (current-time))))
- (symbol-value result-var))
-
-(defun eshell-read-host-names ()
- "Read the contents of /etc/hosts for host names."
- (if eshell-hosts-file
- (eshell-read-hosts eshell-hosts-file 'eshell-host-names
- 'eshell-host-timestamp)))
+(autoload 'pcomplete-read-hosts-file "pcomplete")
+(autoload 'pcomplete-read-hosts "pcomplete")
+(autoload 'pcomplete-read-host-names "pcomplete")
+(define-obsolete-function-alias 'eshell-read-hosts-file
+ #'pcomplete-read-hosts-file "28.1")
+(define-obsolete-function-alias 'eshell-read-hosts
+ #'pcomplete-read-hosts "28.1")
+(define-obsolete-function-alias 'eshell-read-host-names
+ #'pcomplete-read-host-names "28.1")
(defsubst eshell-copy-environment ()
"Return an unrelated copy of `process-environment'."