diff options
| author | Dima Kogan | 2016-12-25 11:49:44 -0800 |
|---|---|---|
| committer | Dima Kogan | 2018-06-17 22:59:21 -0700 |
| commit | ba2ddadb5378351e8003c8e172b52bfabaa27554 (patch) | |
| tree | 8c62c3f64a6af263bddb6777ab3fa2fb71ca1a26 | |
| parent | 74f377b3955198d6f66afa34bbbf6d004aad134a (diff) | |
| download | emacs-ba2ddadb5378351e8003c8e172b52bfabaa27554.tar.gz emacs-ba2ddadb5378351e8003c8e172b52bfabaa27554.zip | |
comint-insert-previous-argument doesn't detect and ignore trailing &
This function is invoked in shell-mode by the user, and is meant to
emulate what M-. does in zsh and bash: it inserts an argument from a
previous command. Neither zsh nor bash treat a trailing & specially:
M-. simply inserts it if it is encountered. Emacs DID have extra
logic to detect and discard trailing &, but this logic was buggy, and
a && anywhere in the sequence would confuse it. This patch simply
removes that logic to fix the bug and to emulate zsh and bash more
closely
* lisp/comint.el (comint-insert-previous-argument): don't detect and
ignore trailing &
(Bug#25271)
* etc/NEWS: Document this.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/comint.el | 3 |
2 files changed, 5 insertions, 3 deletions
| @@ -191,6 +191,11 @@ It now treats the optional 2nd argument to mean that the URL should be | |||
| 191 | shown in the currently selected window. | 191 | shown in the currently selected window. |
| 192 | 192 | ||
| 193 | ** Comint | 193 | ** Comint |
| 194 | *** 'comint-insert-previous-argument' no longer interprets &. | ||
| 195 | This worked strangely in shell-mode in the presence of &&. And omitting this | ||
| 196 | logic makes sense since 'comint-insert-previous-argument' exists to emulate M-. | ||
| 197 | in bash and zsh, and neither of those treat & specially. | ||
| 198 | |||
| 194 | *** 'comint-insert-previous-argument' knows how to count args | 199 | *** 'comint-insert-previous-argument' knows how to count args |
| 195 | from the beginning or from the end. This is useful because | 200 | from the beginning or from the end. This is useful because |
| 196 | 'comint-insert-previous-argument' exists to emulate M-. in bash and zsh; and | 201 | 'comint-insert-previous-argument' exists to emulate M-. in bash and zsh; and |
diff --git a/lisp/comint.el b/lisp/comint.el index f66e40b150b..82c547c9760 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -2705,9 +2705,6 @@ is the last argument. This command is like `M-.' in bash and zsh." | |||
| 2705 | (set-marker comint-insert-previous-argument-last-start-pos (point)) | 2705 | (set-marker comint-insert-previous-argument-last-start-pos (point)) |
| 2706 | ;; Insert the argument. | 2706 | ;; Insert the argument. |
| 2707 | (let ((input-string (comint-previous-input-string 0))) | 2707 | (let ((input-string (comint-previous-input-string 0))) |
| 2708 | (when (string-match "[ \t\n]*&" input-string) | ||
| 2709 | ;; strip terminating '&' | ||
| 2710 | (setq input-string (substring input-string 0 (match-beginning 0)))) | ||
| 2711 | (insert (comint-arguments input-string index index))) | 2708 | (insert (comint-arguments input-string index index))) |
| 2712 | ;; Make next invocation return arg from previous input | 2709 | ;; Make next invocation return arg from previous input |
| 2713 | (setq comint-input-ring-index (1+ (or comint-input-ring-index 0))) | 2710 | (setq comint-input-ring-index (1+ (or comint-input-ring-index 0))) |