--- /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 E4420431FAF\r
+ for <notmuch@notmuchmail.org>; Tue, 8 Jan 2013 14:39:32 -0800 (PST)\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 owZeoGVjKOaa for <notmuch@notmuchmail.org>;\r
+ Tue, 8 Jan 2013 14:39:28 -0800 (PST)\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 BE198431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 8 Jan 2013 14:39:28 -0800 (PST)\r
+X-AuditID: 1209190d-b7efd6d000001a82-8f-50eca020c537\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id E6.B7.06786.020ACE05; Tue, 8 Jan 2013 17:39:28 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r08MdRUP010929; \r
+ Tue, 8 Jan 2013 17:39:27 -0500\r
+Received: from drake.dyndns.org (a069.catapulsion.net [70.36.81.69])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id r08MdOsc015382\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Tue, 8 Jan 2013 17:39:26 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1TshpL-0006pE-Bt; Tue, 08 Jan 2013 17:39:23 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: Disambiguate point placement after hiding message\r
+Date: Tue, 8 Jan 2013 17:39:19 -0500\r
+Message-Id: <1357684759-25979-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1357591189-19487-1-git-send-email-amdragon@mit.edu>\r
+References: <1357591189-19487-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixG6nrquw4E2AwZ3jghbXb85kdmD0eLbq\r
+ FnMAYxSXTUpqTmZZapG+XQJXRs+fqywFr0UrXrw/yNjAeEewi5GTQ0LAROLYoS1MELaYxIV7\r
+ 69lAbCGBfYwS389qdjFyAdnrGSWu//vDDuHsZ5KYcXgfE4Qzl1Gir72RFaSFTUBDYtv+5Ywg\r
+ toiAtMTOu7OB4hwczAJqEn+6VEDCwgI+Evf6XzGBhFkEVCUe/zMFCfMKOEg86etkhzhCUaL7\r
+ 2QSwIzgFHCU+rrzBCnGQg8S8ORtYJjDyL2BkWMUom5JbpZubmJlTnJqsW5ycmJeXWqRrpJeb\r
+ WaKXmlK6iREUMpySvDsY3x1UOsQowMGoxMNrMfNNgBBrYllxZe4hRkkOJiVR3sVzgEJ8Sfkp\r
+ lRmJxRnxRaU5qcWHGCU4mJVEeO96A+V4UxIrq1KL8mFS0hwsSuK8V1Ju+gsJpCeWpGanphak\r
+ FsFkZTg4lCR4w+cDNQoWpaanVqRl5pQgpJk4OEGG8wANLwWp4S0uSMwtzkyHyJ9i1OVoeHnj\r
+ KaMQS15+XqqUOG8hSJEASFFGaR7cHFisv2IUB3pLmDcNpIoHmCbgJr0CWsIEtGTOVLAlJYkI\r
+ KakGxvSW0wncYbu29vOVxDPyxvz5w3j1KfO5DVGzs1ZXGDJ4m90KYHgQozDJod5mbc3kD5oB\r
+ /oFaP5/8fS885VOoR3ihgsjfnQ8lXBYc/lDy2rPA+UtDQP+V9F6to4+LSqX2Flun3F8TYF/8\r
+ +vCVIzdW+y216vX/ONNl/rGXEnEXGFUu929L/pLVqsRSnJFoqMVcVJwIAH8IcLXQAgAA\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: Tue, 08 Jan 2013 22:39:33 -0000\r
+\r
+Currently, if point is in the middle of a message when the user\r
+collapses it, Emacs then displays the cursor on the header line of the\r
+next message, even though point is still on the collapsed message and\r
+even though, if you explicitly move point to the same visual location,\r
+it will be on the next message. As a result, following actions like\r
+re-expanding the message or modifying tags apply to the collapsed\r
+message, even though, visually, it looks like they will apply to the\r
+message following the collapsed message.\r
+\r
+This patch addresses this by explicitly moving point when a message is\r
+collapsed so it is visually unambiguous that the point is still on the\r
+collapsed message.\r
+---\r
+\r
+v2 should fix the strange behavior observed in v1. The added code is\r
+essentially identical to v1, but v2 adds it to\r
+notmuch-show-toggle-message---which is only used\r
+interactively---rather than the core notmuch-show-message-visible\r
+function.\r
+\r
+ emacs/notmuch-show.el | 28 +++++++++++++++++++++++-----\r
+ 1 file changed, 23 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 5751d98..6ab926c 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1789,12 +1789,30 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+ (force-window-update))\r
+ \r
+ (defun notmuch-show-toggle-message ()\r
+- "Toggle the visibility of the current message."\r
++ "Toggle the visibility of the current message.\r
++\r
++If this hides the current message, it will also move point to\r
++make it obvious it's still on the current message."\r
+ (interactive)\r
+- (let ((props (notmuch-show-get-message-properties)))\r
+- (notmuch-show-message-visible\r
+- props\r
+- (not (plist-get props :message-visible))))\r
++ (let* ((props (notmuch-show-get-message-properties))\r
++ (visible-p (not (plist-get props :message-visible))))\r
++ (notmuch-show-message-visible props visible-p)\r
++ (when (not visible-p)\r
++ (let ((ov (plist-get props :message-overlay)))\r
++ ;; If point was contained in the overlay, move it to a\r
++ ;; sensible spot that is visible and still on the same\r
++ ;; message. Strangely, the Emacs event loop doesn't move the\r
++ ;; point out of the invisible region for us like it normally\r
++ ;; does (perhaps because it doesn't know which way to go), so\r
++ ;; if we don't do this, it's visually ambiguous which message\r
++ ;; an action will apply to.\r
++ (let ((start (overlay-start ov))\r
++ (end (overlay-end ov)))\r
++ (dolist (win (get-buffer-window-list nil nil t))\r
++ (with-selected-window win\r
++ (when (and (<= start (point)) (< (point) end))\r
++ (goto-char (1- start))\r
++ (beginning-of-visual-line))))))))\r
+ (force-window-update))\r
+ \r
+ (defun notmuch-show-open-or-close-all ()\r
+-- \r
+1.7.10.4\r
+\r