Re: [PATCH] emacs: Fix point motion in `beginning-of-visual-line'
authorAustin Clements <amdragon@MIT.EDU>
Thu, 10 Jan 2013 22:39:13 +0000 (17:39 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:04 +0000 (09:53 -0800)
2d/1d28e5acfd2e8867122059573bbea7c122d207 [new file with mode: 0644]

diff --git a/2d/1d28e5acfd2e8867122059573bbea7c122d207 b/2d/1d28e5acfd2e8867122059573bbea7c122d207
new file mode 100644 (file)
index 0000000..5b52efb
--- /dev/null
@@ -0,0 +1,136 @@
+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 8ECAB431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 14:39:18 -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 3axfgAMha136 for <notmuch@notmuchmail.org>;\r
+       Thu, 10 Jan 2013 14:39:18 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+       [18.7.68.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id E42AA431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 14:39:17 -0800 (PST)\r
+X-AuditID: 12074424-b7f4e6d0000004ca-33-50ef4314612f\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id D4.FE.01226.4134FE05; Thu, 10 Jan 2013 17:39:16 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r0AMdFTG015263\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 17:39:16 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\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 r0AMdEH4009983\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT)\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 17:39:15 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>) id 1TtQmI-0005Z6-0d\r
+       for notmuch@notmuchmail.org; Thu, 10 Jan 2013 17:39:14 -0500\r
+Date: Thu, 10 Jan 2013 17:39:13 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: Fix point motion in `beginning-of-visual-line'\r
+Message-ID: <20130110223836.GV17581@mit.edu>\r
+References: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com>\r
+       <1357855176-31653-1-git-send-email-amdragon@mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1357855176-31653-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFvrFIsWRmVeSWpSXmKPExsUixG6noivi/D7A4P9PKYvrN2cyOzB6PFt1\r
+       izmAMYrLJiU1J7MstUjfLoEr48fP/+wFt0QrOlZ9YWtgPCnYxcjJISFgInFhdSMLhC0mceHe\r
+       erYuRi4OIYF9jBLn7z9ihnDOMUp86H8P5bxnkrj/5D0LhHOIUWL1u2lg/SwCqhK/zhxhBrHZ\r
+       BDQktu1fzghiiwhIS+y8O5sVxBYW8JL4/+8dexcjBwevgI7Er/P1EHMaGCXO9jwC6+UVEJQ4\r
+       OfMJ2ExmAS2JG/9eMoHUMwPNWf6PAyTMKeAosaBxLRuILSqgIjHl5Da2CYyCs5B0z0LSPQuh\r
+       ewEj8ypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdc73czBK91JTSTYzgYHVR2cHYfEjpEKMAB6MS\r
+       D2+F5vsAIdbEsuLK3EOMkhxMSqK8hnZAIb6k/JTKjMTijPii0pzUYmB4cDArifC2LHgXIMSb\r
+       klhZlVqUD5OS5mBREue9nnLTX0ggPbEkNTs1tSC1CCYrw8GhJMH71RFoqGBRanpqRVpmTglC\r
+       momDE2Q4D9BwdiegGt7igsTc4sx0iPwpRl2O/U/anzMKseTl56VKifOygRQJgBRllObBzYEl\r
+       mVeM4kBvCfMygVTxABMU3KRXQEuYgJbMmfoGZElJIkJKqoHR8ePiw66OhpN4P59Y+XGvAKsM\r
+       V3DdjjMbVpVPlGue52zn9e3xrxLRDU9Ln65S7dP4f5VzMoftLXcFts+TOqyurj4cYzbH7+hx\r
+       f64tM4zb+O6qn3dZZLgwQi1TY3O+/jzXgAObb37qT+UQnWLxYfncM9GXZp+dqaLm224iv/bo\r
+       L/fS7zIK73nvK7EUZyQaajEXFScCAKdNSJINAwAA\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, 10 Jan 2013 22:39:18 -0000\r
+\r
+After some IRC discussion, Mark and I have found that my patch doesn't\r
+fix everything related to w3m that Mark's patch does (though my patch\r
+does fix other things not related to w3m).\r
+\r
+Quoth myself on Jan 10 at  4:59 pm:\r
+> `beginning-of-visual-line' interacts poorly with our use of invisible\r
+> overlays and often moves point into the previous message or part even\r
+> though it looks like it's in the next message or part (e.g., if you\r
+> press C-a on a header line and the previous message is invisible,\r
+> point will move into the previous message, even though it appears to\r
+> still be on the header line).  This advises `beginning-of-visual-line'\r
+> to address this behavior.\r
+> ---\r
+> \r
+> This is a completely different approach that should fix the HTML\r
+> problem, as well as other problems.  I also have an alternate approach\r
+> to this that sets 'field properties on the header line and part\r
+> buttons, which has the same effect, but seems to have more\r
+> side-effects (e.g., if point is at the end of a part button, C-a won't\r
+> go to the beginning).  This patch, OTOH, strikes directly at the\r
+> strange (maybe even buggy) behavior of beginning-of-visual-line.  The\r
+> downside is that it's advice, and advice always feels a little\r
+> sketchy.\r
+> \r
+>  emacs/notmuch-show.el |   22 ++++++++++++++++++++++\r
+>  1 file changed, 22 insertions(+)\r
+> \r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 5751d98..6f5c53a 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -1120,6 +1120,28 @@ function is used."\r
+>      (notmuch-show-goto-first-wanted-message)\r
+>      (current-buffer)))\r
+>  \r
+> +(defadvice beginning-of-visual-line (around constrain-invisible activate)\r
+> +  "Fix point motion around invisible overlays.\r
+> +\r
+> +In `notmuch-show-mode', we often hide overlays that end with a\r
+> +newline (e.g., messages, parts, etc).  This has the effect of\r
+> +collapsing the overlayed text into the beginning of the next\r
+> +line.  Unfortunately, this causes `visual-motion' and hence\r
+> +`beginning-of-visual-line' to move to the first character of the\r
+> +invisible overlay rather than the more obvious first character of\r
+> +the visible line.  Visually, these two points are\r
+> +indistinguishable, but this tends to make actions mysteriously\r
+> +apply to the previous message when it looks like they should\r
+> +apply to the next message.\r
+> +\r
+> +This advice fixes this behavior in `notmuch-show-mode' by\r
+> +restricting the motion of `beginning-of-visual-line'."\r
+> +  (if (eq major-mode 'notmuch-show-mode)\r
+> +      (save-restriction\r
+> +    (narrow-to-region (line-beginning-position) (point-max))\r
+> +    ad-do-it)\r
+> +    ad-do-it))\r
+> +\r
+>  (defun notmuch-show-build-buffer ()\r
+>    (let ((inhibit-read-only t))\r
+>  \r