* grep error because of bad previous input
@ 2006-07-27 17:32 Sam Steingold
2006-07-27 17:51 ` Chong Yidong
2006-07-27 23:46 ` Richard Stallman
0 siblings, 2 replies; 6+ messages in thread
From: Sam Steingold @ 2006-07-27 17:32 UTC (permalink / raw)
GNU Emacs 22.0.50.3 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2006-07-24 on quant8
M-x grep RET
foo *.lis[ RET ;; typo: "[" instead of "p"
M-x grep RET
==>
Debugger entered--Lisp error: (args-out-of-range "*.lis[" 6)
wildcard-to-regexp("*.lis[")
grep-default-command()
(let ((default ...)) (list (read-from-minibuffer "Run grep (like this): " ... nil nil ... ...)))
(progn (grep-compute-defaults) (let (...) (list ...)))
call-interactively(grep)
execute-extended-command(nil)
call-interactively(execute-extended-command)
--
Sam Steingold (http://www.podval.org/~sds) on Fedora Core release 5 (Bordeaux)
http://palestinefacts.org http://thereligionofpeace.com http://truepeace.org
http://ffii.org http://mideasttruth.com http://pmw.org.il http://memri.org
The only thing worse than X Windows: (X Windows) - X
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: grep error because of bad previous input
2006-07-27 17:32 grep error because of bad previous input Sam Steingold
@ 2006-07-27 17:51 ` Chong Yidong
2006-07-27 18:16 ` Sam Steingold
2006-07-27 23:46 ` Richard Stallman
1 sibling, 1 reply; 6+ messages in thread
From: Chong Yidong @ 2006-07-27 17:51 UTC (permalink / raw)
Cc: emacs-devel
Sam Steingold <sds@podval.org> writes:
> GNU Emacs 22.0.50.3 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
> of 2006-07-24 on quant8
>
> M-x grep RET
> foo *.lis[ RET ;; typo: "[" instead of "p"
> M-x grep RET
>
> ==>
>
> Debugger entered--Lisp error: (args-out-of-range "*.lis[" 6)
> wildcard-to-regexp("*.lis[")
I can't reproduce this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: grep error because of bad previous input
2006-07-27 17:51 ` Chong Yidong
@ 2006-07-27 18:16 ` Sam Steingold
0 siblings, 0 replies; 6+ messages in thread
From: Sam Steingold @ 2006-07-27 18:16 UTC (permalink / raw)
Cc: emacs-devel
> * Chong Yidong <plq@fghcvqpuvpxra.pbz> [2006-07-27 13:51:00 -0400]:
>
> Sam Steingold <sds@podval.org> writes:
>
>> GNU Emacs 22.0.50.3 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
>> of 2006-07-24 on quant8
>>
>> M-x grep RET
>> foo *.lis[ RET ;; typo: "[" instead of "p"
>> M-x grep RET
>>
>> ==>
>>
>> Debugger entered--Lisp error: (args-out-of-range "*.lis[" 6)
>> wildcard-to-regexp("*.lis[")
>
> I can't reproduce this.
(setq grep-history '("grep -nH -e compute-discriminating-function *.lis["))
(let ((buffer-file-name "foo"))
(grep-default-command))
i.e.,
1. last grep command must have a regexp-like wildcard for filenames
2. the current buffer must be named.
--
Sam Steingold (http://www.podval.org/~sds) on Fedora Core release 5 (Bordeaux)
http://camera.org http://thereligionofpeace.com http://ffii.org
http://dhimmi.com http://jihadwatch.org http://iris.org.il http://pmw.org.il
Vegetarians eat Vegetables, Humanitarians are scary.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: grep error because of bad previous input
2006-07-27 17:32 grep error because of bad previous input Sam Steingold
2006-07-27 17:51 ` Chong Yidong
@ 2006-07-27 23:46 ` Richard Stallman
2006-07-28 7:11 ` Stefan Monnier
1 sibling, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2006-07-27 23:46 UTC (permalink / raw)
Cc: emacs-devel
Does this fix it?
*** grep.el 19 Jul 2006 17:19:19 -0400 1.62
--- grep.el 27 Jul 2006 19:15:01 -0400
***************
*** 456,488 ****
t)))))
(defun grep-default-command ()
(let ((tag-default
(shell-quote-argument
(or (funcall (or find-tag-default-function
(get major-mode 'find-tag-default-function)
'find-tag-default))
"")))
(sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
(grep-default (or (car grep-history) grep-command)))
! ;; Replace the thing matching for with that around cursor.
(when (or (string-match
(concat "[^ ]+\\s +\\(?:-[^ ]+\\s +\\)*"
sh-arg-re "\\(\\s +\\(\\S +\\)\\)?")
grep-default)
;; If the string is not yet complete.
(string-match "\\(\\)\\'" grep-default))
! (unless (or (not (stringp buffer-file-name))
! (when (match-beginning 2)
! (save-match-data
! (string-match
! (wildcard-to-regexp
! (file-name-nondirectory
! (match-string 3 grep-default)))
! (file-name-nondirectory buffer-file-name)))))
! (setq grep-default (concat (substring grep-default
! 0 (match-beginning 2))
! " *."
! (file-name-extension buffer-file-name))))
(replace-match tag-default t t grep-default 1))))
--- 456,499 ----
t)))))
(defun grep-default-command ()
+ "Compute the default grep command for C-u M-x grep to offer."
(let ((tag-default
+ ;; Find the tag in the buffer at point.
(shell-quote-argument
(or (funcall (or find-tag-default-function
(get major-mode 'find-tag-default-function)
'find-tag-default))
"")))
+ ;; Is this a regexp to match single shell arguments?
+ ;; I guess so. Does someone know?
(sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
(grep-default (or (car grep-history) grep-command)))
! ;; In the default command, find the arg that specifies the pattern.
(when (or (string-match
(concat "[^ ]+\\s +\\(?:-[^ ]+\\s +\\)*"
sh-arg-re "\\(\\s +\\(\\S +\\)\\)?")
grep-default)
;; If the string is not yet complete.
(string-match "\\(\\)\\'" grep-default))
! ;; Maybe we will replace the pattern with the default tag.
! ;; But first, maybe replace the file name pattern.
! (condition-case nil
! (unless (or (not (stringp buffer-file-name))
! (when (match-beginning 2)
! (save-match-data
! (string-match
! (wildcard-to-regexp
! (file-name-nondirectory
! (match-string 3 grep-default)))
! (file-name-nondirectory buffer-file-name)))))
! (setq grep-default (concat (substring grep-default
! 0 (match-beginning 2))
! " *."
! (file-name-extension buffer-file-name))))
! ;; In case wildcard-to-regexp gets an error
! ;; from invalid data.
! (error nil))
! ;; Now replace the pattern with the default tag.
(replace-match tag-default t t grep-default 1))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: grep error because of bad previous input
2006-07-27 23:46 ` Richard Stallman
@ 2006-07-28 7:11 ` Stefan Monnier
2006-07-28 7:31 ` David Kastrup
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2006-07-28 7:11 UTC (permalink / raw)
Cc: sds, emacs-devel
> + ;; Is this a regexp to match single shell arguments?
> + ;; I guess so. Does someone know?
> (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
Yes, that's what it's intended to do.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: grep error because of bad previous input
2006-07-28 7:11 ` Stefan Monnier
@ 2006-07-28 7:31 ` David Kastrup
0 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2006-07-28 7:31 UTC (permalink / raw)
Cc: sds, rms, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> + ;; Is this a regexp to match single shell arguments?
>> + ;; I guess so. Does someone know?
>> (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
>
> Yes, that's what it's intended to do.
It would appear to make minced meat from
"\\" "\\"
as far as I can see. Would probably need something like
(sh-arg-re "\\(\\(?:\"\\(?:[^\\\"]\\|\\\\[^\"]\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-07-28 7:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-27 17:32 grep error because of bad previous input Sam Steingold
2006-07-27 17:51 ` Chong Yidong
2006-07-27 18:16 ` Sam Steingold
2006-07-27 23:46 ` Richard Stallman
2006-07-28 7:11 ` Stefan Monnier
2006-07-28 7:31 ` David Kastrup
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).