diff options
| author | Stefan Monnier | 2019-03-19 23:41:20 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-03-19 23:41:20 -0400 |
| commit | 047c1b19353ff58d8cd45935c7b44c911b70e312 (patch) | |
| tree | 372db51d9d30c1435f4d5d0d7799e45e2c9f27a4 /lisp/eshell | |
| parent | e14c0d748efe35afc653151ff18c4dd93dcc456e (diff) | |
| download | emacs-047c1b19353ff58d8cd45935c7b44c911b70e312.tar.gz emacs-047c1b19353ff58d8cd45935c7b44c911b70e312.zip | |
* lisp/eshell/em-cmpl.el: Use completion-at-point i.s.o pcomplete
(eshell-cmpl-initialize): Refrain from binding to the `tab` key,
which prevents the tab -> TAB remapping.
Use completion-at-point and completion-help-at-point.
(eshell-complete-commands-list): Use `fboundp` test instead of ugly
gymnastics to try and hide the function call from the compiler.
(eshell-pcomplete): Make it an alias of completion-at-point.
* doc/misc/eshell.texi (Completion): Change wording to reflect
different default behavior.
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/em-cmpl.el | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index cd5c14afbe6..25a6e88c8e6 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el | |||
| @@ -288,9 +288,10 @@ to writing a completion function." | |||
| 288 | (function | 288 | (function |
| 289 | (lambda () | 289 | (lambda () |
| 290 | (set (make-local-variable 'comint-file-name-quote-list) | 290 | (set (make-local-variable 'comint-file-name-quote-list) |
| 291 | eshell-special-chars-outside-quoting))) nil t) | 291 | eshell-special-chars-outside-quoting))) |
| 292 | (add-hook 'pcomplete-quote-arg-hook 'eshell-quote-backslash nil t) | 292 | nil t) |
| 293 | (define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) | 293 | (add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t) |
| 294 | ;;(define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) ; Redundant | ||
| 294 | (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol) | 295 | (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol) |
| 295 | (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help) | 296 | (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help) |
| 296 | (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete) | 297 | (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete) |
| @@ -298,15 +299,14 @@ to writing a completion function." | |||
| 298 | 'pcomplete-expand-and-complete) | 299 | 'pcomplete-expand-and-complete) |
| 299 | (define-key eshell-command-map [space] 'pcomplete-expand) | 300 | (define-key eshell-command-map [space] 'pcomplete-expand) |
| 300 | (define-key eshell-command-map [? ] 'pcomplete-expand) | 301 | (define-key eshell-command-map [? ] 'pcomplete-expand) |
| 301 | (define-key eshell-mode-map [tab] 'eshell-pcomplete) | 302 | ;;(define-key eshell-mode-map [tab] 'completion-at-point) ;Redundant! |
| 302 | (define-key eshell-mode-map [(control ?i)] 'eshell-pcomplete) | 303 | (define-key eshell-mode-map [(control ?i)] 'completion-at-point) |
| 303 | (add-hook 'completion-at-point-functions | 304 | (add-hook 'completion-at-point-functions |
| 304 | #'pcomplete-completions-at-point nil t) | 305 | #'pcomplete-completions-at-point nil t) |
| 305 | ;; jww (1999-10-19): Will this work on anything but X? | 306 | ;; jww (1999-10-19): Will this work on anything but X? |
| 306 | (if (featurep 'xemacs) | 307 | (define-key eshell-mode-map |
| 307 | (define-key eshell-mode-map [iso-left-tab] 'pcomplete-reverse) | 308 | (if (featurep 'xemacs) [iso-left-tab] [backtab]) 'pcomplete-reverse) |
| 308 | (define-key eshell-mode-map [backtab] 'pcomplete-reverse)) | 309 | (define-key eshell-mode-map [(meta ??)] 'completion-help-at-point)) |
| 309 | (define-key eshell-mode-map [(meta ??)] 'pcomplete-list)) | ||
| 310 | 310 | ||
| 311 | (defun eshell-completion-command-name () | 311 | (defun eshell-completion-command-name () |
| 312 | "Return the command name, possibly sans globbing." | 312 | "Return the command name, possibly sans globbing." |
| @@ -442,34 +442,24 @@ to writing a completion function." | |||
| 442 | (if glob-name | 442 | (if glob-name |
| 443 | completions | 443 | completions |
| 444 | (setq completions | 444 | (setq completions |
| 445 | (append (and (eshell-using-module 'eshell-alias) | 445 | (append (if (fboundp 'eshell-alias-completions) |
| 446 | (funcall (symbol-function 'eshell-alias-completions) | 446 | (eshell-alias-completions filename)) |
| 447 | filename)) | ||
| 448 | (eshell-winnow-list | 447 | (eshell-winnow-list |
| 449 | (mapcar | 448 | (mapcar |
| 450 | (function | 449 | (function |
| 451 | (lambda (name) | 450 | (lambda (name) |
| 452 | (substring name 7))) | 451 | (substring name 7))) |
| 453 | (all-completions (concat "eshell/" filename) | 452 | (all-completions (concat "eshell/" filename) |
| 454 | obarray 'functionp)) | 453 | obarray #'functionp)) |
| 455 | nil '(eshell-find-alias-function)) | 454 | nil '(eshell-find-alias-function)) |
| 456 | completions)) | 455 | completions)) |
| 457 | (append (and (or eshell-show-lisp-completions | 456 | (append (and (or eshell-show-lisp-completions |
| 458 | (and eshell-show-lisp-alternatives | 457 | (and eshell-show-lisp-alternatives |
| 459 | (null completions))) | 458 | (null completions))) |
| 460 | (all-completions filename obarray 'functionp)) | 459 | (all-completions filename obarray #'functionp)) |
| 461 | completions))))))) | 460 | completions))))))) |
| 462 | 461 | ||
| 463 | (defun eshell-pcomplete (&optional interactively) | 462 | (define-obsolete-function-alias 'eshell-pcomplete #'completion-at-point "27.1") |
| 464 | "Eshell wrapper for `pcomplete'." | ||
| 465 | (interactive "p") | ||
| 466 | ;; Pretend to be pcomplete so that cycling works (bug#13293). | ||
| 467 | (setq this-command 'pcomplete) | ||
| 468 | (condition-case nil | ||
| 469 | (if interactively | ||
| 470 | (call-interactively 'pcomplete) | ||
| 471 | (pcomplete)) | ||
| 472 | (text-read-only (completion-at-point)))) ; Workaround for bug#12838. | ||
| 473 | 463 | ||
| 474 | (provide 'em-cmpl) | 464 | (provide 'em-cmpl) |
| 475 | 465 | ||