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