From 64dc7d3d99fc2cf57e21d211085bc81550254a10 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 27 May 2013 02:34:46 +2000 Subject: [PATCH] [PATCH v2] emacs: Don't override mm-show-part in notmuch-show-view-part --- 58/e2061b7a8815a1b9e4d8098df86b0d07f38085 | 127 ++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 58/e2061b7a8815a1b9e4d8098df86b0d07f38085 diff --git a/58/e2061b7a8815a1b9e4d8098df86b0d07f38085 b/58/e2061b7a8815a1b9e4d8098df86b0d07f38085 new file mode 100644 index 000000000..1b275c35b --- /dev/null +++ b/58/e2061b7a8815a1b9e4d8098df86b0d07f38085 @@ -0,0 +1,127 @@ +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 56EEA431FAF + for ; Sat, 25 May 2013 23:35:09 -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 wh1DS0vvz3v2 for ; + Sat, 25 May 2013 23:35:00 -0700 (PDT) +Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id 531C9431FAE + for ; Sat, 25 May 2013 23:35:00 -0700 (PDT) +X-AuditID: 1209190d-b7f966d000000944-cb-51a1ad11cb17 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id F3.DF.02372.11DA1A15; Sun, 26 May 2013 02:34:57 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4Q6YpmS018417; + Sun, 26 May 2013 02:34:52 -0400 +Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net + [76.21.105.205]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4Q6YmGM031619 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sun, 26 May 2013 02:34:50 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1UgUXZ-000736-Df; Sun, 26 May 2013 02:34:49 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2] emacs: Don't override mm-show-part in + notmuch-show-view-part +Date: Sun, 26 May 2013 02:34:46 -0400 +Message-Id: <1369550086-26986-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <8761ycc19t.fsf@qmul.ac.uk> +References: <8761ycc19t.fsf@qmul.ac.uk> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsUixCmqrSu4dmGgQe93Y4sbrd2MFqvn8lhc + vzmT2YHZY+esu+wez1bdYvbYcug9cwBzFJdNSmpOZllqkb5dAlfGl8ebWQsuC1fcm/mRqYHx + H38XIyeHhICJRMvEp2wQtpjEhXvrwWwhgX2MEtv/l3YxcgHZGxklnj5Zww7hnGaS+Pt5HQtE + 1VxGiQf9UiA2m4CGxLb9yxlBbBEBaYmdd2ezgtjMArESjW+XMXcxcnAICwRILPqtC2KyCKhK + bFsTDVLBK+Ag0dFyixHiBkWJ7mcTwG7gBJrY3fyGHWKTusTrh9/YJjDyL2BkWMUom5JbpZub + mJlTnJqsW5ycmJeXWqRrpJebWaKXmlK6iREcVpK8OxjfHVQ6xCjAwajEwyvhsDBQiDWxrLgy + 9xCjJAeTkiiv5wqgEF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHeg2pAOd6UxMqq1KJ8mJQ0B4uS + OO+VlJv+QgLpiSWp2ampBalFMFkZDg4lCd4bq4EaBYtS01Mr0jJzShDSTBycIMN5gIa/Banh + LS5IzC3OTIfIn2JUlBLn/QSSEABJZJTmwfXC4v4VozjQK8K8f0GqeIApA677FdBgJqDBN3Pn + gwwuSURISTUwtse8OR8q+sLwq9fHdwZPs5XiQuq0PnrzXZpRMmXmwuAem/1nb5zhlj+W9+y8 + otl3P69V8i8ab5usXqXdqT1DOF8l6bqxcuwMTl97K/k3mitDMruk4rriV64L5+S6tnDxoj1C + OxsuqKnzphtMnSZ7dQufSEr63Waz2yzfki8KutWvLFqtI8mqxFKckWioxVxUnAgAmvmhVNYC AAA= +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:35:13 -0000 + +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. +--- +This version overrides the default save directory to make it +consistent with `notmuch-show-save-part'. + + emacs/notmuch-show.el | 23 +++++++++-------------- + 1 file changed, 9 insertions(+), 14 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 423dd58..d773396 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -528,20 +528,15 @@ 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)) ++ ;; Set the default save directory to be consistent with ++ ;; `notmuch-show-save-part'. ++ (mm-default-directory (or mailcap-download-directory "~/")) ++ ;; set mm-inlined-types to nil to force an external viewer ++ (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 + -- 2.26.2