X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fmml.el;h=3199a0d26411b42e04e5cb096842904e88d6fca3;hb=71f930a11aca1a252cc29e71c0fb981e06b43328;hp=a7ee8de9ec72840595f00ff4f7ba3524ba7e24b9;hpb=288df404798143bcebde31f44f2041f786424fa6;p=elisp%2Fgnus.git- diff --git a/lisp/mml.el b/lisp/mml.el index a7ee8de..3199a0d 100644 --- a/lisp/mml.el +++ b/lisp/mml.el @@ -37,7 +37,8 @@ (autoload 'gnus-make-local-hook "gnus-util") (autoload 'message-fetch-field "message") (autoload 'fill-flowed-encode "flow-fill") - (autoload 'message-posting-charset "message")) + (autoload 'message-posting-charset "message") + (autoload 'x-dnd-get-local-file-name "x-dnd")) (defcustom mml-content-type-parameters '(name access-type expiration size permission format) @@ -137,12 +138,8 @@ one charsets.") "Parse the current buffer as an MML document." (save-excursion (goto-char (point-min)) - (let ((table (syntax-table))) - (unwind-protect - (progn - (set-syntax-table mml-syntax-table) - (mml-parse-1)) - (set-syntax-table table))))) + (with-syntax-table mml-syntax-table + (mml-parse-1)))) (defun mml-parse-1 () "Parse the current buffer as an MML document." @@ -164,9 +161,8 @@ one charsets.") (method (cdr (assq 'method taginfo))) tags) (save-excursion - (if - (re-search-forward - "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)." nil t) + (if (re-search-forward + "<#/?\\(multipart\\|part\\|external\\|mml\\)." nil t) (setq secure-mode "multipart") (setq secure-mode "part"))) (save-excursion @@ -446,6 +442,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." ;; actually are hard newlines in the text. (let (use-hard-newlines) (when (and (string= type "text/plain") + (not (string= (cdr (assq 'sign cont)) "pgp")) (or (null (assq 'format cont)) (string= (cdr (assq 'format cont)) "flowed")) @@ -553,7 +550,8 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." (message-options-set 'message-sender sender)) (if (setq recipients (cdr (assq 'recipients cont))) (message-options-set 'message-recipients recipients)) - (let ((style (mml-signencrypt-style (first (or sign-item encrypt-item))))) + (let ((style (mml-signencrypt-style + (first (or sign-item encrypt-item))))) ;; check if: we're both signing & encrypting, both methods ;; are the same (why would they be different?!), and that ;; the signencrypt style allows for combined operation. @@ -587,7 +585,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." (insert-buffer-substring (cdr (assq 'buffer cont)))) ((and (setq filename (cdr (assq 'filename cont))) (not (equal (cdr (assq 'nofile cont)) "yes"))) - (mm-insert-file-contents filename)) + (mm-insert-file-contents filename nil nil nil nil t)) (t (insert (cdr (assq 'contents cont))))) (goto-char (point-min)) @@ -893,6 +891,11 @@ See Info node `(emacs-mime)Composing'. (> (prefix-numeric-value arg) 0))) (add-minor-mode 'mml-mode " MML" mml-mode-map) (easy-menu-add mml-menu mml-mode-map) + (when (boundp 'x-dnd-protocol-alist) + (set (make-local-variable 'x-dnd-protocol-alist) + '(("^file:///" . mml-x-dnd-attach-file) + ("^file://" . x-dnd-open-file) + ("^file:" . mml-x-dnd-attach-file)))) (run-hooks 'mml-mode-hook))) ;;; @@ -1010,6 +1013,15 @@ description of the attachment." 'disposition (or disposition "attachment") 'description description)) +(defun mml-x-dnd-attach-file (uri action) + "Attach a drag and drop file." + (let ((file (x-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))) + (mml-attach-file file type description disposition))))) + (defun mml-attach-buffer (buffer &optional type description) "Attach a buffer to the outgoing MIME message. See `mml-attach-file' for details of operation."