Subject: bug#9679: 24.0.90; After rgrep, next-error goes to the wrong line

From: Ari Roponen <[email-masked]>
Date: Thu, 06 Oct 2011 09:14:02 +0300

Sometimes next-error goes to the wrong line when stepping through rgrep
matches.

Using git bisect and the code below, I found the commit that causes the
problem (rev 105677). Reverting that (and before that a commit that
depended on it) makes the problem disappear.

rev 105685: (grep-regexp-alist): Move dangling comment to the previous rule.
rev 105677: progmodes/grep.el (grep-regexp-alist): Calculate column positions

I used the following test case to find the problematic commit. It
creates a file with two lines matching "mapcar" and then rgreps for it.
After that it calls next-error two times. The second call goes into the
line starting with " (list 'face ...".
                          ^- here

--- code begins ----

(let ((dir (expand-file-name
	    (format "tmp%d" (emacs-pid))
	    temporary-file-directory)))
  (ignore-errors (make-directory dir))

  (with-temp-file (expand-file-name "test.el" dir)
    (insert
"(defun my-diary-lib--date-to-string (date)
  (destructuring-bind (month day year)
      (mapcar 'number-to-string date)
    (concat day \".\" month \".\" year)))

\(defun my-diary-lib--string-to-date (datestr)
  (destructuring-bind (day month year)
      (mapcar #'string-to-number (split-string datestr \"\\\\.\"))
    (list month day year)))

\(defun my-diary-lib-add-dayname (datestr)
  (list 'face 'font-lock-comment-face
	'display (concat datestr \" \" (calendar-day-name
					(my-diary-lib--string-to-date datestr)))))
"))

  (grep-compute-defaults)
  (rgrep "mapcar" "test.el" dir)
  (run-with-idle-timer 0.5 nil #'next-error 1)
  (run-with-idle-timer 1.0 nil #'next-error 1))

--- code ends ---

In GNU Emacs 24.0.90.7 (x86_64-unknown-linux-gnu, GTK+ Version 3.2.0)
 of 2011-10-06 on arirop
Windowing system distributor `Fedora Project', version 11.0.11000000
configured using `configure  '--with-x-toolkit=gtk3''

-- 
Ari Roponen