GNU bug report logs - #7883
[PATCH] comint history expansion fails to process :N or $ modifier

Previous Next

Package: emacs;

Reported by: Roland McGrath <roland <at> frob.com>

Date: Fri, 21 Jan 2011 18:22:02 UTC

Severity: normal

Tags: patch

Merged with 8000

Found in version 23.2

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#7883: closed ([PATCH] comint history expansion fails to
 process :N or $ modifier)
Date: Fri, 21 Jan 2011 20:50:04 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 21 Jan 2011 15:56:56 -0500
with message-id <jwvfwsmj7r6.fsf-monnier+emacs <at> gnu.org>
and subject line Re: bug#7883: [PATCH] comint history expansion fails to process :N or $ modifier
has caused the GNU bug report #7883,
regarding [PATCH] comint history expansion fails to process :N or $ modifier
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
7883: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7883
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Roland McGrath <roland <at> frob.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] comint history expansion fails to process :N or $ modifier
Date: Fri, 21 Jan 2011 10:10:59 -0800 (PST)
This has been driving me nuts since I started using 23 and I only just now
bothered to find and fix it.  This worked correctly in 22 and was broken,
apparently just by a careless change.

In a comint/shell buffer, type:
	echo foo bar RET
and then type:
	echo !$ TAB
and you get the expansion:
	echo echo foo bar
i.e., the whole line as if !$ had been !!.
The expansion you should get is just:
	echo bar

The following trivial patch fixes the bug, restoring the behavior of v22
with similar code to what it had originally.  I tested the fix in 23.2.1,
but the relevant comint.el code in the trunk has not changed since then.


Thanks,
Roland


2011-01-21  Roland McGrath  <roland <at> frob.com>

	* comint.el (comint-replace-by-expanded-history-before-point):
	Fix expansion of !$ and !!:N syntax to pick the indicated word.

--- lisp/comint.el	2011-01-20 22:36:12 +0000
+++ lisp/comint.el	2011-01-21 18:03:09 +0000
@@ -1294,7 +1294,9 @@ than the logical beginning of line."
 		   (message "Relative reference exceeds input history size"))))
 	      ((or (looking-at "!!?:?\\([0-9^$*-]+\\)") (looking-at "!!"))
 	       ;; Just a number of args from the previous input line.
-	       (replace-match (comint-previous-input-string 0) t t)
+	       (replace-match (comint-args (comint-previous-input-string 0)
+					   (match-beginning 1) (match-end 1))
+			      t t)
 	       (message "History item: previous"))
 	      ((looking-at
 		"!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\)\\(:?[0-9^$*-]+\\)?")



[Message part 3 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Roland McGrath <roland <at> frob.com>
Cc: 7883-done <at> debbugs.gnu.org
Subject: Re: bug#7883: [PATCH] comint history expansion fails to process :N or
	$ modifier
Date: Fri, 21 Jan 2011 15:56:56 -0500
> The following trivial patch fixes the bug, restoring the behavior of v22
> with similar code to what it had originally.  I tested the fix in 23.2.1,
> but the relevant comint.el code in the trunk has not changed since then.

Thanks.  I installed it in the emacs-23 branch.


        Stefan


This bug report was last modified 14 years and 97 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.