Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id DE82E429E27 for ; Mon, 9 May 2011 16:33:42 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k7jIhv53t02P for ; Mon, 9 May 2011 16:33:42 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 2B106429E26 for ; Mon, 9 May 2011 16:33:42 -0700 (PDT) Received: by fxm8 with SMTP id 8so4263410fxm.26 for ; Mon, 09 May 2011 16:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=fzzVZabOMKX5mtFsBTSdyT3M/FZL0durHepC4ocdVxQ=; b=BXPyIeeH0DQZ1cEnMpT2W7ZIiFrezhwNUC5MHc/1K3ktH4JYlscefhsFKArOqNpEI2 fDzbe+FPV93my5hdLHQDHBVhuuOT4utFO7O2IaReta5DZtsXX2jDOgemwlHhZ9G+pbKb sfOuu+Rf/vXHd9q0GmPWTy4EAHW8kgYKo8aYc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Kk2WbcddxRP7Y6uM1LSc6zNcEYSXd7ABbZP5Wq2PnjBhbf9aGXxZqIN4BR302pcWov R0XW2+pYt4bsdqh7FybkWawb/rxLK381Joqcg/S/Y2yOqFWp3ZkjGmjsrxggymsrMemE aIkLETiOp6t1jX5sPhPdZpoYx/Sf1syMGLalM= Received: by 10.223.161.194 with SMTP id s2mr765801fax.143.1304984020532; Mon, 09 May 2011 16:33:40 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id c24sm2166421fak.7.2011.05.09.16.33.38 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 May 2011 16:33:39 -0700 (PDT) From: Dmitry Kurochkin To: Notmuch Mail Subject: [PATCH] Don't re-compress .gz & al. in notmuch-show-save-part. Date: Tue, 10 May 2011 03:33:55 +0400 Message-Id: <1304984035-20743-1-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.1 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2011 23:33:43 -0000 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 --- This patch is for the release-candidate/0.6 branch. I know Jameson has declared it ready for release, but perhaps it is not too late for a small fix? Adding a test for this would be nice, but is a low priority for me. If anyone volunteers, that would be welcomed :) Regards, Dmitry emacs/notmuch-show.el | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 825988c..23291ce 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -306,10 +306,11 @@ message at DEPTH in the current thread." "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 -- 1.7.5.1