aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2014-09-26 11:32:48 -0700
committerPaul Eggert2014-09-26 11:32:48 -0700
commit56c6a28d018e8735b14e9bf170c3867cc48374fc (patch)
tree248df227c53c82972a489daa347c5fba6b9c8c96
parent1f9f052c6def2f0d4c19161d6d64979d1e8aa96a (diff)
downloademacs-56c6a28d018e8735b14e9bf170c3867cc48374fc.tar.gz
emacs-56c6a28d018e8735b14e9bf170c3867cc48374fc.zip
* progmodes/grep.el (grep-regexp-alist): Use more-accurate regexp.
Do not match file names that end in '/', as they cannot be 'grep' hits nowadays. This prevents confusion when 'grep -r' reports a match in a file whose basename is ':12345:'. Conversely, do not require exactly the same sequence of spaces and tabs after both colons, and allow spaces or tabs before the second colon, as per the POSIX spec for 'grep' output.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/progmodes/grep.el15
2 files changed, 15 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4c4941d982d..8586d59b3ad 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12014-09-26 Paul Eggert <eggert@cs.ucla.edu>
2
3 * progmodes/grep.el (grep-regexp-alist): Use more-accurate regexp.
4 Do not match file names that end in '/', as they cannot be 'grep'
5 hits nowadays. This prevents confusion when 'grep -r' reports a
6 match in a file whose basename is ':12345:'. Conversely, do not
7 require exactly the same sequence of spaces and tabs after both
8 colons, and allow spaces or tabs before the second colon, as per
9 the POSIX spec for 'grep' output.
10
12014-09-26 Leo Liu <sdl.web@gmail.com> 112014-09-26 Leo Liu <sdl.web@gmail.com>
2 12
3 Add cl-parse-integer based on parse-integer (Bug#18557) 13 Add cl-parse-integer based on parse-integer (Bug#18557)
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 47d92e70c5f..fd48adc70c6 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -343,16 +343,11 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
343;;;###autoload 343;;;###autoload
344(defconst grep-regexp-alist 344(defconst grep-regexp-alist
345 '( 345 '(
346 ;; Rule to match column numbers is commented out since no known grep 346 ;; Use a tight regexp to handle weird file names (with colons
347 ;; produces them 347 ;; in them) as well as possible. E.g., use [1-9][0-9]* rather
348 ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([1-9][0-9]*\\)\\2\\(?:\\([1-9][0-9]*\\)\\(?:-\\([1-9][0-9]*\\)\\)?\\2\\)?" 348 ;; than [0-9]+ so as to accept ":034:" in file names.
349 ;; 1 3 (4 . 5)) 349 ("^\\(.*?[^/\n]\\):[ \t]*\\([1-9][0-9]*\\)[ \t]*:"
350 ;; Note that we want to use as tight a regexp as we can to try and 350 1 2
351 ;; handle weird file names (with colons in them) as well as possible.
352 ;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:"
353 ;; in file names.
354 ("^\\(.+?\\)\\(:[ \t]*\\)\\([1-9][0-9]*\\)\\2"
355 1 3
356 ;; Calculate column positions (col . end-col) of first grep match on a line 351 ;; Calculate column positions (col . end-col) of first grep match on a line
357 ((lambda () 352 ((lambda ()
358 (when grep-highlight-matches 353 (when grep-highlight-matches