Importing Pterodactyl Gnus v0.68.
[elisp/gnus.git-] / lisp / message.el
index 32d909f..fb5e183 100644 (file)
@@ -879,8 +879,12 @@ The cdr of ech entry is a function for applying the face to a region.")
   "Coding system to encode outgoing mail.")
 
 (defvar message-draft-coding-system 
-  (if (string-match "XEmacs\\|Lucid" emacs-version)
-      'escape-quoted 'emacs-mule)
+  (cond 
+   ((not (fboundp 'coding-system-p)) nil)
+   ((coding-system-p 'emacs-mule) 'emacs-mule)
+   ((coding-system-p 'escape-quoted) 'escape-quoted)
+   ((coding-system-p 'no-conversion) 'no-conversion)
+   (t nil))
   "Coding system to compose mail.")
 
 (defvar message-default-charset 'iso-8859-1
@@ -1303,6 +1307,7 @@ Point is left at the beginning of the narrowed-to region."
   (define-key message-mode-map "\C-c\C-y" 'message-yank-original)
   (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message)
   (define-key message-mode-map "\C-c\C-w" 'message-insert-signature)
+  (define-key message-mode-map "\C-c\M-h" 'message-insert-headers)
   (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body)
   (define-key message-mode-map "\C-c\C-o" 'message-sort-headers)
   (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer)
@@ -1317,8 +1322,8 @@ Point is left at the beginning of the narrowed-to region."
   (define-key message-mode-map "\C-c\C-z" 'message-kill-to-signature)
   (define-key message-mode-map "\M-\r" 'message-newline-and-reformat)
 
-  (define-key message-mode-map "\C-c\C-a" 'message-insert-mime-part)
-  (define-key message-mode-map "\C-c\C-m\C-a" 'message-insert-mime-part)
+  (define-key message-mode-map "\C-c\C-a" 'message-mime-attach-file)
+  (define-key message-mode-map "\C-c\C-m\C-a" 'message-mime-attach-file)
   (define-key message-mode-map "\C-c\C-m\C-e" 'message-mime-insert-external)
   (define-key message-mode-map "\C-c\C-m\C-q" 'mml-quote-region)
   
@@ -2011,7 +2016,6 @@ the user from the mailer."
   (let ((inhibit-read-only t))
     (put-text-property (point-min) (point-max) 'read-only nil))
   (message-fix-before-sending)
-  (message-encode-message-body)
   (run-hooks 'message-send-hook)
   (message "Sending...")
   (let ((alist message-send-method-alist)
@@ -2032,7 +2036,8 @@ the user from the mailer."
       (message-do-fcc)
       ;;(when (fboundp 'mail-hist-put-headers-into-history)
       ;; (mail-hist-put-headers-into-history))
-      (run-hooks 'message-sent-hook)
+      (save-excursion
+       (run-hooks 'message-sent-hook))
       (message "Sending...done")
       ;; Mark the buffer as unmodified and delete auto-save.
       (set-buffer-modified-p nil)
@@ -2110,6 +2115,7 @@ the user from the mailer."
       (mail-encode-encoded-word-buffer)
       ;; Let the user do all of the above.
       (run-hooks 'message-header-hook))
+    (message-encode-message-body)
     (unwind-protect
        (save-excursion
          (set-buffer tembuf)
@@ -2283,6 +2289,7 @@ to find out how to use this."
        (mail-encode-encoded-word-buffer)
        ;; Let the user do all of the above.
        (run-hooks 'message-header-hook))
+      (message-encode-message-body)
       (message-cleanup-headers)
       (if (not (message-check-news-syntax))
          nil
@@ -3339,6 +3346,23 @@ Headers already prepared in the buffer are not modified."
     (nndraft-request-expire-articles
      (list message-draft-article) "drafts" nil t)))
 
+(defun message-insert-headers ()
+  "Generate the headers for the article."
+  (interactive)
+  (save-excursion
+    (save-restriction
+      (message-narrow-to-headers)
+      (when (message-news-p)
+       (message-generate-headers
+        (delq 'Lines
+              (delq 'Subject
+                    (copy-sequence message-required-news-headers)))))
+      (when (message-mail-p)
+       (message-generate-headers
+        (delq 'Lines
+              (delq 'Subject
+                    (copy-sequence message-required-mail-headers))))))))
+
 \f
 
 ;;;
@@ -4127,7 +4151,7 @@ regexp varstr."
 ;; I really think this function should be renamed.  It is only useful
 ;; for inserting file attachments.
 
-(defun message-insert-mime-part (file type description)
+(defun message-mime-attach-file (file type description)
   "Attach a file to the outgoing MIME message.
 The file is not inserted or encoded until you send the message with
 `\\[message-send-and-exit]' or `\\[message-send]'.