(woman-mode-line-format): Delete constant.
[bpt/emacs.git] / lisp / mail / rmailsum.el
index c3d686f..9c64712 100644 (file)
@@ -42,7 +42,7 @@
 
 ;;;###autoload
 (defcustom rmail-summary-line-count-flag t
-  "*Non-nil if Rmail summary should show the number of lines in each message."
+  "*Non-nil means Rmail summary should show the number of lines in each message."
   :type 'boolean
   :group 'rmail-summary)
 
@@ -51,7 +51,7 @@
     ("^.....-.*" . font-lock-type-face)                                ; Unread.
     ;; Neither of the below will be highlighted if either of the above are:
     ("^.....[^D-] \\(......\\)" 1 font-lock-keyword-face)      ; Date.
-    ("{ \\([^\n}]+\\),}" 1 font-lock-comment-face))            ; Labels.
+    ("{ \\([^\n}]+\\) }" 1 font-lock-comment-face))            ; Labels.
   "Additional expressions to highlight in Rmail Summary mode.")
 
 ;; Entry points for making a summary buffer.
@@ -119,7 +119,7 @@ Emacs will list the header line in the RMAIL-summary."
 (defun rmail-summary-by-topic (subject &optional whole-message)
   "Display a summary of all messages with the given SUBJECT.
 Normally checks the Subject field of headers;
-but if WHOLE-MESSAGE is non-nil (prefix arg given), 
+but if WHOLE-MESSAGE is non-nil (prefix arg given),
  look in the whole message.
 SUBJECT is a string of regexps separated by commas."
   (interactive "sTopics to summarize by: \nP")
@@ -300,8 +300,12 @@ By default, `identity' is set."
                 ""
               (concat "{"
                       (buffer-substring (point)
-                                        (progn (end-of-line) (point)))
-                      "} ")))))
+                                        (progn (end-of-line)
+                                               (backward-char)
+                                               (if (looking-at ",")
+                                                   (point)
+                                                 (1+ (point)))))
+                      " } ")))))
         (line
          (progn
            (forward-line 1)
@@ -356,7 +360,7 @@ are used to exclude yourself as correspondent.
 
 Usually you don't have to set this variable, except if you collect mails
 sent by you under different user names.
-Then it should be a regexp matching your mail adresses.
+Then it should be a regexp matching your mail addresses.
 
 Setting this variable has an effect only before reading a mail."
   :type '(choice (const :tag "None" nil) regexp)
@@ -371,17 +375,17 @@ Setting this variable has an effect only before reading a mail."
              (cond ((re-search-forward "\\([^0-9:]\\)\\([0-3]?[0-9]\\)\\([- \t_]+\\)\\([adfjmnos][aceopu][bcglnprtvy]\\)"
                      (save-excursion (end-of-line) (point)) t)
                     (format "%2d-%3s"
-                            (string-to-int (buffer-substring
-                                            (match-beginning 2)
-                                            (match-end 2)))
+                            (string-to-number (buffer-substring
+                                                (match-beginning 2)
+                                                (match-end 2)))
                             (buffer-substring
                              (match-beginning 4) (match-end 4))))
                    ((re-search-forward "\\([^a-z]\\)\\([adfjmnos][acepou][bcglnprtvy]\\)\\([-a-z \t_]*\\)\\([0-9][0-9]?\\)"
                      (save-excursion (end-of-line) (point)) t)
                     (format "%2d-%3s"
-                            (string-to-int (buffer-substring
-                                            (match-beginning 4)
-                                            (match-end 4)))
+                            (string-to-number (buffer-substring
+                                                (match-beginning 4)
+                                                (match-end 4)))
                             (buffer-substring
                              (match-beginning 2) (match-end 2))))
                    ((re-search-forward "\\(19\\|20\\)\\([0-9][0-9]\\)-\\([01][0-9]\\)-\\([0-3][0-9]\\)"
@@ -396,49 +400,52 @@ Setting this variable has an effect only before reading a mail."
                    (t "??????"))))
          "  "
          (save-excursion
-           (if (not (re-search-forward "^From:[ \t]*" nil t))
-               "                         "
-             (let* ((from (mail-strip-quoted-names
-                           (buffer-substring
-                            (1- (point))
-                            ;; Get all the lines of the From field
-                            ;; so that we get a whole comment if there is one,
-                            ;; so that mail-strip-quoted-names can discard it.
-                            (let ((opoint (point)))
-                              (while (progn (forward-line 1)
-                                            (looking-at "[ \t]")))
-                              ;; Back up over newline, then trailing spaces or tabs
-                              (forward-char -1)
-                              (skip-chars-backward " \t")
-                              (point)))))
-                     len mch lo)
-               (if (string-match 
-                    (or rmail-user-mail-address-regexp 
-                        (concat "^\\("
-                                (regexp-quote (user-login-name))
-                                "\\($\\|@\\)\\|"
-                                (regexp-quote
-                                 ;; Don't lose if run from init file
-                                 ;; where user-mail-address is not
-                                 ;; set yet.
-                                 (or user-mail-address
-                                     (concat (user-login-name) "@"
-                                             (or mail-host-address
-                                                 (system-name)))))
-                                "\\>\\)"))
-                    from)
-                   (save-excursion
-                     (goto-char (point-min))
-                     (if (not (re-search-forward "^To:[ \t]*" nil t))
-                         nil
-                       (setq from
-                             (concat "to: "
-                                     (mail-strip-quoted-names
-                                      (buffer-substring
-                                       (point)
-                                       (progn (end-of-line)
-                                              (skip-chars-backward " \t")
-                                              (point)))))))))
+           (let* ((from (and (re-search-forward "^From:[ \t]*" nil t)
+                             (mail-strip-quoted-names
+                              (buffer-substring
+                               (1- (point))
+                               ;; Get all the lines of the From field
+                               ;; so that we get a whole comment if there is one,
+                               ;; so that mail-strip-quoted-names can discard it.
+                               (let ((opoint (point)))
+                                 (while (progn (forward-line 1)
+                                               (looking-at "[ \t]")))
+                                 ;; Back up over newline, then trailing spaces or tabs
+                                 (forward-char -1)
+                                 (skip-chars-backward " \t")
+                                 (point))))))
+                  len mch lo)
+             (if (or (null from)
+                     (string-match
+                      (or rmail-user-mail-address-regexp
+                          (concat "^\\("
+                                  (regexp-quote (user-login-name))
+                                  "\\($\\|@\\)\\|"
+                                  (regexp-quote
+                                   ;; Don't lose if run from init file
+                                   ;; where user-mail-address is not
+                                   ;; set yet.
+                                   (or user-mail-address
+                                       (concat (user-login-name) "@"
+                                               (or mail-host-address
+                                                   (system-name)))))
+                                  "\\>\\)"))
+                      from))
+                 ;; No From field, or it's this user.
+                 (save-excursion
+                   (goto-char (point-min))
+                   (if (not (re-search-forward "^To:[ \t]*" nil t))
+                       nil
+                     (setq from
+                           (concat "to: "
+                                   (mail-strip-quoted-names
+                                    (buffer-substring
+                                     (point)
+                                     (progn (end-of-line)
+                                            (skip-chars-backward " \t")
+                                            (point)))))))))
+             (if (null from)
+                 "                         "
                (setq len (length from))
                (setq mch (string-match "[@%]" from))
                (format "%25s"
@@ -513,15 +520,17 @@ messages, or backward if NUMBER is negative."
                                      non-del-msg-found)))
       (setq count (1- count))))
   (beginning-of-line)
-  (display-buffer rmail-view-buffer)
-  )
+  (display-buffer rmail-view-buffer))
 
 (defun rmail-summary-previous-msg (&optional number)
+  "Display previous non-deleted msg from rmail file.
+With optional prefix argument NUMBER, moves backward this number of
+non-deleted messages."
   (interactive "p")
   (rmail-summary-next-msg (- (if number number 1))))
 
 (defun rmail-summary-next-labeled-message (n labels)
-  "Show next message with LABEL.  Defaults to last labels used.
+  "Show next message with LABELS.  Defaults to last labels used.
 With prefix argument N moves forward N messages with these labels."
   (interactive "p\nsMove to next msg with labels: ")
   (let (msg)
@@ -532,7 +541,7 @@ With prefix argument N moves forward N messages with these labels."
     (rmail-summary-goto-msg msg)))
 
 (defun rmail-summary-previous-labeled-message (n labels)
-  "Show previous message with LABEL.  Defaults to last labels used.
+  "Show previous message with LABELS.  Defaults to last labels used.
 With prefix argument N moves backward N messages with these labels."
   (interactive "p\nsMove to previous msg with labels: ")
   (let (msg)
@@ -571,7 +580,7 @@ If N is negative, go backwards."
            ;; Advance thru summary.
            (forward-line (if forward 1 -1))
            ;; Get msg number of this line.
-           (setq i (string-to-int
+           (setq i (string-to-number
                     (buffer-substring (point)
                                       (min (point-max) (+ 6 (point))))))
            ;; See if that msg has desired subject.
@@ -751,7 +760,7 @@ Commands for sorting the summary:
   (make-local-variable 'font-lock-defaults)
   (setq font-lock-defaults '(rmail-summary-font-lock-keywords t))
   (rmail-summary-enable)
-  (run-hooks 'rmail-summary-mode-hook))
+  (run-mode-hooks 'rmail-summary-mode-hook))
 
 ;; Summary features need to be disabled during edit mode.
 (defun rmail-summary-disable ()
@@ -782,10 +791,10 @@ Search, the `unseen' attribute is restored.")
          (forward-line -1))
       (beginning-of-line)
       (skip-chars-forward " ")
