aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-09-21 01:41:50 +0200
committerLars Ingebrigtsen2019-09-21 01:41:50 +0200
commit7828001aef134bf3a062edcea92cd0ce0dac407e (patch)
tree1258642c4b67ac558a991a6e0fc93d473a9453f2
parentc56fabdfc731a8498b9ee8e9c988f85180de690f (diff)
downloademacs-7828001aef134bf3a062edcea92cd0ce0dac407e.tar.gz
emacs-7828001aef134bf3a062edcea92cd0ce0dac407e.zip
Allow the user to specify Content-type in Message mode
* lisp/gnus/message.el (message-encode-message-body): Pass in the content type if the user has given one. * lisp/gnus/mml.el (mml-parse-1): Remove bogus peek at Content-type (there are no headers here) (bug#36527). * lisp/gnus/mml.el (mml-generate-mime): Respect that.
-rw-r--r--lisp/gnus/message.el5
-rw-r--r--lisp/gnus/mml.el19
2 files changed, 13 insertions, 11 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index ef6455ac5c9..ef9f8429d40 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -8061,7 +8061,10 @@ regexp VARSTR."
8061 (message-goto-body) 8061 (message-goto-body)
8062 (save-restriction 8062 (save-restriction
8063 (narrow-to-region (point) (point-max)) 8063 (narrow-to-region (point) (point-max))
8064 (let ((new (mml-generate-mime))) 8064 (let ((new (mml-generate-mime nil
8065 (save-restriction
8066 (message-narrow-to-headers)
8067 (mail-fetch-field "content-type")))))
8065 (when new 8068 (when new
8066 (delete-region (point-min) (point-max)) 8069 (delete-region (point-min) (point-max))
8067 (insert new) 8070 (insert new)
diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index 4a0d40ac0ed..7fd78d7b9c1 100644
--- a/lisp/gnus/mml.el
+++ b/lisp/gnus/mml.el
@@ -295,14 +295,6 @@ part. This is for the internal use, you should never modify the value.")
295 (t 295 (t
296 (mm-find-mime-charset-region point (point) 296 (mm-find-mime-charset-region point (point)
297 mm-hack-charsets)))) 297 mm-hack-charsets))))
298 ;; If the user has inserted a Content-Type header, then
299 ;; respect that instead of overwriting with "text/plain".
300 (save-restriction
301 (narrow-to-region point (point))
302 (let ((content-type (mail-fetch-field "content-type")))
303 (when (and content-type
304 (eq (car tag) 'part))
305 (setcdr (assq 'type tag) content-type))))
306 (when (and (not raw) (memq nil charsets)) 298 (when (and (not raw) (memq nil charsets))
307 (if (or (memq 'unknown-encoding mml-confirmation-set) 299 (if (or (memq 'unknown-encoding mml-confirmation-set)
308 (message-options-get 'unknown-encoding) 300 (message-options-get 'unknown-encoding)
@@ -479,10 +471,13 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
479(declare-function libxml-parse-html-region "xml.c" 471(declare-function libxml-parse-html-region "xml.c"
480 (start end &optional base-url discard-comments)) 472 (start end &optional base-url discard-comments))
481 473
482(defun mml-generate-mime (&optional multipart-type) 474(defun mml-generate-mime (&optional multipart-type content-type)
483 "Generate a MIME message based on the current MML document. 475 "Generate a MIME message based on the current MML document.
484MULTIPART-TYPE defaults to \"mixed\", but can also 476MULTIPART-TYPE defaults to \"mixed\", but can also
485be \"related\" or \"alternate\"." 477be \"related\" or \"alternate\".
478
479If CONTENT-TYPE (and there's only one part), override the content
480type detected."
486 (let ((cont (mml-parse)) 481 (let ((cont (mml-parse))
487 (mml-multipart-number mml-multipart-number) 482 (mml-multipart-number mml-multipart-number)
488 (options message-options)) 483 (options message-options))
@@ -490,6 +485,10 @@ be \"related\" or \"alternate\"."
490 nil 485 nil
491 (when (and (consp (car cont)) 486 (when (and (consp (car cont))
492 (= (length cont) 1) 487 (= (length cont) 1)
488 content-type)
489 (setcdr (assq 'type (cdr (car cont))) content-type))
490 (when (and (consp (car cont))
491 (= (length cont) 1)
493 (fboundp 'libxml-parse-html-region) 492 (fboundp 'libxml-parse-html-region)
494 (equal (cdr (assq 'type (car cont))) "text/html")) 493 (equal (cdr (assq 'type (car cont))) "text/html"))
495 (setq cont (mml-expand-html-into-multipart-related (car cont)))) 494 (setq cont (mml-expand-html-into-multipart-related (car cont))))