X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fmml.el;h=68370d638dea41a110af7b2e3605c735780aa970;hb=e2696774a2e225ea60d46cc665d4232c80412731;hp=a7ee8de9ec72840595f00ff4f7ba3524ba7e24b9;hpb=288df404798143bcebde31f44f2041f786424fa6;p=elisp%2Fgnus.git- diff --git a/lisp/mml.el b/lisp/mml.el index a7ee8de..68370d6 100644 --- a/lisp/mml.el +++ b/lisp/mml.el @@ -36,8 +36,10 @@ (autoload 'gnus-setup-posting-charset "gnus-msg") (autoload 'gnus-make-local-hook "gnus-util") (autoload 'message-fetch-field "message") + (autoload 'message-mark-active-p "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) @@ -130,19 +132,15 @@ one charsets.") (defun mml-destroy-buffers () (let (kill-buffer-hook) - (mapcar 'kill-buffer mml-buffer-list) + (mapc 'kill-buffer mml-buffer-list) (setq mml-buffer-list nil))) (defun mml-parse () "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 +162,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 +443,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 +551,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 +586,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)) @@ -597,7 +596,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." (incf mml-multipart-number))) (throw 'not-unique nil)))) ((eq (car cont) 'multipart) - (mapcar 'mml-compute-boundary-1 (cddr cont)))) + (mapc 'mml-compute-boundary-1 (cddr cont)))) t)) (defun mml-make-boundary (number) @@ -850,33 +849,36 @@ If HANDLES is non-nil, use it instead reparsing the buffer." main)) (easy-menu-define - mml-menu mml-mode-map "" - `("Attachments" - ["Attach File..." mml-attach-file - ,@(if (featurep 'xemacs) '(t) - '(:help "Attach a file at point"))] - ["Attach Buffer..." mml-attach-buffer t] - ["Attach External..." mml-attach-external t] - ["Insert Part..." mml-insert-part t] - ["Insert Multipart..." mml-insert-multipart t] - ["PGP/MIME Sign" mml-secure-message-sign-pgpmime t] - ["PGP/MIME Encrypt" mml-secure-message-encrypt-pgpmime t] - ["PGP Sign" mml-secure-message-sign-pgp t] - ["PGP Encrypt" mml-secure-message-encrypt-pgp t] - ["S/MIME Sign" mml-secure-message-sign-smime t] - ["S/MIME Encrypt" mml-secure-message-encrypt-smime t] - ("Secure MIME part" - ["PGP/MIME Sign Part" mml-secure-sign-pgpmime t] - ["PGP/MIME Encrypt Part" mml-secure-encrypt-pgpmime t] - ["PGP Sign Part" mml-secure-sign-pgp t] - ["PGP Encrypt Part" mml-secure-encrypt-pgp t] - ["S/MIME Sign Part" mml-secure-sign-smime t] - ["S/MIME Encrypt Part" mml-secure-encrypt-smime t]) - ["Encrypt/Sign off" mml-unsecure-message t] - ;;["Narrow" mml-narrow-to-part t] - ["Quote MML" mml-quote-region t] - ["Validate MML" mml-validate t] - ["Preview" mml-preview t])) + mml-menu mml-mode-map "" + `("Attachments" + ["Attach File..." mml-attach-file + ,@(if (featurep 'xemacs) '(t) + '(:help "Attach a file at point"))] + ["Attach Buffer..." mml-attach-buffer t] + ["Attach External..." mml-attach-external t] + ["Insert Part..." mml-insert-part t] + ["Insert Multipart..." mml-insert-multipart t] + ["PGP/MIME Sign" mml-secure-message-sign-pgpmime t] + ["PGP/MIME Encrypt" mml-secure-message-encrypt-pgpmime t] + ["PGP Sign" mml-secure-message-sign-pgp t] + ["PGP Encrypt" mml-secure-message-encrypt-pgp t] + ["S/MIME Sign" mml-secure-message-sign-smime t] + ["S/MIME Encrypt" mml-secure-message-encrypt-smime t] + ("Secure MIME part" + ["PGP/MIME Sign Part" mml-secure-sign-pgpmime t] + ["PGP/MIME Encrypt Part" mml-secure-encrypt-pgpmime t] + ["PGP Sign Part" mml-secure-sign-pgp t] + ["PGP Encrypt Part" mml-secure-encrypt-pgp t] + ["S/MIME Sign Part" mml-secure-sign-smime t] + ["S/MIME Encrypt Part" mml-secure-encrypt-smime t]) + ["Encrypt/Sign off" mml-unsecure-message t] + ;;["Narrow" mml-narrow-to-part t] + ["Quote MML" mml-quote-region + :active (message-mark-active-p) + ,@(if (featurep 'xemacs) nil + '(:help "Quote MML tags in region"))] + ["Validate MML" mml-validate t] + ["Preview" mml-preview t])) (defvar mml-mode nil "Minor mode for editing MML.") @@ -893,6 +895,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 +1017,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."