aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-01-31 22:39:45 -0500
committerStefan Monnier2021-01-31 22:39:45 -0500
commita5438ee11ad052e71334dcfb2db51fb9123411e5 (patch)
tree1476a3ac5ddf1630440f6dbe5114a576d33c13c2
parent82c76e3aeb2465d1d1e66eae5db13ba53e38ed84 (diff)
downloademacs-a5438ee11ad052e71334dcfb2db51fb9123411e5.tar.gz
emacs-a5438ee11ad052e71334dcfb2db51fb9123411e5.zip
* lisp/eshell/em-cmpl.el (eshell--complete-commands-list): Fix last fix
Complete `*firef` to `*firefox` rather than to `firefox`.
-rw-r--r--lisp/eshell/em-cmpl.el95
1 files changed, 37 insertions, 58 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index e0b3ab1ecf4..638c0ac230a 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -91,27 +91,23 @@ variable names, arguments, etc."
91(defcustom eshell-cmpl-load-hook nil 91(defcustom eshell-cmpl-load-hook nil
92 "A list of functions to run when `eshell-cmpl' is loaded." 92 "A list of functions to run when `eshell-cmpl' is loaded."
93 :version "24.1" ; removed eshell-cmpl-initialize 93 :version "24.1" ; removed eshell-cmpl-initialize
94 :type 'hook 94 :type 'hook)
95 :group 'eshell-cmpl)
96 95
97(defcustom eshell-show-lisp-completions nil 96(defcustom eshell-show-lisp-completions nil
98 "If non-nil, include Lisp functions in the command completion list. 97 "If non-nil, include Lisp functions in the command completion list.
99If this variable is nil, Lisp completion can still be done in command 98If this variable is nil, Lisp completion can still be done in command
100position by using M-TAB instead of TAB." 99position by using M-TAB instead of TAB."
101 :type 'boolean 100 :type 'boolean)
102 :group 'eshell-cmpl)
103 101
104(defcustom eshell-show-lisp-alternatives t 102(defcustom eshell-show-lisp-alternatives t
105 "If non-nil, and no other completions found, show Lisp functions. 103 "If non-nil, and no other completions found, show Lisp functions.
106Setting this variable means nothing if `eshell-show-lisp-completions' 104Setting this variable means nothing if `eshell-show-lisp-completions'
107is non-nil." 105is non-nil."
108 :type 'boolean 106 :type 'boolean)
109 :group 'eshell-cmpl)
110 107
111(defcustom eshell-no-completion-during-jobs t 108(defcustom eshell-no-completion-during-jobs t
112 "If non-nil, don't allow completion while a process is running." 109 "If non-nil, don't allow completion while a process is running."
113 :type 'boolean 110 :type 'boolean)
114 :group 'eshell-cmpl)
115 111
116(defcustom eshell-command-completions-alist 112(defcustom eshell-command-completions-alist
117 '(("acroread" . "\\.pdf\\'") 113 '(("acroread" . "\\.pdf\\'")
@@ -136,8 +132,7 @@ is non-nil."
136 "An alist that defines simple argument type correlations. 132 "An alist that defines simple argument type correlations.
137This is provided for common commands, as a simplistic alternative 133This is provided for common commands, as a simplistic alternative
138to writing a completion function." 134to writing a completion function."
139 :type '(repeat (cons string regexp)) 135 :type '(repeat (cons string regexp)))
140 :group 'eshell-cmpl)
141 136
142(defun eshell-cmpl--custom-variable-docstring (pcomplete-var) 137(defun eshell-cmpl--custom-variable-docstring (pcomplete-var)
143 "Generate the docstring of a variable derived from a pcomplete-* variable." 138 "Generate the docstring of a variable derived from a pcomplete-* variable."
@@ -148,23 +143,19 @@ to writing a completion function."
148 143
149(defcustom eshell-cmpl-file-ignore "~\\'" 144(defcustom eshell-cmpl-file-ignore "~\\'"
150 (eshell-cmpl--custom-variable-docstring 'pcomplete-file-ignore) 145 (eshell-cmpl--custom-variable-docstring 'pcomplete-file-ignore)
151 :type (get 'pcomplete-file-ignore 'custom-type) 146 :type (get 'pcomplete-file-ignore 'custom-type))
152 :group 'eshell-cmpl)
153 147
154(defcustom eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\)/\\'" 148(defcustom eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\)/\\'"
155 (eshell-cmpl--custom-variable-docstring 'pcomplete-dir-ignore) 149 (eshell-cmpl--custom-variable-docstring 'pcomplete-dir-ignore)
156 :type (get 'pcomplete-dir-ignore 'custom-type) 150 :type (get 'pcomplete-dir-ignore 'custom-type))
157 :group 'eshell-cmpl)
158 151
159(defcustom eshell-cmpl-ignore-case (eshell-under-windows-p) 152(defcustom eshell-cmpl-ignore-case (eshell-under-windows-p)
160 (eshell-cmpl--custom-variable-docstring 'pcomplete-ignore-case) 153 (eshell-cmpl--custom-variable-docstring 'pcomplete-ignore-case)
161 :type (get 'pcomplete-ignore-case 'custom-type) 154 :type (get 'pcomplete-ignore-case 'custom-type))
162 :group 'eshell-cmpl)
163 155
164(defcustom eshell-cmpl-autolist nil 156(defcustom eshell-cmpl-autolist nil
165 (eshell-cmpl--custom-variable-docstring 'pcomplete-autolist) 157 (eshell-cmpl--custom-variable-docstring 'pcomplete-autolist)
166 :type (get 'pcomplete-autolist 'custom-type) 158 :type (get 'pcomplete-autolist 'custom-type))
167 :group 'eshell-cmpl)
168 159
169(defcustom eshell-cmpl-suffix-list (list ?/ ?:) 160(defcustom eshell-cmpl-suffix-list (list ?/ ?:)
170 (eshell-cmpl--custom-variable-docstring 'pcomplete-suffix-list) 161 (eshell-cmpl--custom-variable-docstring 'pcomplete-suffix-list)
@@ -176,51 +167,42 @@ to writing a completion function."
176 167
177(defcustom eshell-cmpl-recexact nil 168(defcustom eshell-cmpl-recexact nil
178 (eshell-cmpl--custom-variable-docstring 'pcomplete-recexact) 169 (eshell-cmpl--custom-variable-docstring 'pcomplete-recexact)
179 :type (get 'pcomplete-recexact 'custom-type) 170 :type (get 'pcomplete-recexact 'custom-type))
180 :group 'eshell-cmpl)
181 171
182(defcustom eshell-cmpl-man-function 'man 172(defcustom eshell-cmpl-man-function #'man
183 (eshell-cmpl--custom-variable-docstring 'pcomplete-man-function) 173 (eshell-cmpl--custom-variable-docstring 'pcomplete-man-function)
184 :type (get 'pcomplete-man-function 'custom-type) 174 :type (get 'pcomplete-man-function 'custom-type))
185 :group 'eshell-cmpl)
186 175
187(defcustom eshell-cmpl-compare-entry-function 'file-newer-than-file-p 176(defcustom eshell-cmpl-compare-entry-function #'file-newer-than-file-p
188 (eshell-cmpl--custom-variable-docstring 'pcomplete-compare-entry-function) 177 (eshell-cmpl--custom-variable-docstring 'pcomplete-compare-entry-function)
189 :type (get 'pcomplete-compare-entry-function 'custom-type) 178 :type (get 'pcomplete-compare-entry-function 'custom-type))
190 :group 'eshell-cmpl)
191 179
192(defcustom eshell-cmpl-expand-before-complete nil 180(defcustom eshell-cmpl-expand-before-complete nil
193 (eshell-cmpl--custom-variable-docstring 'pcomplete-expand-before-complete) 181 (eshell-cmpl--custom-variable-docstring 'pcomplete-expand-before-complete)
194 :type (get 'pcomplete-expand-before-complete 'custom-type) 182 :type (get 'pcomplete-expand-before-complete 'custom-type))
195 :group 'eshell-cmpl)
196 183
197(defcustom eshell-cmpl-cycle-completions t 184(defcustom eshell-cmpl-cycle-completions t
198 (eshell-cmpl--custom-variable-docstring 'pcomplete-cycle-completions) 185 (eshell-cmpl--custom-variable-docstring 'pcomplete-cycle-completions)
199 :type (get 'pcomplete-cycle-completions 'custom-type) 186 :type (get 'pcomplete-cycle-completions 'custom-type))
200 :group 'eshell-cmpl)
201 187
202(defcustom eshell-cmpl-cycle-cutoff-length 5 188(defcustom eshell-cmpl-cycle-cutoff-length 5
203 (eshell-cmpl--custom-variable-docstring 'pcomplete-cycle-cutoff-length) 189 (eshell-cmpl--custom-variable-docstring 'pcomplete-cycle-cutoff-length)
204 :type (get 'pcomplete-cycle-cutoff-length 'custom-type) 190 :type (get 'pcomplete-cycle-cutoff-length 'custom-type))
205 :group 'eshell-cmpl)
206 191
207(defcustom eshell-cmpl-restore-window-delay 1 192(defcustom eshell-cmpl-restore-window-delay 1
208 (eshell-cmpl--custom-variable-docstring 'pcomplete-restore-window-delay) 193 (eshell-cmpl--custom-variable-docstring 'pcomplete-restore-window-delay)
209 :type (get 'pcomplete-restore-window-delay 'custom-type) 194 :type (get 'pcomplete-restore-window-delay 'custom-type))
210 :group 'eshell-cmpl)
211 195
212(defcustom eshell-command-completion-function 196(defcustom eshell-command-completion-function
213 (lambda () 197 (lambda ()
214 (pcomplete-here (eshell--complete-commands-list))) 198 (pcomplete-here (eshell--complete-commands-list)))
215 (eshell-cmpl--custom-variable-docstring 'pcomplete-command-completion-function) 199 (eshell-cmpl--custom-variable-docstring 'pcomplete-command-completion-function)
216 :type (get 'pcomplete-command-completion-function 'custom-type) 200 :type (get 'pcomplete-command-completion-function 'custom-type))
217 :group 'eshell-cmpl)
218 201
219(defcustom eshell-cmpl-command-name-function 202(defcustom eshell-cmpl-command-name-function
220 'eshell-completion-command-name 203 #'eshell-completion-command-name
221 (eshell-cmpl--custom-variable-docstring 'pcomplete-command-name-function) 204 (eshell-cmpl--custom-variable-docstring 'pcomplete-command-name-function)
222 :type (get 'pcomplete-command-name-function 'custom-type) 205 :type (get 'pcomplete-command-name-function 'custom-type))
223 :group 'eshell-cmpl)
224 206
225(defcustom eshell-default-completion-function 207(defcustom eshell-default-completion-function
226 (lambda () 208 (lambda ()
@@ -229,13 +211,11 @@ to writing a completion function."
229 (cdr (assoc (funcall eshell-cmpl-command-name-function) 211 (cdr (assoc (funcall eshell-cmpl-command-name-function)
230 eshell-command-completions-alist)))))) 212 eshell-command-completions-alist))))))
231 (eshell-cmpl--custom-variable-docstring 'pcomplete-default-completion-function) 213 (eshell-cmpl--custom-variable-docstring 'pcomplete-default-completion-function)
232 :type (get 'pcomplete-default-completion-function 'custom-type) 214 :type (get 'pcomplete-default-completion-function 'custom-type))
233 :group 'eshell-cmpl)
234 215
235(defcustom eshell-cmpl-use-paring t 216(defcustom eshell-cmpl-use-paring t
236 (eshell-cmpl--custom-variable-docstring 'pcomplete-use-paring) 217 (eshell-cmpl--custom-variable-docstring 'pcomplete-use-paring)
237 :type (get 'pcomplete-use-paring 'custom-type) 218 :type (get 'pcomplete-use-paring 'custom-type))
238 :group 'eshell-cmpl)
239 219
240;;; Functions: 220;;; Functions:
241 221
@@ -274,7 +254,7 @@ to writing a completion function."
274 (setq-local pcomplete-default-completion-function 254 (setq-local pcomplete-default-completion-function
275 eshell-default-completion-function) 255 eshell-default-completion-function)
276 (setq-local pcomplete-parse-arguments-function 256 (setq-local pcomplete-parse-arguments-function
277 'eshell-complete-parse-arguments) 257 #'eshell-complete-parse-arguments)
278 (setq-local pcomplete-file-ignore 258 (setq-local pcomplete-file-ignore
279 eshell-cmpl-file-ignore) 259 eshell-cmpl-file-ignore)
280 (setq-local pcomplete-dir-ignore 260 (setq-local pcomplete-dir-ignore
@@ -407,20 +387,19 @@ to writing a completion function."
407 "Generate list of applicable, visible commands." 387 "Generate list of applicable, visible commands."
408 ;; Building the commands list can take quite a while, especially over Tramp 388 ;; Building the commands list can take quite a while, especially over Tramp
409 ;; (bug#41423), so do it lazily. 389 ;; (bug#41423), so do it lazily.
410 (completion-table-dynamic 390 (let ((glob-name
411 (lambda (filename) 391 ;; When a command is specified using `eshell-explicit-command-char',
412 (if (file-name-directory filename) 392 ;; that char is not part of the command and hence not part of what
413 (if eshell-force-execution 393 ;; we complete. Adjust `pcomplete-stub' accordingly!
414 (pcomplete-dirs-or-entries nil #'file-readable-p) 394 (if (and (> (length pcomplete-stub) 0)
415 (pcomplete-executables)) 395 (eq (aref pcomplete-stub 0) eshell-explicit-command-char))
416 (let (glob-name) 396 (setq pcomplete-stub (substring pcomplete-stub 1)))))
417 (if (and (> (length filename) 0) 397 (completion-table-dynamic
418 (eq (aref filename 0) eshell-explicit-command-char)) 398 (lambda (filename)
419 ;; FIXME: Shouldn't we handle this `*' outside of the 399 (if (file-name-directory filename)
420 ;; `pcomplete-here' in `eshell-command-completion-function'? 400 (if eshell-force-execution
421 (setq filename (substring filename 1) 401 (pcomplete-dirs-or-entries nil #'file-readable-p)
422 pcomplete-stub filename 402 (pcomplete-executables))
423 glob-name t))
424 (let* ((paths (eshell-get-path)) 403 (let* ((paths (eshell-get-path))
425 (cwd (file-name-as-directory 404 (cwd (file-name-as-directory
426 (expand-file-name default-directory))) 405 (expand-file-name default-directory)))