[PATCH v2] emacs: Don't override mm-show-part in notmuch-show-view-part
authorAustin Clements <amdragon@MIT.EDU>
Sun, 26 May 2013 06:34:46 +0000 (02:34 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:55:01 +0000 (09:55 -0800)
58/e2061b7a8815a1b9e4d8098df86b0d07f38085 [new file with mode: 0644]

diff --git a/58/e2061b7a8815a1b9e4d8098df86b0d07f38085 b/58/e2061b7a8815a1b9e4d8098df86b0d07f38085
new file mode 100644 (file)
index 0000000..1b275c3
--- /dev/null
@@ -0,0 +1,127 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 56EEA431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 25 May 2013 23:35:09 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id wh1DS0vvz3v2 for <notmuch@notmuchmail.org>;\r
+       Sat, 25 May 2013 23:35:00 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
+       [18.9.25.13])\r
+       by olra.theworths.org (Postfix) with ESMTP id 531C9431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 25 May 2013 23:35:00 -0700 (PDT)\r
+X-AuditID: 1209190d-b7f966d000000944-cb-51a1ad11cb17\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id F3.DF.02372.11DA1A15; Sun, 26 May 2013 02:34:57 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4Q6YpmS018417; \r
+       Sun, 26 May 2013 02:34:52 -0400\r
+Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net\r
+       [76.21.105.205]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4Q6YmGM031619\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sun, 26 May 2013 02:34:50 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1UgUXZ-000736-Df; Sun, 26 May 2013 02:34:49 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: Don't override mm-show-part in\r
+       notmuch-show-view-part\r
+Date: Sun, 26 May 2013 02:34:46 -0400\r
+Message-Id: <1369550086-26986-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <8761ycc19t.fsf@qmul.ac.uk>\r
+References: <8761ycc19t.fsf@qmul.ac.uk>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsUixCmqrSu4dmGgQe93Y4sbrd2MFqvn8lhc\r
+       vzmT2YHZY+esu+wez1bdYvbYcug9cwBzFJdNSmpOZllqkb5dAlfGl8ebWQsuC1fcm/mRqYHx\r
+       H38XIyeHhICJRMvEp2wQtpjEhXvrwWwhgX2MEtv/l3YxcgHZGxklnj5Zww7hnGaS+Pt5HQtE\r
+       1VxGiQf9UiA2m4CGxLb9yxlBbBEBaYmdd2ezgtjMArESjW+XMXcxcnAICwRILPqtC2KyCKhK\r
+       bFsTDVLBK+Ag0dFyixHiBkWJ7mcTwG7gBJrY3fyGHWKTusTrh9/YJjDyL2BkWMUom5JbpZub\r
+       mJlTnJqsW5ycmJeXWqRrpJebWaKXmlK6iREcVpK8OxjfHVQ6xCjAwajEwyvhsDBQiDWxrLgy\r
+       9xCjJAeTkiiv5wqgEF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHeg2pAOd6UxMqq1KJ8mJQ0B4uS\r
+       OO+VlJv+QgLpiSWp2ampBalFMFkZDg4lCd4bq4EaBYtS01Mr0jJzShDSTBycIMN5gIa/Banh\r
+       LS5IzC3OTIfIn2JUlBLn/QSSEABJZJTmwfXC4v4VozjQK8K8f0GqeIApA677FdBgJqDBN3Pn\r
+       gwwuSURISTUwtse8OR8q+sLwq9fHdwZPs5XiQuq0PnrzXZpRMmXmwuAem/1nb5zhlj+W9+y8\r
+       otl3P69V8i8ab5usXqXdqT1DOF8l6bqxcuwMTl97K/k3mitDMruk4rriV64L5+S6tnDxoj1C\r
+       OxsuqKnzphtMnSZ7dQufSEr63Waz2yzfki8KutWvLFqtI8mqxFKckWioxVxUnAgAmvmhVNYC        AAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 26 May 2013 06:35:13 -0000\r
+\r
+Previously, notmuch-show-view-part overrode the function binding of\r
+mm-show-part to redirect it to notmuch-show-save-part to get notmuch's\r
+default file name handling in case mm-display-part decided to fall\r
+back to saving the part.  In addition to being messy, this depended on\r
+the now-deprecated dynamic binding behavior of flet.\r
+\r
+This patch removes the mm-show-part override in favor of passing the\r
+file name in to mm-show-part the way it expects, so we get its default\r
+file name handling.  It's not clear why we didn't do this before;\r
+mm-show-part has supported default file names since at least Emacs\r
+23.1.\r
+---\r
+This version overrides the default save directory to make it\r
+consistent with `notmuch-show-save-part'.\r
+\r
+ emacs/notmuch-show.el |   23 +++++++++--------------\r
+ 1 file changed, 9 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 423dd58..d773396 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -528,20 +528,15 @@ message at DEPTH in the current thread."\r
\r
+ (defun notmuch-show-view-part (message-id nth &optional filename content-type )\r
+   (notmuch-with-temp-part-buffer message-id nth\r
+-    ;; set mm-inlined-types to nil to force an external viewer\r
+-    (let ((handle (mm-make-handle (current-buffer) (list content-type)))\r
+-        (mm-inlined-types nil))\r
+-      ;; We override mm-save-part as notmuch-show-save-part is better\r
+-      ;; since it offers the filename. We need to lexically bind\r
+-      ;; everything we need for notmuch-show-save-part to prevent\r
+-      ;; potential dynamic shadowing.\r
+-      (lexical-let ((message-id message-id)\r
+-                  (nth nth)\r
+-                  (filename filename)\r
+-                  (content-type content-type))\r
+-      (flet ((mm-save-part (&rest args) (notmuch-show-save-part\r
+-                                         message-id nth filename content-type)))\r
+-        (mm-display-part handle))))))\r
++    (let* ((disposition (if filename `(attachment (filename . ,filename))))\r
++         (handle (mm-make-handle (current-buffer) (list content-type)\r
++                                 nil nil disposition))\r
++         ;; Set the default save directory to be consistent with\r
++         ;; `notmuch-show-save-part'.\r
++         (mm-default-directory (or mailcap-download-directory "~/"))\r
++         ;; set mm-inlined-types to nil to force an external viewer\r
++         (mm-inlined-types nil))\r
++      (mm-display-part handle))))\r
\r
+ (defun notmuch-show-interactively-view-part (message-id nth &optional filename content-type)\r
+   (notmuch-with-temp-part-buffer message-id nth\r
+-- \r
+1.7.10.4\r
+\r