Subject: Re: bug#4210: 23.1.50; lgrep chooses silly default value for file extension

From: Kevin Rodgers <[email-masked]>
Date: Sun, 23 Aug 2009 12:02:51 -0600

Eric Hanchrow wrote:
> Please write in English if possible, because the Emacs maintainers
> usually do not have translators to read other languages for them.
> 
> Your bug report will be posted to the [email-masked] mailing list.
> 
> Please describe exactly what actions triggered the bug
> and the precise symptoms of the bug:
> 
> I visited a python file
> 
> C-x C-f ~ / l o c TAB RET b i n RET . p y RET
> 
> (I happen to have a bunch of python files in ~/local/bin, and I have
> ido-mode turned on)
>  
> I cloned the buffer:
> 
> C-x 4 c 
> 
> I used lgrep to search:
> 
> ESC x l g r e p RET ^ c l a s s RET RET RET
> 
> 
> At this point I was looking at a *grep* buffer like this:
> 
>     -*- mode: grep; default-directory: "~/local/bin/" -*-
>     Grep started at Wed Aug 19 19:17:41
> 
>     grep -i -nH -e \^class *.py<2>
>     /bin/bash: -c: line 0: syntax error near unexpected token `2'
>     /bin/bash: -c: line 0: `grep -i -nH -e \^class *.py<2>'
> 
>     Grep exited abnormally with code 2 at Wed Aug 19 19:17:41
> 
> Naturally the "grep" command should have been 
> 
>     grep -i -nH -e \^class *.py
> 
> i.e., the "<2>" shouldn't have been put in there.

2009-08-23  Kevin Rodgers  <[email-masked]>

	* progmodes/grep.el (grep-read-files): Strip trailing <N> from
	buffer names not visiting a file (e.g. cloned buffers).

*** grep.el~	Sun Aug 23 11:51:39 2009
--- grep.el	Sun Aug 23 11:52:37 2009
***************
*** 747,753 ****

   (defun grep-read-files (regexp)
     "Read files arg for interactive grep."
!   (let* ((bn (or (buffer-file-name) (buffer-name)))
   	 (fn (and bn
   		  (stringp bn)
   		  (file-name-nondirectory bn)))
--- 747,754 ----

   (defun grep-read-files (regexp)
     "Read files arg for interactive grep."
!   (let* ((bn (or (buffer-file-name)
! 		 (replace-regexp-in-string "<[0-9]+>\\'" "" (buffer-name))))
   	 (fn (and bn
   		  (stringp bn)
   		  (file-name-nondirectory bn)))

-- 
Kevin Rodgers
Denver, Colorado, USA