Merge from emacs--rel--22
[bpt/emacs.git] / lisp / mail / rmailsum.el
index 497f2f7..9c9ba7a 100644 (file)
@@ -1,17 +1,17 @@
 ;;; rmailsum.el --- make summary buffers for the mail reader
 
 ;; Copyright (C) 1985, 1993, 1994, 1995, 1996, 2000, 2001, 2002, 2003,
-;;   2004, 2005 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -132,7 +130,15 @@ Normally checks the Subject field of headers;
 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")
+  (interactive
+   (let* ((subject (with-current-buffer rmail-buffer
+                    (rmail-current-subject)))
+         (subject-re (with-current-buffer rmail-buffer
+                       (rmail-current-subject-regexp)))
+         (prompt (concat "Topics to summarize by (regexp"
+                         (if subject ", default current subject" "")
+                         "): ")))
+     (list (read-string prompt nil nil subject) current-prefix-arg)))
   (rmail-new-summary
    (concat "about " subject)
    (list 'rmail-summary-by-topic subject whole-message)
@@ -280,12 +286,14 @@ nil for FUNCTION means all messages."
                    (if (zerop (% rmail-new-summary-line-count 10))
                        (message "Computing summary lines...%d"
                                 rmail-new-summary-line-count))
-                   (rmail-make-summary-line-1 msg)))))
+                   (rmail-make-summary-line-1 msg))))
+       delpos)
     ;; Fix up the part of the summary that says "deleted" or "unseen".
-    (aset line 5
-         (if (rmail-message-deleted-p msg) ?\D
+    (string-match "[0-9]+" line)
+    (aset line (match-end 0)
+         (if (rmail-message-deleted-p msg) ?D
            (if (= ?0 (char-after (+ 3 (rmail-msgbeg msg))))
-               ?\- ?\ )))
+               ?- ?\s)))
     line))
 
 ;;;###autoload
@@ -324,9 +332,8 @@ By default, `identity' is set."
            (if (looking-at "Summary-line: ")
                (progn
                  (goto-char (match-end 0))
-                 (setq line
-                       (buffer-substring (point)
-                                         (progn (forward-line 1) (point)))))))))
+                 (buffer-substring (point)
+                                   (progn (forward-line 1) (point))))))))
     ;; Obsolete status lines lacking a # should be flushed.
     (and line
         (not (string-match "#" line))
@@ -528,7 +535,7 @@ messages, or backward if NUMBER is negative."
        (search (if (> number 0) 're-search-forward 're-search-backward))
        (non-del-msg-found nil))
     (while (and (> count 0) (setq non-del-msg-found
-                                 (or (funcall search "^....[^D]" nil t)
+                                 (or (funcall search "^.....[^D]" nil t)
                                      non-del-msg-found)))
       (setq count (1- count))))
   (beginning-of-line)
@@ -568,17 +575,11 @@ With prefix argument N moves backward N messages with these labels."
 With prefix argument N, do this N times.
 If N is negative, go backwards."
   (interactive "p")
-  (let (subject search-regexp  i found
-       (forward (> n 0)))
-    (save-excursion
-      (set-buffer rmail-buffer)
-      (setq subject (mail-fetch-field "Subject"))
-      (setq i rmail-current-message))
-    (if (string-match "Re:[ \t]*" subject)
-       (setq subject (substring subject (match-end 0))))
-    (setq search-regexp (concat "^Subject: *\\(Re: *\\)?"
-                               (regexp-quote subject)
-                               "\n"))
+  (let ((forward (> n 0))
+       search-regexp i found)
+    (with-current-buffer rmail-buffer
+      (setq search-regexp (rmail-current-subject-regexp)
+           i rmail-current-message))
     (save-excursion
       (while (and (/= n 0)
                  (if forward
@@ -853,6 +854,15 @@ Search, the `unseen' attribute is restored.")
                      (set-buffer rmail-buffer)
                      (rmail-show-message msg-num t))))))
        (rmail-summary-update-highlight nil)))))
+
+(defun rmail-summary-save-buffer ()
+  "Save the buffer associated with this RMAIL summary."
+  (interactive)
+  (save-window-excursion
+    (save-excursion
+      (switch-to-buffer rmail-buffer)
+      (save-buffer))))
+
 \f
 (if rmail-summary-mode-map
     nil
@@ -922,6 +932,7 @@ Search, the `unseen' attribute is restored.")
     'rmail-summary-sort-by-lines)
   (define-key rmail-summary-mode-map "\C-c\C-s\C-k"
     'rmail-summary-sort-by-labels)
+  (define-key rmail-summary-mode-map "\C-x\C-s" 'rmail-summary-save-buffer)
   )
 \f
 ;;; Menu bar bindings.
@@ -1310,6 +1321,13 @@ argument says to read a file name and use that file as the inbox."
     (end-of-buffer))
   (forward-line -1))
 
+(declare-function rmail-abort-edit "rmailedit" ())
+(declare-function rmail-cease-edit "rmailedit"())
+(declare-function rmail-set-label "rmailkwd" (l state &optional n))
+(declare-function rmail-output-read-file-name "rmailout" ())
+(declare-function rmail-output-read-rmail-file-name  "rmailout" ())
+(declare-function mail-send-and-exit "sendmail" (&optional arg))
+
 (defvar rmail-summary-edit-map nil)
 (if rmail-summary-edit-map
     nil
@@ -1684,5 +1702,5 @@ KEYWORDS is a comma-separated list of labels."
 
 (provide 'rmailsum)
 
-;;; arch-tag: 556079ee-75c1-47f5-9884-2e0a0bc6c5a1
+;; arch-tag: 556079ee-75c1-47f5-9884-2e0a0bc6c5a1
 ;;; rmailsum.el ends here