From 06e94e089f2f1d1bc7404e5e915593a8d7bd00ac Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 11 Jan 2013 16:59:36 +1900 Subject: [PATCH] [PATCH] emacs: Fix point motion in `beginning-of-visual-line' --- 72/2c06165b3bbca72bc9a5b77a2992a80008b8ce | 129 ++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 72/2c06165b3bbca72bc9a5b77a2992a80008b8ce diff --git a/72/2c06165b3bbca72bc9a5b77a2992a80008b8ce b/72/2c06165b3bbca72bc9a5b77a2992a80008b8ce new file mode 100644 index 000000000..4fa82195c --- /dev/null +++ b/72/2c06165b3bbca72bc9a5b77a2992a80008b8ce @@ -0,0 +1,129 @@ +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 7EEF6431FB6 + for ; Thu, 10 Jan 2013 13:59:58 -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 Sd17MZIdembT for ; + Thu, 10 Jan 2013 13:59:58 -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 CD852431FAF + for ; Thu, 10 Jan 2013 13:59:57 -0800 (PST) +X-AuditID: 1209190d-b7efd6d000001a82-bf-50ef39dd6386 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id A1.DD.06786.DD93FE05; Thu, 10 Jan 2013 16:59:57 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r0ALxtWF004008; + Thu, 10 Jan 2013 16:59:55 -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 r0ALxlrB003569 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 10 Jan 2013 16:59:54 -0500 (EST) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1TtQA7-0008M8-2k; Thu, 10 Jan 2013 16:59:47 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: Fix point motion in `beginning-of-visual-line' +Date: Thu, 10 Jan 2013 16:59:36 -0500 +Message-Id: <1357855176-31653-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com> +References: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrHvX8n2AQcdJEYvrN2cyOzB6PFt1 + izmAMYrLJiU1J7MstUjfLoErY15DQsFs4YrurauYGxhf8XcxcnBICJhItN336mLkBDLFJC7c + W8/WxcjFISSwj1Hi/aSbUM4GRok70y4yQzgHmCQ2tx2CysxllFhw4iIjSD+bgIbEtv3LwWwR + AWmJnXdns4KsYBZQk/jTpQISFhZwk1hxdyI7SJhFQFVi3dQ0kDCvgIPEnc/zWCCuUJTofjaB + DcTmFPCS2Nf6HWyikICnxJ5f89gmMPIvYGRYxSibklulm5uYmVOcmqxbnJyYl5dapGukl5tZ + opeaUrqJERwwkrw7GN8dVDrEKMDBqMTDq6D+PkCINbGsuDL3EKMkB5OSKO8kA6AQX1J+SmVG + YnFGfFFpTmrxIUYJDmYlEd6WBe8ChHhTEiurUovyYVLSHCxK4rxXUm76CwmkJ5akZqemFqQW + wWRlODiUJHidgZEhJFiUmp5akZaZU4KQZuLgBBnOAzQ8EKSGt7ggMbc4Mx0if4pRl2P/k/bn + jEIsefl5qVLivDcsgIoEQIoySvPg5sAi/RWjONBbwrx+IKN4gEkCbtIroCVMQEvmTH0DsqQk + ESEl1cC46j3LjWqjleLn/KPPrXklNudi/tn2PWZtdpwnvl92f53etlZxo2qTUEClqOFdpemZ + CZcXsb5c0ipXySScGrORteI6q32W7LKZzOf1arV1Nslfdhb8s45Zdd1a2xd3nrtMvim65J3Q + rdaNzr1vjnwUj4z0vpZrm3XlvMMPU+ODz/7kalx45xelxFKckWioxVxUnAgAvFgnWc8CAAA= +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: Thu, 10 Jan 2013 21:59:58 -0000 + +`beginning-of-visual-line' interacts poorly with our use of invisible +overlays and often moves point into the previous message or part even +though it looks like it's in the next message or part (e.g., if you +press C-a on a header line and the previous message is invisible, +point will move into the previous message, even though it appears to +still be on the header line). This advises `beginning-of-visual-line' +to address this behavior. +--- + +This is a completely different approach that should fix the HTML +problem, as well as other problems. I also have an alternate approach +to this that sets 'field properties on the header line and part +buttons, which has the same effect, but seems to have more +side-effects (e.g., if point is at the end of a part button, C-a won't +go to the beginning). This patch, OTOH, strikes directly at the +strange (maybe even buggy) behavior of beginning-of-visual-line. The +downside is that it's advice, and advice always feels a little +sketchy. + + emacs/notmuch-show.el | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 5751d98..6f5c53a 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1120,6 +1120,28 @@ function is used." + (notmuch-show-goto-first-wanted-message) + (current-buffer))) + ++(defadvice beginning-of-visual-line (around constrain-invisible activate) ++ "Fix point motion around invisible overlays. ++ ++In `notmuch-show-mode', we often hide overlays that end with a ++newline (e.g., messages, parts, etc). This has the effect of ++collapsing the overlayed text into the beginning of the next ++line. Unfortunately, this causes `visual-motion' and hence ++`beginning-of-visual-line' to move to the first character of the ++invisible overlay rather than the more obvious first character of ++the visible line. Visually, these two points are ++indistinguishable, but this tends to make actions mysteriously ++apply to the previous message when it looks like they should ++apply to the next message. ++ ++This advice fixes this behavior in `notmuch-show-mode' by ++restricting the motion of `beginning-of-visual-line'." ++ (if (eq major-mode 'notmuch-show-mode) ++ (save-restriction ++ (narrow-to-region (line-beginning-position) (point-max)) ++ ad-do-it) ++ ad-do-it)) ++ + (defun notmuch-show-build-buffer () + (let ((inhibit-read-only t)) + +-- +1.7.10.4 + -- 2.26.2