From: Austin Clements Date: Thu, 10 Jan 2013 22:39:13 +0000 (+1900) Subject: Re: [PATCH] emacs: Fix point motion in `beginning-of-visual-line' X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=39c775eb61cd53ad629b19b6c74ef0e94b14d8f6;p=notmuch-archives.git Re: [PATCH] emacs: Fix point motion in `beginning-of-visual-line' --- diff --git a/2d/1d28e5acfd2e8867122059573bbea7c122d207 b/2d/1d28e5acfd2e8867122059573bbea7c122d207 new file mode 100644 index 000000000..5b52efb34 --- /dev/null +++ b/2d/1d28e5acfd2e8867122059573bbea7c122d207 @@ -0,0 +1,136 @@ +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 8ECAB431FB6 + for ; Thu, 10 Jan 2013 14:39:18 -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 3axfgAMha136 for ; + Thu, 10 Jan 2013 14:39:18 -0800 (PST) +Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU + [18.7.68.36]) + by olra.theworths.org (Postfix) with ESMTP id E42AA431FAF + for ; Thu, 10 Jan 2013 14:39:17 -0800 (PST) +X-AuditID: 12074424-b7f4e6d0000004ca-33-50ef4314612f +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id D4.FE.01226.4134FE05; Thu, 10 Jan 2013 17:39:16 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r0AMdFTG015263 + for ; Thu, 10 Jan 2013 17:39:16 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id r0AMdEH4009983 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) + for ; Thu, 10 Jan 2013 17:39:15 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) id 1TtQmI-0005Z6-0d + for notmuch@notmuchmail.org; Thu, 10 Jan 2013 17:39:14 -0500 +Date: Thu, 10 Jan 2013 17:39:13 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs: Fix point motion in `beginning-of-visual-line' +Message-ID: <20130110223836.GV17581@mit.edu> +References: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com> + <1357855176-31653-1-git-send-email-amdragon@mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1357855176-31653-1-git-send-email-amdragon@mit.edu> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFvrFIsWRmVeSWpSXmKPExsUixG6noivi/D7A4P9PKYvrN2cyOzB6PFt1 + izmAMYrLJiU1J7MstUjfLoEr48fP/+wFt0QrOlZ9YWtgPCnYxcjJISFgInFhdSMLhC0mceHe + erYuRi4OIYF9jBLn7z9ihnDOMUp86H8P5bxnkrj/5D0LhHOIUWL1u2lg/SwCqhK/zhxhBrHZ + BDQktu1fzghiiwhIS+y8O5sVxBYW8JL4/+8dexcjBwevgI7Er/P1EHMaGCXO9jwC6+UVEJQ4 + OfMJ2ExmAS2JG/9eMoHUMwPNWf6PAyTMKeAosaBxLRuILSqgIjHl5Da2CYyCs5B0z0LSPQuh + ewEj8ypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdc73czBK91JTSTYzgYHVR2cHYfEjpEKMAB6MS + D2+F5vsAIdbEsuLK3EOMkhxMSqK8hnZAIb6k/JTKjMTijPii0pzUYmB4cDArifC2LHgXIMSb + klhZlVqUD5OS5mBREue9nnLTX0ggPbEkNTs1tSC1CCYrw8GhJMH71RFoqGBRanpqRVpmTglC + momDE2Q4D9BwdiegGt7igsTc4sx0iPwpRl2O/U/anzMKseTl56VKifOygRQJgBRllObBzYEl + mVeM4kBvCfMygVTxABMU3KRXQEuYgJbMmfoGZElJIkJKqoHR8ePiw66OhpN4P59Y+XGvAKsM + V3DdjjMbVpVPlGue52zn9e3xrxLRDU9Ln65S7dP4f5VzMoftLXcFts+TOqyurj4cYzbH7+hx + f64tM4zb+O6qn3dZZLgwQi1TY3O+/jzXgAObb37qT+UQnWLxYfncM9GXZp+dqaLm224iv/bo + L/fS7zIK73nvK7EUZyQaajEXFScCAKdNSJINAwAA +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 22:39:18 -0000 + +After some IRC discussion, Mark and I have found that my patch doesn't +fix everything related to w3m that Mark's patch does (though my patch +does fix other things not related to w3m). + +Quoth myself on Jan 10 at 4:59 pm: +> `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)) +>