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 | |
| 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.
| -rw-r--r-- | doc/misc/eshell.texi | 17 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/eshell/em-cmpl.el | 38 |
3 files changed, 27 insertions, 33 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index ce3a30c3a9e..716b4b7a50d 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi | |||
| @@ -499,15 +499,14 @@ be directories @emph{and} files. Eshell provides predefined completions | |||
| 499 | for the built-in functions and some common external commands, and you | 499 | for the built-in functions and some common external commands, and you |
| 500 | can define your own for any command. | 500 | can define your own for any command. |
| 501 | 501 | ||
| 502 | Eshell completion also works for lisp forms and glob patterns. If the | 502 | Eshell completion also works for lisp forms and glob patterns. If the point is |
| 503 | point is on a lisp form, then @key{TAB} will behave similarly to completion | 503 | on a lisp form, then @key{TAB} will behave similarly to completion in |
| 504 | in @code{elisp-mode} and @code{lisp-interaction-mode}. For glob | 504 | @code{elisp-mode} and @code{lisp-interaction-mode}. For glob patterns, the |
| 505 | patterns, If there are few enough possible completions of the patterns, | 505 | pattern will be removed from the input line, and replaced by the |
| 506 | they will be cycled when @key{TAB} is pressed, otherwise it will be removed | 506 | completion. |
| 507 | from the input line and the possible completions will be listed. | 507 | |
| 508 | 508 | If you want to see the entire list of possible completions (e.g. when it's | |
| 509 | If you want to see the entire list of possible completions when it's | 509 | below the @code{completion-cycle-threshold}), press @kbd{M-?}. |
| 510 | below the cycling threshold, press @kbd{M-?}. | ||
| 511 | 510 | ||
| 512 | @subsection pcomplete | 511 | @subsection pcomplete |
| 513 | Pcomplete, short for programmable completion, is the completion | 512 | Pcomplete, short for programmable completion, is the completion |
| @@ -985,6 +985,11 @@ default, and not just the opening element. | |||
| 985 | 985 | ||
| 986 | ** Eshell | 986 | ** Eshell |
| 987 | 987 | ||
| 988 | *** TAB completion uses the standard completion-at-point rather than pcomplete | ||
| 989 | Its UI is slightly different but can be customized to behave similarly, | ||
| 990 | e.g. Pcomplete's default cycling can be obtained with | ||
| 991 | (setq completion-cycle-threshold 5). | ||
| 992 | |||
| 988 | --- | 993 | --- |
| 989 | *** Expansion of history event designators is disabled by default. | 994 | *** Expansion of history event designators is disabled by default. |
| 990 | To restore the old behavior, use | 995 | To restore the old behavior, use |
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 | ||