2001-08-19 Simon Josefsson <jas@extundo.com>
[gnus] / lisp / message.el
index 71aabe7..e08d4ff 100644 (file)
@@ -40,6 +40,7 @@
     (require 'mail-abbrevs))
 (require 'mail-parse)
 (require 'mml)
+(require 'rfc822)
 
 (defgroup message '((user-mail-address custom-variable)
                    (user-full-name custom-variable))
@@ -190,7 +191,7 @@ header, remove it from this list."
   '(From Subject Date (optional . In-Reply-To) Message-ID Lines
         (optional . User-Agent))
   "*Headers to be generated or prompted for when mailing a message.
-RFC822 required that From, Date, To, Subject and Message-ID be
+It is recommended that From, Date, To, Subject and Message-ID be
 included.  Organization, Lines and User-Agent are optional."
   :group 'message-mail
   :group 'message-headers
@@ -540,7 +541,7 @@ See also `message-yank-cited-prefix'."
   :group 'message-insertion)
 
 (defcustom message-yank-cited-prefix ">"
-  "*Prefix inserted on cited lines of yanked messages.
+  "*Prefix inserted on cited or empty lines of yanked messages.
 Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
 See also `message-yank-prefix'."
   :type 'string
@@ -1114,6 +1115,9 @@ no, only reply back to the author."
 (defvar message-send-mail-real-function nil
   "Internal send mail function.")
 
+(defvar message-bogus-system-names "^localhost\\."
+  "The regexp of bogus system names.")
+
 (eval-and-compile
   (autoload 'message-setup-toolbar "messagexmas")
   (autoload 'mh-new-draft-name "mh-comp")
@@ -1512,14 +1516,11 @@ Point is left at the beginning of the narrowed-to region."
     ["Spellcheck" ispell-message
      ,@(if (featurep 'xemacs) '(t)
         '(:help "Spellcheck this message"))]
-    ["Attach file as MIME" mml-attach-file
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Attach a file at point"))]
     "----"
     ["Send Message" message-send-and-exit
      ,@(if (featurep 'xemacs) '(t)
         '(:help "Send this message"))]
-    ["Abort Message" message-dont-send
+    ["Postpone Message" message-dont-send
      ,@(if (featurep 'xemacs) '(t)
         '(:help "File this draft message and exit"))]
     ["Kill Message" message-kill-buffer
@@ -1916,8 +1917,10 @@ Prefix arg means justify as well."
 (defun message-fill-paragraph (&optional arg)
   "Like `fill-paragraph'."
   (interactive (list (if current-prefix-arg 'full)))
-  (message-newline-and-reformat arg t)
-  t)
+  (if (and (boundp 'filladapt-mode) filladapt-mode)
+      nil
+    (message-newline-and-reformat arg t)
+    t))
 
 (defun message-insert-signature (&optional force)
   "Insert a signature.  See documentation for variable `message-signature'."
@@ -2098,11 +2101,31 @@ However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
        (indent-rigidly start (mark t) message-indentation-spaces)
       (save-excursion
        (goto-char start)
-       (while (< (point) (mark t))
-         (if (looking-at message-cite-prefix-regexp)
+       (let (last-line)
+         ;; `last-line' describes the contents of the last line
+         ;; encountered in the loop below. nil means "empty line",
+         ;; spaces "line consisting entirely of whitespace",
+         ;; right-angle "line starts with >", quoted "quote character
+         ;; at the beginning of the line", text "the remaining cases".
+         (while (< (point) (mark t))
+           (cond
+            ((eolp) 
              (insert message-yank-cited-prefix)
-           (insert message-yank-prefix))
-         (forward-line 1))))
+             (setq last-line nil))
+            ((looking-at ">")
+             (if (memq last-line '(nil spaces right-angle quoted))
+                 (progn
+                   (insert message-yank-cited-prefix)
+                   (setq last-line 'quoted))
+               (insert message-yank-prefix)
+               (setq last-line 'right-angle)))
+            ((looking-at "\\s-+$")
+             (insert message-yank-prefix)
+             (setq last-line 'spaces))
+            (t
+             (insert message-yank-prefix)
+             (setq last-line 'text)))
+           (forward-line 1)))))
     (goto-char start)))
 
 (defun message-yank-original (&optional arg)
@@ -2711,7 +2734,8 @@ to find out how to use this."
              (cons '(valid-newsgroups . disabled)
                    message-syntax-checks)))
       (message-cleanup-headers)
-      (if (not (message-check-news-syntax))
+      (if (not (let ((message-post-method method))
+                (message-check-news-syntax)))
          nil
        (unwind-protect
            (save-excursion
@@ -2890,10 +2914,9 @@ to find out how to use this."
            (known-groups
             (mapcar (lambda (n) (gnus-group-real-name n))
                     (gnus-groups-from-server
-                     (cond ((equal gnus-post-method 'current)
-                            gnus-current-select-method)
-                           (gnus-post-method gnus-post-method)
-                           (t gnus-select-method)))))
+                     (if (message-functionp message-post-method)
+                         (funcall message-post-method)
+                       message-post-method))))
            errors)
        (while groups
         (unless (or (equal (car groups) "poster")
@@ -2989,6 +3012,14 @@ to find out how to use this."
         (message
          "Denied posting -- the From looks strange: \"%s\"." from)
         nil)
+       ((let ((addresses (rfc822-addresses from)))
+          (while (and addresses
+                      (not (eq (string-to-char (car addresses)) ?\()))
+            (setq addresses (cdr addresses)))
+          addresses)
+        (message
+         "Denied posting -- bad From address: \"%s\"." from)
+        nil)
        (t t))))
    ;; Check the Reply-To header.
    (message-check 'reply-to
@@ -3442,7 +3473,8 @@ give as trustworthy answer as possible."
   (let ((system-name (system-name))
        (user-mail (message-user-mail-address)))
     (cond
-     ((string-match "[^.]\\.[^.]" system-name)
+     ((and (string-match "[^.]\\.[^.]" system-name)
+          (not (string-match message-bogus-system-names system-name)))
       ;; `system-name' returned the right result.
       system-name)
      ;; Try `mail-host-address'.
@@ -3949,7 +3981,10 @@ than 988 characters long, and if they are not, trim them until they are."
        (setq message-draft-article
              (nndraft-request-associate-buffer "drafts"))
       (setq buffer-file-name (expand-file-name
-                             (if (eq system-type 'windows-nt)
+                             (if (memq system-type 
+                                       '(ms-dos ms-windows windows-nt 
+                                                cygwin32 win32 w32 
+                                                mswindows))
                                  "message"
                                "*message*")
                              message-auto-save-directory))
@@ -4110,7 +4145,7 @@ responses here are directed to other addresses.")))
        ;; Allow the user to be asked whether or not to reply to all
        ;; recipients in a wide reply.
        (if (and ccalist wide message-wide-reply-confirm-recipients
-                (not (y-or-n-p "Reply to all recipients?")))
+                (not (y-or-n-p "Reply to all recipients? ")))
            (setq follow-to (delq (assoc 'Cc follow-to) follow-to)))))
     follow-to))
 
@@ -4798,15 +4833,15 @@ which specify the range to operate on."
   "Alist of (RE . FUN).  Use FUN for completion on header lines matching RE.")
 
 (defun message-tab ()
-  "Expand group names in Newsgroups and Followup-To headers.
-Do a `tab-to-tab-stop' if not in those headers."
+  "Complete names according to `message-completion-alist'.
+Do an `indent-relative' if not in those headers."
   (interactive)
   (let ((alist message-completion-alist))
     (while (and alist
                (let ((mail-abbrev-mode-regexp (caar alist)))
                  (not (mail-abbrev-in-expansion-header-p))))
       (setq alist (cdr alist)))
-    (funcall (or (cdar alist) (default-value 'indent-line-function)))))
+    (funcall (or (cdar alist) 'indent-relative))))
 
 (defun message-expand-group ()
   "Expand the group name under point."