unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: Don't override mm-show-part in notmuch-show-view-part
Date: Tue, 21 May 2013 20:13:09 +0100	[thread overview]
Message-ID: <87fvxguoxm.fsf@qmul.ac.uk> (raw)
In-Reply-To: <8761ycc19t.fsf@qmul.ac.uk>


On Tue, 21 May 2013, Mark Walters <markwalters1009@gmail.com> wrote:
> Hi
>
>> Previously, notmuch-show-view-part overrode the function binding of
>> mm-show-part to redirect it to notmuch-show-save-part to get notmuch's
>> default file name handling in case mm-display-part decided to fall
>> back to saving the part.  In addition to being messy, this depended on
>> the now-deprecated dynamic binding behavior of flet.
>>
>> This patch removes the mm-show-part override in favor of passing the
>> file name in to mm-show-part the way it expects, so we get its default
>> file name handling.  It's not clear why we didn't do this before;
>> mm-show-part has supported default file names since at least Emacs
>> 23.1.
>
> The new code is much simpler (and nicer). However, one small annoyance
> is it makes notmuch-show-save-part and notmuch-show-view-part behave
> differently on parts which can only be saved (eg
> application/octet-stream): view-part (ie mm-save-part) offers the
> current directory (where emacs was started) whereas the notmuch
> save-part explicitly offers mailcap-download-directory or ~/. I have no
> preference which is used but think they should be the same. Perhaps
> notmuch-show-save-part could just call mm-save-part? I have tried that
> and the tests pass. (If we can do that I think the whole part button handling
> stuff could be unified/simplified significantly)

Here is the code I was using to try using mm-save-part rather than our
own version. I don't know why we have our own version: this does pass
the tests and seems to work (though as mentioned above the semantics of
which default path is used are different)

Best wishes

Mark

---
 emacs/notmuch-show.el |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 45039bd..a63b857 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -516,15 +516,10 @@ message at DEPTH in the current thread."
 
 (defun notmuch-show-save-part (message-id nth &optional filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
-    (let ((file (read-file-name
-		 "Filename to save as: "
-		 (or mailcap-download-directory "~/")
-		 nil nil
-		 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))))
+    (let* ((disposition (if filename `(attachment (filename . ,filename))))
+	   (handle (mm-make-handle (current-buffer) (list content-type)
+				   nil nil disposition)))
+      (mm-save-part handle))))
 
 (defun notmuch-show-view-part (message-id nth &optional filename content-type )
   (notmuch-with-temp-part-buffer message-id nth
-- 
1.7.9.1

  reply	other threads:[~2013-05-21 19:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-19 11:31 use of flet in notmuch-emacs David Bremner
2013-05-19 15:14 ` [PATCH] emacs: Avoid deprecated function flet Austin Clements
2013-05-20 15:45   ` David Bremner
2013-05-20 17:04     ` Austin Clements
2013-05-20 20:08       ` [PATCH] emacs: Don't override mm-show-part in notmuch-show-view-part Austin Clements
2013-05-21  6:09         ` Mark Walters
2013-05-21 19:13           ` Mark Walters [this message]
2013-05-26  6:36             ` Austin Clements
2013-05-26  6:34           ` [PATCH v2] " Austin Clements
2013-05-26  7:04             ` Mark Walters
2013-05-26  7:31             ` Tomi Ollila
2013-05-26 23:35             ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fvxguoxm.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=amdragon@MIT.EDU \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).