diff options
| author | Jim Porter | 2023-02-24 21:49:54 -0800 |
|---|---|---|
| committer | Jim Porter | 2023-02-25 20:38:55 -0800 |
| commit | 9565e34762af6e0db51e9ae01683eb5d4c97ff3d (patch) | |
| tree | 9f9a1a3a3d0e0d3ddc86adc8bf4d8831283e35b4 /lisp/eshell | |
| parent | 2baf08683fcf4b6b1ad65a6dc239b889d78a74b2 (diff) | |
| download | emacs-9565e34762af6e0db51e9ae01683eb5d4c97ff3d.tar.gz emacs-9565e34762af6e0db51e9ae01683eb5d4c97ff3d.zip | |
Be more cautious in completing Eshell variable assignments
Previously, Eshell treated cases like the second argument in "tar
--directory=dir" as a variable assignment, but that prevented
'pcomplete/tar' from implementing its own completion for that
argument (bug#61778).
* lisp/eshell/esh-var.el (eshell-complete-variable-assignment): Only
handle completion when all initial arguments are variable assignments.
* test/lisp/eshell/em-cmpl-tests.el
(em-cmpl-test/variable-assign-completion/non-assignment): New test.
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/esh-var.el | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 0031324b537..5d6299af564 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el | |||
| @@ -862,11 +862,19 @@ START and END." | |||
| 862 | 862 | ||
| 863 | (defun eshell-complete-variable-assignment () | 863 | (defun eshell-complete-variable-assignment () |
| 864 | "If there is a variable assignment, allow completion of entries." | 864 | "If there is a variable assignment, allow completion of entries." |
| 865 | (let ((arg (pcomplete-actual-arg)) pos) | 865 | (catch 'not-assignment |
| 866 | (when (string-match (concat "\\`" eshell-variable-name-regexp "=") arg) | 866 | ;; The current argument can only be a variable assignment if all |
| 867 | (setq pos (match-end 0)) | 867 | ;; arguments leading up to it are also variable assignments. See |
| 868 | (if (string-match "\\(:\\)[^:]*\\'" arg) | 868 | ;; `eshell-handle-local-variables'. |
| 869 | (setq pos (match-end 1))) | 869 | (dotimes (offset (1+ pcomplete-index)) |
| 870 | (unless (string-match (concat "\\`" eshell-variable-name-regexp "=") | ||
| 871 | (pcomplete-actual-arg 'first offset)) | ||
| 872 | (throw 'not-assignment nil))) | ||
| 873 | ;; We have a variable assignment. Handle it. | ||
| 874 | (let ((arg (pcomplete-actual-arg)) | ||
| 875 | (pos (match-end 0))) | ||
| 876 | (when (string-match "\\(:\\)[^:]*\\'" arg) | ||
| 877 | (setq pos (match-end 1))) | ||
| 870 | (setq pcomplete-stub (substring arg pos)) | 878 | (setq pcomplete-stub (substring arg pos)) |
| 871 | (throw 'pcomplete-completions (pcomplete-entries))))) | 879 | (throw 'pcomplete-completions (pcomplete-entries))))) |
| 872 | 880 | ||