[PATCH] emacs: Don't override mm-show-part in notmuch-show-view-part
Mark Walters
markwalters1009 at gmail.com
Mon May 20 23:09:18 PDT 2013
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)
Best wishes
Mark
> ---
>
> This takes a different approach from the previous patch by eliminating
> the function override altogether, so we don't need flet or anything
> like it. I tested it by hand in Emacs 24.3 and 23.4 and checked that
> mm-save-part's code has not changed since at least 23.1.
>
> emacs/notmuch-show.el | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 423dd58..19bcb29 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -529,19 +529,11 @@ message at DEPTH in the current thread."
> (defun notmuch-show-view-part (message-id nth &optional filename content-type )
> (notmuch-with-temp-part-buffer message-id nth
> ;; set mm-inlined-types to nil to force an external viewer
> - (let ((handle (mm-make-handle (current-buffer) (list content-type)))
> - (mm-inlined-types nil))
> - ;; We override mm-save-part as notmuch-show-save-part is better
> - ;; since it offers the filename. We need to lexically bind
> - ;; everything we need for notmuch-show-save-part to prevent
> - ;; potential dynamic shadowing.
> - (lexical-let ((message-id message-id)
> - (nth nth)
> - (filename filename)
> - (content-type content-type))
> - (flet ((mm-save-part (&rest args) (notmuch-show-save-part
> - message-id nth filename content-type)))
> - (mm-display-part handle))))))
> + (let* ((disposition (if filename `(attachment (filename . ,filename))))
> + (handle (mm-make-handle (current-buffer) (list content-type)
> + nil nil disposition))
> + (mm-inlined-types nil))
> + (mm-display-part handle))))
>
> (defun notmuch-show-interactively-view-part (message-id nth &optional filename content-type)
> (notmuch-with-temp-part-buffer message-id nth
> --
> 1.7.10.4
More information about the notmuch
mailing list