unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Don't re-compress .gz & al. in notmuch-show-save-part.
@ 2011-05-09 23:33 Dmitry Kurochkin
  2011-05-10  1:18 ` [PATCH] test: saving attachments from within emacs using notmuch-show-save-attachments Dmitry Kurochkin
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Kurochkin @ 2011-05-09 23:33 UTC (permalink / raw)
  To: Notmuch Mail

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] test: saving attachments from within emacs using notmuch-show-save-attachments
  2011-05-09 23:33 [PATCH] Don't re-compress .gz & al. in notmuch-show-save-part Dmitry Kurochkin
@ 2011-05-10  1:18 ` Dmitry Kurochkin
  2011-05-10  1:24   ` [PATCH] test: saving attachments from within emacs using notmuch-show-save-part Dmitry Kurochkin
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Kurochkin @ 2011-05-10  1:18 UTC (permalink / raw)
  To: Notmuch Mail

---
 test/emacs |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/emacs b/test/emacs
index 75dec89..675a887 100755
--- a/test/emacs
+++ b/test/emacs
@@ -112,9 +112,17 @@ Fcc: $(pwd)/mail/sent
 On Fri, 29 Mar 1974 10:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
 > This is a test that messages are sent via SMTP"
 
-test_begin_subtest "Save attachment from within emacs"
-echo "./attachment" | test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1
-output=$(cat attachment)
+test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
+# save as archive to test that Emacs does not re-compress .gz
+echo "./attachment1.gz" | test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1
+output=$(cat attachment1.gz)
+expected=$(cat $EXPECTED/attachment)
+test_expect_equal "$output" "$expected"
+
+test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
+# save as archive to test that Emacs does not re-compress .gz
+echo "./attachment2.gz" | test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1
+output=$(cat attachment2.gz)
 expected=$(cat $EXPECTED/attachment)
 test_expect_equal "$output" "$expected"
 
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] test: saving attachments from within emacs using notmuch-show-save-part
  2011-05-10  1:18 ` [PATCH] test: saving attachments from within emacs using notmuch-show-save-attachments Dmitry Kurochkin
@ 2011-05-10  1:24   ` Dmitry Kurochkin
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Kurochkin @ 2011-05-10  1:24 UTC (permalink / raw)
  To: Notmuch Mail

---
Oops, the previos
patch (id:"1304990327-8665-1-git-send-email-dmitry.kurochkin@gmail.com")
has wrong title.

s/notmuch-show-save-attachments/notmuch-show-save-part/

Regards,
  Dmitry

 test/emacs |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/emacs b/test/emacs
index 75dec89..675a887 100755
--- a/test/emacs
+++ b/test/emacs
@@ -112,9 +112,17 @@ Fcc: $(pwd)/mail/sent
 On Fri, 29 Mar 1974 10:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
 > This is a test that messages are sent via SMTP"
 
-test_begin_subtest "Save attachment from within emacs"
-echo "./attachment" | test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1
-output=$(cat attachment)
+test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
+# save as archive to test that Emacs does not re-compress .gz
+echo "./attachment1.gz" | test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") (notmuch-show-save-attachments)' > /dev/null 2>&1
+output=$(cat attachment1.gz)
+expected=$(cat $EXPECTED/attachment)
+test_expect_equal "$output" "$expected"
+
+test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
+# save as archive to test that Emacs does not re-compress .gz
+echo "./attachment2.gz" | test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1
+output=$(cat attachment2.gz)
 expected=$(cat $EXPECTED/attachment)
 test_expect_equal "$output" "$expected"
 
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-10  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09 23:33 [PATCH] Don't re-compress .gz & al. in notmuch-show-save-part Dmitry Kurochkin
2011-05-10  1:18 ` [PATCH] test: saving attachments from within emacs using notmuch-show-save-attachments Dmitry Kurochkin
2011-05-10  1:24   ` [PATCH] test: saving attachments from within emacs using notmuch-show-save-part Dmitry Kurochkin

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).