emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r105010: Fix bugs finding grep hits i


From: Richard Stallman
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105010: Fix bugs finding grep hits in Rmail buffers.
Date: Thu, 07 Jul 2011 06:35:43 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105010
committer: Richard Stallman <address@hidden>
branch nick: trunk
timestamp: Thu 2011-07-07 06:35:43 -0400
message:
  Fix bugs finding grep hits in Rmail buffers.
modified:
  lisp/ChangeLog
  lisp/mail/rmail.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-07-07 04:20:12 +0000
+++ b/lisp/ChangeLog    2011-07-07 10:35:43 +0000
@@ -1,3 +1,11 @@
+2011-07-07  Richard Stallman  <address@hidden>
+
+       * mail/rmail.el (rmail-next-error-move): Use `compilation-message'
+       property, and handle its changed format.
+       Look for the correct line number.
+       Use file's line contents (but not past first =) to find
+       correct line in message.
+
 2011-07-07  Kenichi Handa  <address@hidden>
 
        * international/characters.el (build-unicode-category-table):

=== modified file 'lisp/mail/rmail.el'
--- a/lisp/mail/rmail.el        2011-07-07 04:20:12 +0000
+++ b/lisp/mail/rmail.el        2011-07-07 10:35:43 +0000
@@ -3025,9 +3025,13 @@
 MSG-POS is a marker pointing at the error message in the grep buffer.
 BAD-MARKER is a marker that ought to point at where to move to,
 but probably is garbage."
-  (let* ((message (car (get-text-property msg-pos 'message (marker-buffer 
msg-pos))))
-        (column (car message))
-        (linenum (cadr message))
+
+  (let* ((message-loc (compilation--message->loc
+                      (get-text-property msg-pos 'compilation-message
+                                         (marker-buffer msg-pos))))
+        (column (car message-loc))
+        (linenum (cadr message-loc))
+        line-text
         pos
         msgnum msgbeg msgend
         header-field
@@ -3041,10 +3045,18 @@
       (save-excursion
        ;; Find the line that the error message points at.
        (goto-char (point-min))
-       (forward-line linenum)
+       (forward-line (1- linenum))
        (setq pos (point))
 
-       ;; Find which message that's in,
+       ;; Find the text at the start of the line,
+       ;; before the first = sign.
+       ;; This text has a good chance of being also in the
+       ;; decoded message.
+       (save-excursion
+         (skip-chars-forward "^=\n")
+         (setq line-text (buffer-substring pos (point))))
+
+       ;; Find which message this position is in,
        ;; and the limits of that message.
        (setq msgnum (rmail-what-message pos))
        (setq msgbeg (rmail-msgbeg msgnum))
@@ -3071,11 +3083,23 @@
     (rmail-show-message msgnum)
 
     ;; Move to the right position within the displayed message.
+    ;; Or at least try.  The decoded message's lines may not
+    ;; correspond to the lines in the inbox file.
+    (goto-char (point-min))
     (if header-field
-       (re-search-forward (concat "^" (regexp-quote header-field)) nil t)
-      (search-forward "\n\n" nil t))
-    (forward-line line-number-within)
-    (forward-char column)))
+       (progn 
+         (re-search-forward (concat "^" (regexp-quote header-field)) nil t)
+         (forward-line line-number-within))
+      (search-forward "\n\n" nil t)
+      (if (re-search-forward (concat "^" (regexp-quote line-text)) nil t)
+         (goto-char (match-beginning 0))))
+    (if (eobp)
+       ;; If the decoded message doesn't have enough lines,
+       ;; go to the beginning rather than the end.
+       (goto-char (point-min))
+      ;; Otherwise, go to the right column.
+      (if column
+         (forward-char column)))))
 
 (defun rmail-what-message (&optional pos)
   "Return message number POS (or point) is in."


reply via email to

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