From 45de3e8dfa8a267c7af7732ef5fc6cb2c1606a66 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sun, 25 Dec 2016 11:49:44 -0800 Subject: [PATCH 2/2] 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 & --- lisp/comint.el | 3 --- 1 file changed, 3 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index 171caef..83dbce0 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2692,9 +2692,6 @@ comint-insert-previous-argument (set-marker comint-insert-previous-argument-last-start-pos (point)) ;; Insert the argument. (let ((input-string (comint-previous-input-string 0))) - (when (string-match "[ \t\n]*&" input-string) - ;; strip terminating '&' - (setq input-string (substring input-string 0 (match-beginning 0)))) (insert (comint-arguments input-string index index))) ;; Make next invocation return arg from previous input (setq comint-input-ring-index (1+ (or comint-input-ring-index 0))) -- 2.10.1