changeset 101594:76012a3bc99d

(rmail-message-recipients-p-1): Don't bother starting from the beginning, since mail-fetch-field does not care. (rmail-create-summary-line): Fix unseen handling. (Bug#2089) (rmail-get-summary-status): New name for old rmail-get-summary-labels. (rmail-get-summary-labels): New function. Returns labels rather than status (edited, etc). (rmail-create-summary): Insert an extra space after the status flags, for consistency with old rmail, and with current rmail-summary-font-lock-keywords.
author Glenn Morris <rgm@gnu.org>
date Wed, 28 Jan 2009 02:49:40 +0000
parents 84cb9ad20593
children 93295628737c
files lisp/mail/rmailsum.el
diffstat 1 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmailsum.el	Wed Jan 28 02:17:29 2009 +0000
+++ b/lisp/mail/rmailsum.el	Wed Jan 28 02:49:40 2009 +0000
@@ -111,7 +111,8 @@
 			  recipients primary-only))
 
 (defun rmail-message-recipients-p-1 (recipients &optional primary-only)
-  (narrow-to-region (point) (save-excursion (search-forward "\n\n") (point)))
+  ;; mail-fetch-field does not care where it starts from.
+  (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
   (or (string-match recipients (or (mail-fetch-field "To") ""))
       (string-match recipients (or (mail-fetch-field "From") ""))
       (if (not primary-only)
@@ -138,6 +139,7 @@
   (rmail-apply-in-message msg 'rmail-message-regexp-p-1 msg regexp))
 
 (defun rmail-message-regexp-p-1 (msg regexp)
+  ;; Search functions can expect to start from the beginning.
   (narrow-to-region (point) (save-excursion (search-forward "\n\n") (point)))
   (if rmail-enable-mime
       (if rmail-search-mime-header-function
@@ -361,8 +363,9 @@
   (let ((beg (rmail-msgbeg msgnum))
 	(end (rmail-msgend msgnum))
 	(deleted (rmail-message-deleted-p msgnum))
-	(unseen (rmail-message-unseen-p msgnum))
-	lines)
+	;; Does not work (swapped?)
+;;;	(unseen (rmail-message-unseen-p msgnum))
+	unseen lines)
     (save-excursion
       ;; Switch to the buffer that has the whole mbox text.
       (if (rmail-buffers-swapped-p)
@@ -377,12 +380,24 @@
 	(if (search-forward "\n\n" end t)
 	    (save-restriction
 	      (narrow-to-region beg (point))
+	      ;; Replace rmail-message-unseen-p from above.
+	      (goto-char beg)
+	      (setq unseen (and (search-forward
+				 (concat rmail-attribute-header ": ") nil t)
+				(looking-at "......U")))
 	      ;; Generate a status line from the message.
 	      (rmail-create-summary msgnum deleted unseen lines))
 	  (rmail-error-bad-format msgnum))))))
 
-(defun rmail-get-summary-labels ()
-  "Return a coded string wrapped in curly braces denoting the status labels.
+;; FIXME this is now unused.
+;; The intention was to display in the summary something like {E}
+;; for an edited messaged, similarly for answered, etc.
+;; But that conflicts with the previous rmail usage, where
+;; any user-defined { labels } occupied this space.
+;; So whilst it would be nice to have this information in the summary,
+;; it would need to go somewhere else.
+(defun rmail-get-summary-status ()
+  "Return a coded string wrapped in curly braces denoting the status.
 
 The current buffer must already be narrowed to the message headers for
 the message being processed."
@@ -404,6 +419,14 @@
       (setq result (concat "{" result "}")))
     result))
 
+(defun rmail-get-summary-labels ()
+  "Return a string wrapped in curly braces with the current message labels.
+Returns nil if there are no labels.  The current buffer must
+already be narrowed to the message headers for the message being
+processed."
+  (let ((labels (mail-fetch-field rmail-keyword-header)))
+    (if labels (format "{ %s } " labels))))
+
 (defun rmail-create-summary (msgnum deleted unseen lines)
   "Return the summary line for message MSGNUM.
 The current buffer should already be narrowed to the header for that message.
@@ -431,7 +454,7 @@
 		  (deleted ?D)
 		  (unseen ?-)
 		  (t ? ))
-	  prefix (format "%5d%c" msgnum status)
+	  prefix (format "%5d%c " msgnum status)
 	  basic-start (car line)
 	  basic-end (cadr line))
     (funcall rmail-summary-line-decoder