emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/grep.el,v


From: Richard M. Stallman
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/grep.el,v
Date: Sat, 29 Jul 2006 02:03:21 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Richard M. Stallman <rms>       06/07/29 02:03:21

Index: grep.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/grep.el,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- grep.el     28 Jul 2006 23:20:21 -0000      1.64
+++ grep.el     29 Jul 2006 02:03:21 -0000      1.65
@@ -465,16 +465,22 @@
       ""))
 
 (defun grep-default-command ()
+  "Compute the default grep command for C-u M-x grep to offer."
   (let ((tag-default (shell-quote-argument (grep-tag-default)))
+       ;; This a regexp to match single shell arguments.
+       ;; Could someone please add comments explaining it?
        (sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' 
\t\n]\\)+\\)")
        (grep-default (or (car grep-history) grep-command)))
-    ;; Replace the thing matching for with that around cursor.
+    ;; 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
@@ -487,6 +493,10 @@
                                              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))))
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]