aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2011-06-23 13:08:15 -0400
committerRichard M. Stallman2011-06-23 13:08:15 -0400
commit14b4e83d6235ac48c563deda84f5fffe489f9a95 (patch)
treef808ef8b8229b99460307f920d7c32284be63b76
parent8050daa1d0ce09b581fa7c6a94be57d3ecdead3c (diff)
downloademacs-14b4e83d6235ac48c563deda84f5fffe489f9a95.tar.gz
emacs-14b4e83d6235ac48c563deda84f5fffe489f9a95.zip
Going to grep hit in Rmail buffer finds the message.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/mail/rmail.el73
2 files changed, 73 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c34ccb6e577..73c33ec6d6f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12011-06-23 Richard Stallman <rms@gnu.org>
2
3 * mail/rmail.el: Going to grep hit in Rmail buffer finds the message.
4 (rmail-variables): Set next-error-move-function.
5 (rmail-what-message): Take argument POS.
6 (rmail-next-error-move): New function.
7
12011-06-23 Stefan Monnier <monnier@iro.umontreal.ca> 82011-06-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * emacs-lisp/smie.el (smie-bnf->prec2): Give more understandable error 10 * emacs-lisp/smie.el (smie-bnf->prec2): Give more understandable error
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index a0156aeb750..04ff457dcfb 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1444,7 +1444,8 @@ If so restore the actual mbox message collection."
1444 (make-local-variable 'file-precious-flag) 1444 (make-local-variable 'file-precious-flag)
1445 (setq file-precious-flag t) 1445 (setq file-precious-flag t)
1446 (make-local-variable 'desktop-save-buffer) 1446 (make-local-variable 'desktop-save-buffer)
1447 (setq desktop-save-buffer t)) 1447 (setq desktop-save-buffer t)
1448 (setq next-error-move-function 'rmail-next-error-move))
1448 1449
1449;; Handle M-x revert-buffer done in an rmail-mode buffer. 1450;; Handle M-x revert-buffer done in an rmail-mode buffer.
1450(defun rmail-revert (arg noconfirm) 1451(defun rmail-revert (arg noconfirm)
@@ -3019,15 +3020,73 @@ or forward if N is negative."
3019 (rmail-maybe-set-message-counters) 3020 (rmail-maybe-set-message-counters)
3020 (rmail-show-message rmail-total-messages)) 3021 (rmail-show-message rmail-total-messages))
3021 3022
3022(defun rmail-what-message () 3023(defun rmail-next-error-move (msg-pos bad-marker)
3023 "For debugging Rmail: find the message number that point is in." 3024 "Move to an error locus (probably grep hit) in an Rmail buffer.
3025MSG-POS is a marker pointing at the error message in the grep buffer.
3026BAD-MARKER is a marker that ought to point at where to move to,
3027but probably is garbage."
3028 (let* ((message (car (get-text-property msg-pos 'message (marker-buffer msg-pos))))
3029 (column (car message))
3030 (linenum (cadr message))
3031 pos
3032 msgnum msgbeg msgend
3033 header-field
3034 line-number-within)
3035
3036 ;; Look at the whole Rmail file.
3037 (rmail-swap-buffers-maybe)
3038
3039 (save-restriction
3040 (widen)
3041 (save-excursion
3042 ;; Find the line that the error message points at.
3043 (goto-char (point-min))
3044 (forward-line linenum)
3045 (setq pos (point))
3046
3047 ;; Find which message that's in,
3048 ;; and the limits of that message.
3049 (setq msgnum (rmail-what-message pos))
3050 (setq msgbeg (rmail-msgbeg msgnum))
3051 (setq msgend (rmail-msgend msgnum))
3052
3053 ;; Find which header this locus is in,
3054 ;; or if it's in the message body,
3055 ;; and the line-based position within that.
3056 (goto-char msgbeg)
3057 (let ((header-end msgend))
3058 (if (search-forward "\n\n" nil t)
3059 (setq header-end (point)))
3060 (if (>= pos header-end)
3061 (setq line-number-within
3062 (count-lines header-end pos))
3063 (goto-char pos)
3064 (unless (looking-at "^[^ \t]")
3065 (re-search-backward "^[^ \t]"))
3066 (looking-at "[^:\n]*[:\n]")
3067 (setq header-field (match-string 0)
3068 line-number-within (count-lines (point) pos))))))
3069
3070 ;; Display the right message.
3071 (rmail-show-message msgnum)
3072
3073 ;; Move to the right position within the displayed message.
3074 (if header-field
3075 (re-search-forward (concat "^" (regexp-quote header-field)) nil t)
3076 (search-forward "\n\n" nil t))
3077 (forward-line line-number-within)
3078 (forward-char column)))
3079
3080(defun rmail-what-message (&optional pos)
3081 "Return message number POS (or point) is in."
3024 (let* ((high rmail-total-messages) 3082 (let* ((high rmail-total-messages)
3025 (mid (/ high 2)) 3083 (mid (/ high 2))
3026 (low 1) 3084 (low 1)
3027 (where (with-current-buffer (if (rmail-buffers-swapped-p) 3085 (where (or pos
3028 rmail-view-buffer 3086 (with-current-buffer (if (rmail-buffers-swapped-p)
3029 (current-buffer)) 3087 rmail-view-buffer
3030 (point)))) 3088 (current-buffer))
3089 (point)))))
3031 (while (> (- high low) 1) 3090 (while (> (- high low) 1)
3032 (if (>= where (rmail-msgbeg mid)) 3091 (if (>= where (rmail-msgbeg mid))
3033 (setq low mid) 3092 (setq low mid)