--- /dev/null
+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 68B3F431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 29 May 2013 18:14:06 -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 WrjHLkiiSPk7 for <notmuch@notmuchmail.org>;\r
+ Wed, 29 May 2013 18:13:58 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+ [18.7.68.35])\r
+ by olra.theworths.org (Postfix) with ESMTP id 76B20431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 29 May 2013 18:13:58 -0700 (PDT)\r
+X-AuditID: 12074423-b7f826d000001438-61-51a6a7d6fe27\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id DD.9D.05176.6D7A6A15; Wed, 29 May 2013 21:13:58 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r4U1Dt6H015111; \r
+ Wed, 29 May 2013 21:13:55 -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 r4U1DqVn003002\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Wed, 29 May 2013 21:13:54 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1UhrR9-0003Yo-Ta; Wed, 29 May 2013 21:13:51 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 0/5] emacs: Part command improvements\r
+Date: Wed, 29 May 2013 21:13:43 -0400\r
+Message-Id: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrCIsWRmVeSWpSXmKPExsUixG6nrntt+bJAg7m7+SxWz+WxuH5zJrMD\r
+ k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlbH251SWgmfqFQ9Ob2VpYPws38XIySEhYCLx\r
+ 4ek1RghbTOLCvfVsXYxcHEIC+xgl7l65xQ7hbGSUmLB+MVTmNJNE84Y2JghnLqPE2hcX2EH6\r
+ 2QQ0JLbtXw42S0RAWmLn3dmsIDazgKzEj/N/wGxhAQuJd0dawepZBFQlHj+aADSVg4NXwEFi\r
+ xiEXiDMUJbqfTWCbwMi7gJFhFaNsSm6Vbm5iZk5xarJucXJiXl5qka6ZXm5miV5qSukmRnBg\r
+ uCjvYPxzUOkQowAHoxIP7watZYFCrIllxZW5hxglOZiURHnXLAUK8SXlp1RmJBZnxBeV5qQW\r
+ H2KU4GBWEuFdow2U401JrKxKLcqHSUlzsCiJ815LuekvJJCeWJKanZpakFoEk5Xh4FCS4C1a\r
+ BtQoWJSanlqRlplTgpBm4uAEGc4DNFwJpIa3uCAxtzgzHSJ/ilFRSpzXFiQhAJLIKM2D64VF\r
+ 7itGcaBXhCFW8ACjHq77FdBgJqDB4syLQQaXJCKkpBoYvRluf/Y6eWH7ajGh2b31LALeOeZH\r
+ Lr1155p+loHvbqLBYp8n59wnBpTWzfncPD+ij9n0kNW3Ss737E/Kr0fyVdnxnBRe9Sd6UrJz\r
+ euzea73FXtfeNyW02rjyTM3Of3h25q+Am7t2bprwWtL81WqHa+YTOR96qqYXOJVz6YjolKQ6\r
+ 3jSskf6jxFKckWioxVxUnAgA6SomZ7cCAAA=\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: Thu, 30 May 2013 01:14:06 -0000\r
+\r
+This is v2 of id:87zjvghx82.fsf@qmul.ac.uk. In addition to some\r
+general improvements, this fixes the handling of part overlays in\r
+indented messages, removes the special part button map entirely in\r
+favor of the "." submap, and adds a NEWS patch.\r
+\r
+The diff from v1 follows\r
+\r
+diff --git a/NEWS b/NEWS\r
+index a7f2ec6..23f4c6a 100644\r
+--- a/NEWS\r
++++ b/NEWS\r
+@@ -61,6 +61,22 @@ notmuch-vim, but of course that is their decision.\r
+ Emacs Interface\r
+ ---------------\r
+ \r
++New keymap to view/save parts\r
++\r
++ To view or save a single MIME part of a message, use the new "."\r
++ submap (e.g., ". s" to save, ". v" to view). Previously, these keys\r
++ were only available when point was on a part button and they did not\r
++ have the "." prefix, so they were difficult to invoke (impossible if\r
++ a part did not have a button) and clashed with other bindings.\r
++ These new bindings also appear in show's help, so you don't have to\r
++ memorize them.\r
++\r
++Default part save directory is now `mm-default-directory`\r
++\r
++ Previously, notmuch offered to save parts and attachments to a mix\r
++ of `mm-default-directory`, `mailcap-download-directory`, and `~/`.\r
++ This has been standardized on `mm-default-directory`.\r
++\r
+ No Emacs 22 support\r
+ \r
+ The Emacs 22 support added late 2010 was sufficient only for a short\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 09ce25e..2186783 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -360,21 +360,17 @@ OBJECT."\r
+ below\r
+ string))\r
+ \r
+-(defun notmuch-put-text-property-if-nil (start end property value\r
+- &optional object)\r
+- "Like `put-text-property', but only set the property where it is nil."\r
++(defun notmuch-map-text-property (start end prop func &optional object)\r
++ "Transform text property PROP using FUNC.\r
++\r
++Applies FUNC to each distinct value of the text property PROP\r
++between START and END of OBJECT, setting PROP to the value\r
++returned by FUNC."\r
+ (while (< start end)\r
+- (let ((start-nil (text-property-any start end property nil object)))\r
+- (if (null start-nil)\r
+- ;; There are no more nil regions; exit the loop\r
+- (setq start end)\r
+- ;; Find the end of the nil region\r
+- (let ((end-nil\r
+- (or (text-property-not-all start-nil end property nil object)\r
+- end)))\r
+- ;; Set the property\r
+- (put-text-property start-nil end-nil property value object)\r
+- (setq start end-nil))))))\r
++ (let ((value (get-text-property start prop object))\r
++ (next (next-single-property-change start prop object end)))\r
++ (put-text-property start next prop (funcall func value) object)\r
++ (setq start next))))\r
+ \r
+ (defun notmuch-logged-error (msg &optional extra)\r
+ "Log MSG and EXTRA to *Notmuch errors* and signal MSG.\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 380b144..613e666 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -466,7 +466,6 @@ message at DEPTH in the current thread."\r
+ \r
+ (define-button-type 'notmuch-show-part-button-type\r
+ 'action 'notmuch-show-part-button-default\r
+- 'keymap 'notmuch-show-part-button-map\r
+ 'follow-link t\r
+ 'face 'message-mml\r
+ :supertype 'notmuch-button-type)\r
+@@ -843,8 +842,15 @@ If HIDE is non-nil then initially hide this part."\r
+ (insert "\n"))\r
+ (notmuch-show-create-part-overlays msg beg (point) hide)\r
+ ;; Record part information. Since we already inserted subparts,\r
+- ;; don't override exiting :notmuch-part properties.\r
+- (notmuch-put-text-property-if-nil beg (point) :notmuch-part part)))\r
++ ;; don't override existing :notmuch-part properties.\r
++ (notmuch-map-text-property beg (point) :notmuch-part\r
++ (lambda (v) (or v part)))\r
++ ;; Make :notmuch-part front sticky and rear non-sticky so it stays\r
++ ;; applied to the beginning of each line when we indent the message.\r
++ (notmuch-map-text-property beg (point) 'front-sticky\r
++ (lambda (v) (pushnew :notmuch-part v)))\r
++ (notmuch-map-text-property beg (point) 'rear-nonsticky\r
++ (lambda (v) (pushnew :notmuch-part v)))))\r
+ \r
+ (defun notmuch-show-insert-body (msg body depth)\r
+ "Insert the body BODY at depth DEPTH in the current thread."\r
+@@ -1194,11 +1200,6 @@ reset based on the original query."\r
+ "Submap for part commands")\r
+ (fset 'notmuch-show-part-map notmuch-show-part-map)\r
+ \r
+-(defvar notmuch-show-part-button-map\r
+- (make-composed-keymap notmuch-show-part-map button-map)\r
+- "Keymap for part button commands")\r
+-(fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
+-\r
+ (defvar notmuch-show-mode-map\r
+ (let ((map (make-sparse-keymap)))\r
+ (define-key map "?" 'notmuch-help)\r
+@@ -1365,7 +1366,7 @@ Some useful entries are:\r
+ (get-text-property (point) :notmuch-message-properties)))\r
+ \r
+ (defun notmuch-show-get-part-properties ()\r
+- "Return the properties of the part containing point.\r
++ "Return the properties of the innermost part containing point.\r
+ \r
+ This is the part property list retrieved from the CLI. Signals\r
+ an error if there is no part containing point."\r
+\r
+\r