From 3f59c55d436a1c3b82cf1e6c50b647874049b973 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 27 May 2013 02:36:27 +2000 Subject: [PATCH] Re: [PATCH] emacs: Don't override mm-show-part in notmuch-show-view-part --- 16/3c05c6a494e9adc3f88dc4c1c705ba2b0997ba | 148 ++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 16/3c05c6a494e9adc3f88dc4c1c705ba2b0997ba diff --git a/16/3c05c6a494e9adc3f88dc4c1c705ba2b0997ba b/16/3c05c6a494e9adc3f88dc4c1c705ba2b0997ba new file mode 100644 index 000000000..71875c729 --- /dev/null +++ b/16/3c05c6a494e9adc3f88dc4c1c705ba2b0997ba @@ -0,0 +1,148 @@ +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 D2080431FB6 + for ; Sat, 25 May 2013 23:36:52 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 myOckCsazAax for ; + Sat, 25 May 2013 23:36:40 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU + [18.9.25.14]) + by olra.theworths.org (Postfix) with ESMTP id 96F91431FAF + for ; Sat, 25 May 2013 23:36:36 -0700 (PDT) +X-AuditID: 1209190e-b7f4f6d000005142-01-51a1ad70dec3 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id 0A.B5.20802.07DA1A15; Sun, 26 May 2013 02:36:32 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r4Q6aV91024635; + Sun, 26 May 2013 02:36:31 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4Q6aTTi031911 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Sun, 26 May 2013 02:36:30 -0400 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1UgUZ9-0005ij-Qw; Sun, 26 May 2013 02:36:27 -0400 +Date: Sun, 26 May 2013 02:36:27 -0400 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH] emacs: Don't override mm-show-part in + notmuch-show-view-part +Message-ID: <20130526063627.GQ5999@mit.edu> +References: <20130520170439.GG5999@mit.edu> + <1369080503-6866-1-git-send-email-amdragon@mit.edu> + <8761ycc19t.fsf@qmul.ac.uk> <87fvxguoxm.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87fvxguoxm.fsf@qmul.ac.uk> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsUixG6noluwdmGgwaVvJhY3WrsZLVbP5bG4 + fnMmswOzx85Zd9k9nq26xeyx5dB75gDmKC6blNSczLLUIn27BK6Mm6v+sRVcl6y4MX8ycwPj + PpEuRk4OCQETiW9PfjJB2GISF+6tZ+ti5OIQEtjHKNH34goThLORUeLa73OsEM5pJonmHz0s + EM4SRolF+ztYQPpZBFQl2jp2MILYbAIaEtv2LwezRQR0JG4fWsAOYjML6Em0z3oGtk9YIFhi + 3vQmMJtXQFviz74V7BBD5zJKfHu5lQUiIShxcuYTFohmLYkb/14CNXAA2dISy/9xgIQ5gXZ1 + 71jPDGKLCqhITDm5jW0Co9AsJN2zkHTPQuhewMi8ilE2JbdKNzcxM6c4NVm3ODkxLy+1SNdY + LzezRC81pXQTIyjYOSX5djB+Pah0iFGAg1GJh1fCYWGgEGtiWXFl7iFGSQ4mJVFezxVAIb6k + /JTKjMTijPii0pzU4kOMEhzMSiK8B9WAcrwpiZVVqUX5MClpDhYlcd4rKTf9hQTSE0tSs1NT + C1KLYLIyHBxKErwSa4AaBYtS01Mr0jJzShDSTBycIMN5gIZrg9TwFhck5hZnpkPkTzHqcmw+ + P/kdoxBLXn5eqpQ4rxFIkQBIUUZpHtwcWJJ6xSgO9JYwrwVIFQ8wwcFNegW0hAloyc3c+SBL + ShIRUlINjObtOyt4mrVviRfFLgwvf/SmNLDnS4SASLjsTt5P7tzfhI4/7To28+obrxdzWn/s + 3LrMZ7tT6adtE3SCds8VfcJ+UC5mn0PTVWvlic/YGja1SdQyrN04r/hH9no1ntcfGsIvHkhU + 5uUrsOHW/X43++ne64fvZfk0fdabWLqm9Qv7s66Duz01HimxFGckGmoxFxUnAgDJkQfeLQMA AA== +Cc: notmuch@notmuchmail.org +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: Sun, 26 May 2013 06:36:55 -0000 + +Quoth Mark Walters on May 21 at 8:13 pm: +> +> On Tue, 21 May 2013, Mark Walters 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) + +I think this is a good idea. I'm putting together a patch that cleans +up and simplifies all of the part button handling code by taking +better advantage of mm. I should have it ready in the next few days. + +> 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 -- 2.26.2