]> git.notmuchmail.org Git - notmuch/commitdiff
Don't re-compress .gz & al. in notmuch-show-save-part.
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Mon, 9 May 2011 23:33:55 +0000 (03:33 +0400)
committerCarl Worth <cworth@cworth.org>
Tue, 31 May 2011 22:04:52 +0000 (15:04 -0700)
Write-region handles some file names specially, see Emacs Lisp
manual section 25.11 Making Certain File Names "Magic" [1].  This
is a nice feature for normal text editing, but it is not
desirable if we need to save raw file content (e.g. attachment).
In particular, this affects archives and may result in corrupted
attachments saved with notmuch-show-save-part (attachment button
click handler).

Turns out, smart GNUS folks encountered the same problem and
implemented write-region wrapper which inhibits some file name
handlers.  In particular, this wrapper is used in mm-save-part,
which is why notmuch-save-attachments that uses it works fine
with archives.

The patch replaces write-region with mm-write-region in
notmuch-show-save-part.  Also it removes coding-system-for-write
and require-final-newline setting in notmuch-show-save-part.  The
former is set in mm-write-region.  The latter seems to be
unneeded because mm-save-part does not use it.

[1] http://www.gnu.org/s/emacs/manual/html_node/elisp/Magic-File-Names.html

emacs/notmuch-show.el

index 6c498ab1b8cff9cd53bb8620fb34b2448b7cd81b..40cf74e8f110f447b9196bd709c12adfa191e27d 100644 (file)
@@ -306,10 +306,11 @@ message at DEPTH in the current thread."
                   "Filename to save as: "
                   (or mailcap-download-directory "~/")
                   nil nil
                   "Filename to save as: "
                   (or mailcap-download-directory "~/")
                   nil nil
-                  filename))
-           (require-final-newline nil)
-           (coding-system-for-write 'no-conversion))
-       (write-region (point-min) (point-max) file)))))
+                  filename)))
+       ;; Don't re-compress .gz & al.  Arguably we should make
+       ;; `file-name-handler-alist' nil, but that would chop
+       ;; ange-ftp, which is reasonable to use here.
+       (mm-write-region (point-min) (point-max) file nil nil nil 'no-conversion t)))))
 
 (defun notmuch-show-mm-display-part-inline (msg part content-type content)
   "Use the mm-decode/mm-view functions to display a part in the
 
 (defun notmuch-show-mm-display-part-inline (msg part content-type content)
   "Use the mm-decode/mm-view functions to display a part in the