2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 1 Jan 2002 06:05:08 +0000 (06:05 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 1 Jan 2002 06:05:08 +0000 (06:05 +0000)
* gnus-msg.el (gnus-gcc-externalize-attachments): New variable.
(gnus-inews-do-gcc): Use it.

* mml.el (mml-tweak-sexp-alist): New variable.
(mml-externalize-attachments): New variable.
(mml-tweak-part): Use mml-tweak-sexp-alist.
(mml-tweak-externalize-attachments): New function.

lisp/ChangeLog
lisp/gnus-msg.el
lisp/mml.el

index 6016928..d5f0c6e 100644 (file)
@@ -1,3 +1,13 @@
+2002-01-01  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * gnus-msg.el (gnus-gcc-externalize-attachments): New variable.
+       (gnus-inews-do-gcc): Use it.
+
+       * mml.el (mml-tweak-sexp-alist): New variable.
+       (mml-externalize-attachments): New variable.
+       (mml-tweak-part): Use mml-tweak-sexp-alist.
+       (mml-tweak-externalize-attachments): New function.
+
 2002-01-01  Steve Youngs  <youngs@xemacs.org>
 
        * gnus-xmas.el (gnus-xmas-article-display-xface): Uncomment
index af72688..204aa66 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-msg.el --- mail and post interface for Gnus
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
@@ -137,6 +137,16 @@ See Info node `(gnus)Posting Styles'."
   :group 'gnus-message
   :type 'boolean)
 
+(defcustom gnus-gcc-externalize-attachments nil
+  "Should local-file attachments be included as external parts?
+If it is `all', attach files as external parts;
+if a regexp and matches the Gcc group name, attach files as external parts;
+If nil, attach files as normal parts."
+  :group 'gnus-message
+  :type '(choice (const nil :tag "None")
+                (const all :tag "Any")
+                (string :tag "Regexp")))
+
 (defcustom gnus-group-posting-charset-alist
   '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
     ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
@@ -1335,7 +1345,8 @@ this is a reply."
       (message-narrow-to-headers)
       (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
            (cur (current-buffer))
-           groups group method group-art)
+           groups group method group-art
+           mml-externalize-attachments)
        (when gcc
          (message-remove-header "gcc")
          (widen)
@@ -1349,6 +1360,10 @@ this is a reply."
                                              (car method))))
            (unless (gnus-request-group group nil method)
              (gnus-request-create-group group method))
+           (setq mml-externalize-attachments
+                 (if (stringp gnus-gcc-externalize-attachments)
+                     (string-match gnus-gcc-externalize-attachments group)
+                   gnus-gcc-externalize-attachments))
            (save-excursion
              (nnheader-set-temp-buffer " *acc*")
              (insert-buffer-substring cur)
index 2fabf3e..af9b23c 100644 (file)
@@ -1,5 +1,5 @@
 ;;; mml.el --- A package for parsing and validating MML documents
-;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; This file is part of GNU Emacs.
@@ -64,6 +64,16 @@ NAME is a string containing the name of the TWEAK parameter in the MML
 handle.  FUNCTION is a Lisp function which is called with the MML
 handle to tweak the part.")
 
+(defvar mml-tweak-sexp-alist 
+  '((mml-externalize-attachments . mml-tweak-externalize-attachments))
+  "A list of (SEXP . FUNCTION) for tweaking MML parts.
+SEXP is a s-expression. If the evaluation of SEXP is non-nil, FUNCTION
+is called.  FUNCTION is a Lisp function which is called with the MML
+handle to tweak the part.")
+
+(defvar mml-externalize-attachments nil
+  "*If non-nil, local-file attachments are generated as external parts.")
+
 (defvar mml-generate-multipart-alist nil
   "*Alist of multipart generation functions.
 Each entry has the form (NAME . FUNCTION), where
@@ -962,7 +972,23 @@ If RAW, don't highlight the article."
            (setq alist (cdr alist)))))))
     (if func
        (funcall func cont)
-      cont)))
+      cont)
+    (let ((alist mml-tweak-sexp-alist))
+      (while alist
+       (if (eval (caar alist))
+           (funcall (cdar alist) cont))
+       (setq alist (cdr alist)))))
+  cont)
+
+(defun mml-tweak-externalize-attachments (cont)
+  "Tweak attached files as external parts."
+  (let (filename-cons)
+    (when (and (eq (car cont) 'part) 
+              (not (cdr (assq 'buffer cont)))
+              (and (setq filename-cons (assq 'filename cont))
+                   (not (equal (cdr (assq 'nofile cont)) "yes"))))
+      (setcar cont 'external)
+      (setcar filename-cons 'name))))
 
 (provide 'mml)