2000-11-17 08:02 ShengHuo ZHU <zsh@cs.rochester.edu>
[gnus] / lisp / message.el
index 934a4a7..cbcfabb 100644 (file)
@@ -33,6 +33,7 @@
 (eval-when-compile
   (require 'cl)
   (defvar gnus-list-identifiers))      ; gnus-sum is required where necessary
+
 (require 'mailheader)
 (require 'nnheader)
 ;; This is apparently necessary even though things are autoloaded:
@@ -330,6 +331,13 @@ The provided functions are:
   :group 'message-insertion
   :type 'regexp)
 
+(defcustom message-cite-prefix-regexp
+  ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
+  "\\([ \t]*\\(\\w\\|[-_.]\\)+>+\\|[ \t]*[]>»|:}+]\\)+"
+  "*Regexp matching the longest possible citation prefix on a line."
+  :group 'message-insertion
+  :type 'regexp)
+
 (defcustom message-cancel-message "I am canceling my own article.\n"
   "Message to be inserted in the cancel message."
   :group 'message-interface
@@ -819,9 +827,7 @@ Defaults to `text-mode-abbrev-table'.")
   :group 'message-faces)
 
 (defvar message-font-lock-keywords
-  (let* ((cite-prefix "A-Za-z")
-        (cite-suffix (concat cite-prefix "0-9_.@-"))
-        (content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)"))
+  (let ((content "[ \t]*\\(.+\\(\n[ \t].*\\)*\\)\n?"))
     `((,(concat "^\\([Tt]o:\\)" content)
        (1 'message-header-name-face)
        (2 'message-header-to-face nil t))
@@ -845,9 +851,7 @@ Defaults to `text-mode-abbrev-table'.")
            `((,(concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
               1 'message-separator-face))
          nil)
-      (,(concat "^[ \t]*"
-               "\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
-               "[:>|}].*")
+      (,(concat "^\\(" message-cite-prefix-regexp "\\).*")
        (0 'message-cited-text-face))
       ("<#/?\\(multipart\\|part\\|external\\|mml\\).*>"
        (0 'message-mml-face))))
@@ -1518,7 +1522,7 @@ M-RET    message-newline-and-reformat (break the line and reformat)."
          (concat
           "[ \t]*"                      ; possible initial space
           "\\(\\(" (regexp-quote message-yank-prefix) "\\|" ; user's prefix
-          "\\w+>\\|"                    ; supercite-style prefix
+          "\\(\\w\\|[-_.]\\)+>\\|"      ; supercite-style prefix
           "[|:>]"                       ; standard prefix
           "\\)[ \t]*\\)+")))            ; possible space after each prefix
     (setq paragraph-start
@@ -1710,14 +1714,11 @@ With the prefix argument FORCE, insert the header anyway."
 (defun message-newline-and-reformat ()
   "Insert four newlines, and then reformat if inside quoted text."
   (interactive)
-  (let ((prefix "[]>»|:}+ \t]*")
-       (supercite-thing "[-._a-zA-Z0-9]*[>]+[ \t]*")
-       quoted point)
+  (let (quoted point)
     (unless (bolp)
       (save-excursion
        (beginning-of-line)
-       (when (looking-at (concat prefix
-                                 supercite-thing))
+       (when (looking-at (concat message-cite-prefix-regexp "[ \t]*"))
          (setq quoted (match-string 0))))
       (insert "\n"))
     (setq point (point))
@@ -2129,6 +2130,7 @@ It should typically alter the sending method in some way or other."
        (success t)
        elem sent
        (message-options message-options))
+    (message-options-set-recipient)
     (while (and success
                (setq elem (pop alist)))
       (when (funcall (cadr elem))
@@ -3705,11 +3707,13 @@ OTHER-HEADERS is an alist of header/value pairs."
                    message-use-followup-to
                    (or (not (eq message-use-followup-to 'ask))
                        (message-y-or-n-p
-                       (concat "Obey Mail-Followup-To: " mft "? ") t "\
-You should normally obey the Mail-Followup-To: header.
+                       (concat "Obey Mail-Followup-To? ") t "\
+You should normally obey the Mail-Followup-To: header.  In this
+article, it has the value of
 
-       `Mail-Followup-To: " mft "'
-directs your response to " (if (string-match "," mft)
+" mft "
+
+which directs your response to " (if (string-match "," mft)
                               "the specified addresses"
                             "that address only") ".
 
@@ -3754,7 +3758,6 @@ responses here are directed to other addresses.")))
            (push ccs follow-to)))))
     follow-to))
 
-
 ;;;###autoload
 (defun message-reply (&optional to-address wide)
   "Start editing a reply to the article in the current buffer."
@@ -4472,21 +4475,8 @@ regexp varstr."
 
 ;;; Miscellaneous functions
 
-;; stolen (and renamed) from nnheader.el
-(if (fboundp 'subst-char-in-string)
-    (defsubst message-replace-chars-in-string (string from to)
-      (subst-char-in-string from to string))
-  (defun message-replace-chars-in-string (string from to)
-    "Replace characters in STRING from FROM to TO."
-    (let ((string (substring string 0))        ;Copy string.
-         (len (length string))
-         (idx 0))
-      ;; Replace all occurrences of FROM with TO.
-      (while (< idx len)
-       (when (= (aref string idx) from)
-         (aset string idx to))
-       (setq idx (1+ idx)))
-      string)))
+(defsubst message-replace-chars-in-string (string from to)
+  (mm-subst-char-in-string from to string))
 
 ;;;
 ;;; MIME functions
@@ -4577,6 +4567,16 @@ regexp varstr."
           (push (cons symbol value) message-options))))
   value)
 
+(defun message-options-set-recipient ()
+  (save-restriction
+    (message-narrow-to-headers-or-head)
+    (message-options-set 'message-sender
+                        (mail-strip-quoted-names 
+                         (message-fetch-field "from")))
+    (message-options-set 'message-recipients
+                         (mail-strip-quoted-names 
+                          (message-fetch-field "to")))))
+
 (provide 'message)
 
 (run-hooks 'message-load-hook)