-      (let ((msg-num (string-to-int (buffer-substring
-                                    (point)
-                                    (progn (skip-chars-forward "0-9")
-                                           (point))))))
+      (let ((msg-num (string-to-number (buffer-substring
+                                        (point)
+                                        (progn (skip-chars-forward "0-9")
+                                               (point))))))
        ;; Always leave `unseen' removed
        ;; if we get out of isearch mode.
        ;; Don't let a subsequent isearch restore that `unseen'.
@@ -1052,7 +1061,7 @@ If SKIP-RMAIL, don't do anything to the Rmail buffer."
         (buf rmail-buffer)
         (cur (point))
         message-not-found
-        (curmsg (string-to-int
+        (curmsg (string-to-number
                  (buffer-substring (point)
                                    (min (point-max) (+ 6 (point))))))
         (total (save-excursion (set-buffer buf) rmail-total-messages)))
@@ -1065,7 +1074,8 @@ If SKIP-RMAIL, don't do anything to the Rmail buffer."
       (if (< n 1)
          (progn (message "No preceding message")
                 (setq n 1)))
-      (if (> n total)
+      (if (and (> n total)
+              (> total 0))
          (progn (message "No following message")
                 (goto-char (point-max))
                 (rmail-summary-goto-msg nil nowarn skip-rmail)))
@@ -1405,7 +1415,7 @@ Completion is performed over known labels when reading."
 ;;;; *** Rmail Summary Mailing Commands ***
 
 (defun rmail-summary-override-mail-send-and-exit ()
-  "Replace bindings to 'mail-send-and-exit with 'rmail-summary-send-and-exit"
+  "Replace bindings to `mail-send-and-exit' with `rmail-summary-send-and-exit'."
   (use-local-map (copy-keymap (current-local-map)))
   (dolist (key (where-is-internal 'mail-send-and-exit))
     (define-key (current-local-map) key 'rmail-summary-send-and-exit)))
@@ -1475,7 +1485,7 @@ see the documentation of `rmail-resend'."
     (rmail-summary-override-mail-send-and-exit)))
 
 (defun rmail-summary-resend ()
-  "Resend current message using 'rmail-resend'."
+  "Resend current message using `rmail-resend'."
   (interactive)
   (save-excursion
     (let ((window (get-buffer-window rmail-buffer)))
@@ -1499,12 +1509,12 @@ starting with the current one.  Deleted messages are skipped and don't count."
          (list (rmail-output-read-rmail-file-name)
                (prefix-numeric-value current-prefix-arg))))
   (let ((i 0) prev-msg)
-    (while 
+    (while
        (and (< i n)
             (progn (rmail-summary-goto-msg)
                    (not (eq prev-msg
                             (setq prev-msg
-                                  (with-current-buffer rmail-buffer 
+                                  (with-current-buffer rmail-buffer
                                     rmail-current-message))))))
       (setq i (1+ i))
       (with-current-buffer rmail-buffer
@@ -1524,8 +1534,14 @@ starting with the current one.  Deleted messages are skipped and don't count."
    (progn (require 'rmailout)
          (list (rmail-output-read-file-name)
                (prefix-numeric-value current-prefix-arg))))
-  (let ((i 0))
-    (while (< i n)
+  (let ((i 0) prev-msg)
+    (while
+       (and (< i n)
+            (progn (rmail-summary-goto-msg)
+                   (not (eq prev-msg
+                            (setq prev-msg
+                                  (with-current-buffer rmail-buffer
+                                    rmail-current-message))))))
       (setq i (1+ i))
       (with-current-buffer rmail-buffer
        (let ((rmail-delete-after-output nil))
@@ -1553,13 +1569,13 @@ The variables `rmail-secondary-file-directory' and
     (if files
        (progn
          (define-key rmail-summary-mode-map [menu-bar classify input-menu]
-           (cons "Input Rmail File" 
-                 (rmail-list-to-menu "Input Rmail File" 
+           (cons "Input Rmail File"
+                 (rmail-list-to-menu "Input Rmail File"
                                      files
                                      'rmail-summary-input)))
          (define-key rmail-summary-mode-map [menu-bar classify output-menu]
-           (cons "Output Rmail File" 
-                 (rmail-list-to-menu "Output Rmail File" 
+           (cons "Output Rmail File"
+                 (rmail-list-to-menu "Output Rmail File"
                                      files
                                      'rmail-summary-output-to-rmail-file))))
       (define-key rmail-summary-mode-map [menu-bar classify input-menu]
@@ -1639,4 +1655,5 @@ KEYWORDS is a comma-separated list of labels."
 
 (provide 'rmailsum)
 
+;;; arch-tag: 556079ee-75c1-47f5-9884-2e0a0bc6c5a1
 ;;; rmailsum.el ends here