aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/emacs/misc.texi22
-rw-r--r--etc/NEWS31
-rw-r--r--lisp/comint.el25
3 files changed, 46 insertions, 32 deletions
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 7c595388ead..24586eb2813 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1133,7 +1133,7 @@ Fetch the next subsequent command from the history
1133 1133
1134@item C-c . 1134@item C-c .
1135@kindex C-c . @r{(Shell mode)} 1135@kindex C-c . @r{(Shell mode)}
1136@findex comint-input-previous-argument 1136@findex comint-insert-previous-argument
1137Fetch one argument from an old shell command 1137Fetch one argument from an old shell command
1138(@code{comint-input-previous-argument}). 1138(@code{comint-input-previous-argument}).
1139 1139
@@ -1180,14 +1180,20 @@ you just repeated. Then type @key{RET} to reexecute this command. You
1180can reexecute several successive commands by typing @kbd{C-c C-x 1180can reexecute several successive commands by typing @kbd{C-c C-x
1181@key{RET}} over and over. 1181@key{RET}} over and over.
1182 1182
1183 The command @kbd{C-c .}@: (@code{comint-input-previous-argument}) 1183 The command @kbd{C-c .}@: (@code{comint-insert-previous-argument})
1184copies an individual argument from a previous command, like 1184copies an individual argument from a previous command, like
1185@kbd{@key{ESC} .} in Bash. The simplest use copies the last argument from the 1185@kbd{@key{ESC} .}@: in Bash and @command{zsh}. The simplest use
1186previous shell command. With a prefix argument @var{n}, it copies the 1186copies the last argument from the previous shell command. With a
1187@var{n}th argument instead. Repeating @kbd{C-c .} copies from an 1187prefix argument @var{n}, it copies the @var{n}th argument instead.
1188earlier shell command instead, always using the same value of @var{n} 1188Repeating @kbd{C-c .} copies from an earlier shell commands, always
1189(don't give a prefix argument when you repeat the @kbd{C-c .} 1189using the same value of @var{n} (don't give a prefix argument when
1190command). 1190you repeat the @kbd{C-c .} command).
1191
1192@vindex comint-insert-previous-argument-from-end
1193 If you set @code{comint-insert-previous-argument-from-end} to a
1194non-@code{nil} value, @kbd{C-c .}@: will instead copy the @var{n}th
1195argument counting from the last one; this emulates @kbd{@key{ESC} .}@:
1196in @command{zsh}.
1191 1197
1192 These commands get the text of previous shell commands from a special 1198 These commands get the text of previous shell commands from a special
1193history list, not from the shell buffer itself. Thus, editing the shell 1199history list, not from the shell buffer itself. Thus, editing the shell
diff --git a/etc/NEWS b/etc/NEWS
index 5568e29eb8e..f290e76e445 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -186,24 +186,29 @@ navigation and editing of large files.
186* Changes in Specialized Modes and Packages in Emacs 27.1 186* Changes in Specialized Modes and Packages in Emacs 27.1
187 187
188** Browse-url 188** Browse-url
189
189*** The function 'browse-url-emacs' can now visit a URL in selected window. 190*** The function 'browse-url-emacs' can now visit a URL in selected window.
190It now treats the optional 2nd argument to mean that the URL should be 191It now treats the optional 2nd argument to mean that the URL should be
191shown in the currently selected window. 192shown in the currently selected window.
192 193
193** Comint 194** Comint
194*** 'comint-insert-previous-argument' no longer interprets &. 195
195This worked strangely in shell-mode in the presence of &&. And omitting this 196+++
196logic makes sense since 'comint-insert-previous-argument' exists to emulate M-. 197*** 'C-c .' (comint-insert-previous-argument) no longer interprets '&'.
197in bash and zsh, and neither of those treat & specially. 198This feature caused problems when '&&' was present in the previous
198 199command. Since this command emulates 'M-.' in Bash and zsh, neither
199*** 'comint-insert-previous-argument' knows how to count args 200of which treats '&' specially, the feature was removed for
200from the beginning or from the end. This is useful because 201compatibility with these shells.
201'comint-insert-previous-argument' exists to emulate M-. in bash and zsh; and 202
202bash counts from the start while zsh counts from the end. 203+++
203 204*** 'comint-insert-previous-argument' can now count arguments from the end.
204*** New variable 'comint-insert-previous-argument-from-end' controls whether 205By default, invoking 'C-c .' with a numeric argument N would copy the
205args passed to 'comint-insert-previous-argument' count from the beginning or 206Nth argument, counting from the first one. But if the new option
206from the end 207'comint-insert-previous-argument-from-end' is non-nil, it will copy
208the Nth argument counting from the last one. Thus 'C-c .' can now
209better emulate 'M-.' in both Bash and zsh, since the former counts
210from the beginning of the arguments, while the latter counts from the
211end.
207 212
208** Flymake 213** Flymake
209 214
diff --git a/lisp/comint.el b/lisp/comint.el
index 82c547c9760..71a2b5eca55 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1682,8 +1682,9 @@ characters), and are not considered to be delimiters."
1682 1682
1683(defun comint-arguments (string nth mth) 1683(defun comint-arguments (string nth mth)
1684 "Return from STRING the NTH to MTH arguments. 1684 "Return from STRING the NTH to MTH arguments.
1685NTH and/or MTH can be nil, which means the last argument. NTH 1685NTH and/or MTH can be nil, which means the last argument.
1686and MTH can be <0 to count from the end; -1 means last argument. 1686NTH and MTH can be negative to count from the end; -1 means
1687the last argument.
1687Returned arguments are separated by single spaces. We assume 1688Returned arguments are separated by single spaces. We assume
1688whitespace separates arguments, except within quotes and except 1689whitespace separates arguments, except within quotes and except
1689for a space or tab that immediately follows a backslash. Also, a 1690for a space or tab that immediately follows a backslash. Also, a
@@ -2660,14 +2661,15 @@ text matching `comint-prompt-regexp'."
2660(defvar-local comint-insert-previous-argument-last-index nil) 2661(defvar-local comint-insert-previous-argument-last-index nil)
2661 2662
2662(defcustom comint-insert-previous-argument-from-end nil 2663(defcustom comint-insert-previous-argument-from-end nil
2663 "If nil, the INDEX argument to 2664 "If non-nil, `comint-insert-previous-argument' counts args from the end.
2664`comint-insert-previous-argument' refers to the INDEX-th 2665If this variable is nil, the default, `comint-insert-previous-argument'
2665argument, counting from the beginning; if non-nil, counting from 2666counts the arguments from the beginning; if non-nil, it counts from
2666the end. This exists to emulate the bahavior of `M-number M-.' 2667the end instead. This allows to emulate the behavior of `ESC-NUM ESC-.'
2667in bash and zsh: in bash, `number' counts from the 2668in both Bash and zsh: in Bash, `number' counts from the
2668beginning (variable in nil), while in zsh it counts from the end." 2669beginning (variable is nil), while in zsh, it counts from the end."
2669 :type 'boolean 2670 :type 'boolean
2670 :group 'comint) 2671 :group 'comint
2672 :version "27.1")
2671 2673
2672(defun comint-insert-previous-argument (index) 2674(defun comint-insert-previous-argument (index)
2673 "Insert the INDEXth argument from the previous Comint command-line at point. 2675 "Insert the INDEXth argument from the previous Comint command-line at point.
@@ -2676,8 +2678,9 @@ necessary to ensure that it's separated from adjacent arguments.
2676Interactively, if no prefix argument is given, the last argument is inserted. 2678Interactively, if no prefix argument is given, the last argument is inserted.
2677Repeated interactive invocations will cycle through the same argument 2679Repeated interactive invocations will cycle through the same argument
2678from progressively earlier commands (using the value of INDEX specified 2680from progressively earlier commands (using the value of INDEX specified
2679with the first command). Values of INDEX<0 count from the end, so INDEX=-1 2681with the first command). Values of INDEX < 0 count from the end, so
2680is the last argument. This command is like `M-.' in bash and zsh." 2682INDEX = -1 is the last argument. This command is like `M-.' in
2683Bash and zsh."
2681 (interactive "P") 2684 (interactive "P")
2682 (unless (null index) 2685 (unless (null index)
2683 (setq index (prefix-numeric-value index))) 2686 (setq index (prefix-numeric-value index)))