GNU bug report logs - #11382
M-x grep sometimes mark matches erroneously

Previous Next

Package: emacs;

Reported by: Troels Nielsen <bn.troels <at> gmail.com>

Date: Mon, 30 Apr 2012 10:08:02 UTC

Severity: normal

Tags: patch

Done: Chong Yidong <cyd <at> gnu.org>

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 11382 in the body.
You can then email your comments to 11382 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 bug-gnu-emacs <at> gnu.org:
bug#11382; Package emacs. (Mon, 30 Apr 2012 10:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Troels Nielsen <bn.troels <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 30 Apr 2012 10:08:02 GMT) Full text and rfc822 format available.

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

From: Troels Nielsen <bn.troels <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: M-x grep sometimes mark matches erroneously
Date: Mon, 30 Apr 2012 12:06:00 +0200
Hi all, and thanks for all the good work with emacs!

When running M-x grep and getting many matches, when walking through
the *grep* buffer (with <n> for example) eventually the matches will
fail to be highlighted appropriately.

To reproduce e.g.

1. emacs -Q
2. goto emacs trunk/src directory
3. M-x grep
4. Enter the command: grep -nH -e .c bytecode.c
5. Walk through the *grep* buffer with n, and notice erroneous
highlights in bytecode.c-buffer.

This patch fixes the problem for me.
It works by calculating the start-position correctly when end-col, but
not end-line is set.

I've also taken the liberty of not using loc for line in the upper
part of compilation-internal-error-properties, as I think that use is
a little confusing and possibly the cause of some bugs.

Regards
Troels

=== modified file 'lisp/progmodes/compile.el'
--- lisp/progmodes/compile.el	2012-04-09 13:05:48 +0000
+++ lisp/progmodes/compile.el	2012-04-30 09:57:39 +0000
@@ -1068,14 +1068,14 @@
 	 end-marker loc end-loc)
     (if (not (and marker (marker-buffer marker)))
 	(setq marker nil)		; no valid marker for this file
-      (setq loc (or line 1))		; normalize no linenumber to line 1
+      (unless line (setq line 1))       ; normalize no linenumber to line 1
       (catch 'marker			; find nearest loc, at least one exists
 	(dolist (x (cddr (compilation--file-struct->loc-tree
                           file-struct)))	; Loop over remaining lines.
-	  (if (> (car x) loc)		; Still bigger.
+	  (if (> (car x) line)		; Still bigger.
 	      (setq marker-line x)
-	    (if (> (- (or (car marker-line) 1) loc)
-		   (- loc (car x)))	; Current line is nearer.
+	    (if (> (- (or (car marker-line) 1) line)
+		   (- line (car x)))	; Current line is nearer.
 		(setq marker-line x))
 	    (throw 'marker t))))
       (setq marker (compilation--loc->marker (cadr marker-line))
@@ -1093,15 +1093,18 @@
 	  (save-restriction
 	    (widen)
 	    (goto-char (marker-position marker))
-	    (when (or end-col end-line)
-	      (beginning-of-line (- (or end-line line) marker-line -1))
-	      (if (or (null end-col) (< end-col 0))
-		  (end-of-line)
-		(compilation-move-to-column end-col screen-columns))
-	      (setq end-marker (point-marker)))
-	    (beginning-of-line (if end-line
-				   (- line end-line -1)
-				 (- loc marker-line -1)))
+
+            ; set end-marker if appropriate and goto line
+	    (if (not (or end-col end-line))
+                (beginning-of-line (- line marker-line -1))
+
+              (beginning-of-line (- (or end-line line) marker-line -1))
+              (if (or (null end-col) (< end-col 0))
+                  (end-of-line)
+                (compilation-move-to-column end-col screen-columns))
+              (setq end-marker (point-marker))
+              (when end-line (beginning-of-line (- line end-line -1))))
+
 	    (if col
 		(compilation-move-to-column col screen-columns)
 	      (forward-to-indentation 0))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11382; Package emacs. (Sun, 06 May 2012 04:57:01 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: Troels Nielsen <bn.troels <at> gmail.com>
Cc: 11382 <at> debbugs.gnu.org
Subject: Re: bug#11382: M-x grep sometimes mark matches erroneously
Date: Sun, 06 May 2012 12:54:55 +0800
Troels Nielsen <bn.troels <at> gmail.com> writes:

> This patch fixes the problem for me.  It works by calculating the
> start-position correctly when end-col, but not end-line is set.
>
> I've also taken the liberty of not using loc for line in the upper
> part of compilation-internal-error-properties, as I think that use is
> a little confusing and possibly the cause of some bugs.

Committed to trunk.  Thank you.

We're approaching the extent of the contributions we can accept form you
without a copyright assignment.  If you intend to submit more patches in
the future, would you be willing to sign a copyright assignment?




bug closed, send any further explanations to 11382 <at> debbugs.gnu.org and Troels Nielsen <bn.troels <at> gmail.com> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 13 May 2012 09:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 10 Jun 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 315 days ago.

Previous Next


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