(mml-dnd-protocol-alist, mml-dnd-attach-options): New
[gnus] / lisp / mml.el
index 66c1643..f6e728b 100644 (file)
@@ -940,9 +940,7 @@ See Info node `(emacs-mime)Composing'.
     (easy-menu-add mml-menu mml-mode-map)
     (when (boundp 'dnd-protocol-alist)
       (set (make-local-variable 'dnd-protocol-alist)
-          '(("^file:///" . mml-dnd-attach-file)
-            ("^file://"  . dnd-open-file)
-            ("^file:"    . mml-dnd-attach-file))))
+          (append mml-dnd-protocol-alist dnd-protocol-alist)))
     (run-hooks 'mml-mode-hook)))
 
 ;;;
@@ -1040,6 +1038,36 @@ See Info node `(emacs-mime)Composing'.
 
 ;;; Attachment functions.
 
+(defcustom mml-dnd-protocol-alist
+  '(("^file:///" . mml-dnd-attach-file)
+    ("^file://"  . dnd-open-file)
+    ("^file:"    . mml-dnd-attach-file))
+  "The functions to call when a drop in `mml-mode' is made.
+See `dnd-protocol-alist' for more information.  When nil, behave
+as in other buffers."
+  :type '(choice (repeat (cons (regexp) (function)))
+                (const :tag "Behave as in other buffers" nil))
+  :version "23.0" ;; No Gnus
+  :group 'message)
+
+(defcustom mml-dnd-attach-options nil
+  "Which options should be queried when attaching a file via drag and drop.
+
+If it is a list, valid members are `type', `description' and
+`disposition'.  `disposition' implies `type'.  If it is nil,
+don't ask for options.  If it is t, ask the user whether or not
+to specify options."
+  :type '(choice
+         (const :tag "Non" nil)
+         (const :tag "Query" t)
+         (list :value (type description disposition)
+          (set :inline t
+               (const type)
+               (const description)
+               (const disposition))))
+  :version "23.0" ;; No Gnus
+  :group 'message)
+
 (defun mml-attach-file (file &optional type description disposition)
   "Attach a file to the outgoing MIME message.
 The file is not inserted or encoded until you send the message with
@@ -1061,12 +1089,27 @@ description of the attachment."
                        'description description))
 
 (defun mml-dnd-attach-file (uri action)
-  "Attach a drag and drop file."
+  "Attach a drag and drop file.
+
+Ask for type, description or disposition according to
+`mml-dnd-attach-options'."
   (let ((file (dnd-get-local-file-name uri t)))
     (when (and file (file-regular-p file))
-      (let* ((type (mml-minibuffer-read-type file))
-           (description (mml-minibuffer-read-description))
-           (disposition (mml-minibuffer-read-disposition type)))
+      (let ((mml-dnd-attach-options mml-dnd-attach-options)
+           type description disposition)
+       (setq mml-dnd-attach-options
+             (when (and (eq mml-dnd-attach-options t)
+                        (not
+                         (y-or-n-p
+                          "Use default type, disposition and description? ")))
+               '(type description disposition)))
+       (when (or (memq 'type mml-dnd-attach-options)
+                 (memq 'disposition mml-dnd-attach-options))
+         (setq type (mml-minibuffer-read-type file)))
+       (when (memq 'description mml-dnd-attach-options)
+         (setq description (mml-minibuffer-read-description)))
+       (when (memq 'disposition mml-dnd-attach-options)
+         (setq disposition (mml-minibuffer-read-disposition type)))
        (mml-attach-file file type description disposition)))))
 
 (defun mml-attach-buffer (buffer &optional type description)