* lisp/gnus-vers.el (gnus-revision-number): Increment to 02.
[elisp/gnus.git-] / lisp / gnus-msg.el
index cdac772..a9be535 100644 (file)
@@ -142,6 +142,9 @@ See Info node `(gnus)Posting Styles'."
                                        (variable)
                                        (sexp)))))))
 
+(defvar gnus-named-posting-styles nil
+  "Alist mapping names to the user-defined posting styles.")
+
 (defcustom gnus-gcc-mark-as-read nil
   "If non-nil, automatically mark Gcc articles as read."
   :version "21.1"
@@ -351,7 +354,8 @@ Thank you for your help in stamping out bugs.
   "om" gnus-summary-mail-forward
   "op" gnus-summary-post-forward
   "Om" gnus-summary-digest-mail-forward
-  "Op" gnus-summary-digest-post-forward)
+  "Op" gnus-summary-digest-post-forward
+  "P" gnus-summary-execute-command-with-posting-style)
 
 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
   "b" gnus-summary-resend-bounced-mail
@@ -816,6 +820,9 @@ header line with the old Message-ID."
   ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
   ;; this buffer should be passed to all mail/news reply/post routines.
   (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
+  (save-excursion
+    (set-buffer gnus-article-copy)
+    (set-buffer-multibyte t))
   (let ((article-buffer (or article-buffer gnus-article-buffer))
        end beg)
     (if (not (and (get-buffer article-buffer)
@@ -832,32 +839,36 @@ header line with the old Message-ID."
            ;; Copy over the (displayed) article buffer, delete
            ;; hidden text and remove text properties.
            (widen)
-           (let ((inhibit-read-only t))
-             (copy-to-buffer gnus-article-copy (point-min) (point-max))
-             (set-buffer gnus-article-copy)
-             (when yank-string
-               (message-goto-body)
-               (delete-region (point) (point-max))
-               (insert yank-string))
-             ;; Encode bitmap smileys to ordinary text.
-             ;; Possibly, the original text might be restored.
-             (static-unless (featurep 'xemacs)
-               (when (featurep 'smiley-mule)
-                 (smiley-encode-buffer)))
-             (gnus-article-delete-text-of-type 'annotation)
-             (gnus-remove-text-with-property 'gnus-prev)
-             (gnus-remove-text-with-property 'gnus-next)
-             (gnus-remove-text-with-property 'gnus-decoration)
-             (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
-             (insert
-              (prog1
-                  (static-if (featurep 'xemacs)
-                      ;; Revome smiley extents for (possibly) XEmacs 21.1.
-                      (format "%s"
-                              (buffer-substring-no-properties (point-min)
-                                                              (point-max)))
-                    (buffer-substring-no-properties (point-min) (point-max)))
-                (erase-buffer))))
+           (copy-to-buffer gnus-article-copy (point-min) (point-max))
+           (set-buffer gnus-article-copy)
+           ;; There's invisible and intangible text in T-gnus.  Especially,
+           ;; if there is a boundary line (X-Boundary: ------------------),
+           ;; in the end of a header, it will cause a serious problem.
+           (add-text-properties (point-min) (point-max)
+                                '(invisible nil intangible nil))
+           (when yank-string
+             (message-goto-body)
+             (delete-region (point) (point-max))
+             (insert yank-string))
+           ;; Encode bitmap smileys to ordinary text.
+           ;; Possibly, the original text might be restored.
+           (static-unless (featurep 'xemacs)
+             (when (featurep 'smiley-mule)
+               (smiley-encode-buffer)))
+           (gnus-article-delete-text-of-type 'annotation)
+           (gnus-remove-text-with-property 'gnus-prev)
+           (gnus-remove-text-with-property 'gnus-next)
+           (gnus-remove-text-with-property 'gnus-decoration)
+           (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
+           (insert
+            (prog1
+                (static-if (featurep 'xemacs)
+                    ;; Revome smiley extents for (possibly) XEmacs 21.1.
+                    (format "%s"
+                            (buffer-substring-no-properties (point-min)
+                                                            (point-max)))
+                  (buffer-substring-no-properties (point-min) (point-max)))
+              (erase-buffer)))
            ;; Find the original headers.
            (set-buffer gnus-original-article-buffer)
            (goto-char (point-min))
@@ -1178,13 +1189,13 @@ If VERY-WIDE, make a very wide reply."
        (set-buffer gnus-article-buffer)
        (setq signed (memq 'signed gnus-article-wash-types))
        (setq encrypted (memq 'encrypted gnus-article-wash-types)))
-      (cond ((and gnus-message-replysign signed)
-            (mml-secure-message mml-default-sign-method 'sign))
-           ((and gnus-message-replyencrypt encrypted)
+      (cond ((and gnus-message-replyencrypt encrypted)
             (mml-secure-message mml-default-encrypt-method
                                 (if gnus-message-replysignencrypted
                                     'signencrypt
-                                  'encrypt)))))))
+                                  'encrypt)))
+           ((and gnus-message-replysign signed)
+            (mml-secure-message mml-default-sign-method 'sign))))))
 
 (defun gnus-summary-reply-with-original (n &optional wide)
   "Start composing a reply mail to the current message.
@@ -1923,6 +1934,16 @@ this is a reply."
                 (t
                  ;; This is a form to be evaled.
                  (eval match)))))
+         ;; Expand all the named elements in style.
+         (setq style (apply (function nconc)
+                            (mapcar
+                             (lambda (attribute)
+                               (if (stringp attribute)
+                                   (copy-sequence
+                                    (cdr (assoc attribute
+                                                gnus-named-posting-styles)))
+                                 (list attribute)))
+                             style)))
          ;; We have a match, so we set the variables.
          (dolist (attribute style)
            (setq element (pop attribute)
@@ -2021,6 +2042,18 @@ this is a reply."
                         (insert "From: " (message-make-from) "\n"))))
                  nil 'local)))))
 
+(defun gnus-summary-execute-command-with-posting-style (style command)
+  "Temporarily select a posting-style named STYLE and execute COMMAND."
+  (interactive
+   (let ((style (completing-read "Posting style: "
+                                gnus-named-posting-styles nil t)))
+     (list style
+          (key-binding
+           (read-key-sequence
+            (format "Command to execute with %s:" style))))))
+  (let ((gnus-posting-styles (list (list ".*" style))))
+    (call-interactively command)))
+
 
 ;;; @ for MIME Edit mode
 ;;;