From: Mark Walters Date: Tue, 21 May 2013 06:09:18 +0000 (+0100) Subject: Re: [PATCH] emacs: Don't override mm-show-part in notmuch-show-view-part X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cd37edfafc8d9c161035353c42302ad646e761c0;p=notmuch-archives.git Re: [PATCH] emacs: Don't override mm-show-part in notmuch-show-view-part --- diff --git a/a5/65f179751f96adce6d85398f071c15062f140d b/a5/65f179751f96adce6d85398f071c15062f140d new file mode 100644 index 000000000..4c88926ac --- /dev/null +++ b/a5/65f179751f96adce6d85398f071c15062f140d @@ -0,0 +1,143 @@ +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 B05D4431FB6 + for ; Mon, 20 May 2013 23:09:38 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 gEKrQmhVa9En for ; + Mon, 20 May 2013 23:09:32 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B3E7D431FBC + for ; Mon, 20 May 2013 23:09:31 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1UeflC-0007Q6-7S; Tue, 21 May 2013 07:09:27 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1UeflB-0001SJ-SH; Tue, 21 May 2013 07:09:22 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs: Don't override mm-show-part in + notmuch-show-view-part +In-Reply-To: <1369080503-6866-1-git-send-email-amdragon@mit.edu> +References: <20130520170439.GG5999@mit.edu> + <1369080503-6866-1-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 21 May 2013 07:09:18 +0100 +Message-ID: <8761ycc19t.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 6db475ec8ed3e45d4efed38343dceaf0 (of first 20000 bytes) +X-SpamAssassin-Score: -0.2 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.2 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.2 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Tue, 21 May 2013 06:09:39 -0000 + + +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