From: Katsumi Yamaoka Date: Thu, 14 Feb 2019 02:16:05 +0000 (+0000) Subject: Work for empty MIME attachments (related to bug#34387) X-Git-Tag: emacs-26.1.92~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=25d9fe24a657565761f79d7d96e22777a94aa84f;p=emacs.git Work for empty MIME attachments (related to bug#34387) * mm-view.el (mm-inline-text): Make undisplayer do nothing if the part is empty. * mm-decode.el (mm-copy-to-buffer): Work for empty MIME part. * mml.el (mime-to-mml): Ditto. --- diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index 5dad2acbdd0..21552abae73 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -764,7 +764,7 @@ MIME-Version header before proceeding." (mb (mm-multibyte-p)) beg) (goto-char (point-min)) - (search-forward-regexp "^\n" nil t) + (search-forward-regexp "^\n" nil 'move) ;; There might be no body. (setq beg (point)) (with-current-buffer (generate-new-buffer " *mm*") diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index d588e9b9a87..03e1e11813f 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -368,10 +368,12 @@ (enriched-decode (point-min) (point-max)))) (mm-handle-set-undisplayer handle - `(lambda () - (let ((inhibit-read-only t)) - (delete-region ,(copy-marker (point-min) t) - ,(point-max-marker)))))))) + (if (= (point-min) (point-max)) + #'ignore + `(lambda () + (let ((inhibit-read-only t)) + (delete-region ,(copy-marker (point-min) t) + ,(point-max-marker))))))))) (defun mm-insert-inline (handle text) "Insert TEXT inline from HANDLE." diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el index f2b969a15b5..d5588971e59 100644 --- a/lisp/gnus/mml.el +++ b/lisp/gnus/mml.el @@ -979,8 +979,10 @@ If HANDLES is non-nil, use it instead reparsing the buffer." (unless handles (setq handles (mm-dissect-buffer t))) (goto-char (point-min)) - (search-forward "\n\n" nil t) - (delete-region (point) (point-max)) + (if (search-forward "\n\n" nil 'move) + (delete-region (point) (point-max)) + ;; No content in the part that is the sole part of this message. + (insert (if (bolp) "\n" "\n\n"))) (if (stringp (car handles)) (mml-insert-mime handles) (mml-insert-mime handles t))