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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7883 in the body.
You can then email your comments to 7883 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7883; Package emacs. (Fri, 21 Jan 2011 18:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Roland McGrath <roland <at> frob.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 21 Jan 2011 18:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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^$*-]+\\)?")





Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Fri, 21 Jan 2011 20:50:03 GMT) Full text and rfc822 format available.

Notification sent to Roland McGrath <roland <at> frob.com>:
bug acknowledged by developer. (Fri, 21 Jan 2011 20:50:04 GMT) Full text and rfc822 format available.

Message #10 received at 7883-done <at> debbugs.gnu.org (full text, mbox):

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




Forcibly Merged 7883 8000. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 08 Feb 2011 05:06:01 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7883; Package emacs. (Tue, 15 Feb 2011 01:28:02 GMT) Full text and rfc822 format available.

Message #15 received at 7883 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 7883 <at> debbugs.gnu.org, Roland McGrath <roland <at> frob.com>
Subject: Re: bug#7883: [PATCH] comint history expansion fails to process :N or
	$ modifier
Date: Mon, 14 Feb 2011 20:36:24 -0500
Stefan Monnier wrote:

>> 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.

This just undoes the fix installed for

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1795

(Although it wasn't really fixed anyway.)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7883; Package emacs. (Tue, 15 Feb 2011 01:48:02 GMT) Full text and rfc822 format available.

Message #18 received at 7883 <at> debbugs.gnu.org (full text, mbox):

From: Roland McGrath <roland <at> frob.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 7883 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#7883: [PATCH] comint history expansion fails to process :N or
	$ modifier
Date: Mon, 14 Feb 2011 17:56:19 -0800 (PST)
> This just undoes the fix installed for
> 
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1795
> 
> (Although it wasn't really fixed anyway.)

The change was not a fix for that problem at all, as you say.  That problem
continues to exist in various forms (that also exist in v22) and is a bug
in entirely different parts of the code.  I noticed the gratuitous
insertion of spaces long ago, but it didn't really irk me quite enough to
look into it.  I see no reason whatsoever why expansion should be looking
for metacharacters and fiddling things around like that at all.  I always
assumed it was a dismally misguided attempt at pretty-printing, which, even
it weren't completely broken (as it is), is not a proper thing to be doing
implicitly during history expansion at all.

This misfeature appears to be fixed by:

(setq comint-delimiter-argument-list nil) ;buffer-local

The buffer-local setting comes from the global value of
shell-delimiter-argument-list, which I've just set to nil in my init files.

I really can't tell what the thinking behind the default setting of that
was, since it's not commented particularly well.  It seems just entirely
wrong-headed to me.  As far as I can tell, the only uses of the things it
affects (comint-delimiter-argument-list, comint-arguments, comint-args)
are in this history expansion stuff, where it is just thoroughly wrong if
you either want to have history expansion work anything like it does in
the shell (which is largely immune to any details of shell syntax, though
bash's is not so immune to quoting as is csh's, which is the original and
One True definition of ! history's meaning), or you know much of anything
about shell syntax.


Thanks,
Roland




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7883; Package emacs. (Tue, 15 Feb 2011 01:52:02 GMT) Full text and rfc822 format available.

Message #21 received at 7883 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Roland McGrath <roland <at> frob.com>
Cc: 7883 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#7883: [PATCH] comint history expansion fails to process :N or
	$ modifier
Date: Mon, 14 Feb 2011 21:00:23 -0500
Roland McGrath wrote:

> The buffer-local setting comes from the global value of
> shell-delimiter-argument-list, which I've just set to nil in my init files.

:)

http://debbugs.gnu.org/cgi-bin/bugreport.cgi?bug=8027#22




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 15 Mar 2011 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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