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

diff --git a/72/2c06165b3bbca72bc9a5b77a2992a80008b8ce b/72/2c06165b3bbca72bc9a5b77a2992a80008b8ce
new file mode 100644 (file)
index 0000000..4fa8219
--- /dev/null
@@ -0,0 +1,129 @@
+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 7EEF6431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 13:59:58 -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 Sd17MZIdembT for <notmuch@notmuchmail.org>;\r
+       Thu, 10 Jan 2013 13:59:58 -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 CD852431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 13:59:57 -0800 (PST)\r
+X-AuditID: 1209190d-b7efd6d000001a82-bf-50ef39dd6386\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id A1.DD.06786.DD93FE05; Thu, 10 Jan 2013 16:59:57 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r0ALxtWF004008; \r
+       Thu, 10 Jan 2013 16:59:55 -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 r0ALxlrB003569\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 10 Jan 2013 16:59:54 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1TtQA7-0008M8-2k; Thu, 10 Jan 2013 16:59:47 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Fix point motion in `beginning-of-visual-line'\r
+Date: Thu, 10 Jan 2013 16:59:36 -0500\r
+Message-Id: <1357855176-31653-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrHvX8n2AQcdJEYvrN2cyOzB6PFt1\r
+       izmAMYrLJiU1J7MstUjfLoErY15DQsFs4YrurauYGxhf8XcxcnBICJhItN336mLkBDLFJC7c\r
+       W8/WxcjFISSwj1Hi/aSbUM4GRok70y4yQzgHmCQ2tx2CysxllFhw4iIjSD+bgIbEtv3LwWwR\r
+       AWmJnXdns4KsYBZQk/jTpQISFhZwk1hxdyI7SJhFQFVi3dQ0kDCvgIPEnc/zWCCuUJTofjaB\r
+       DcTmFPCS2Nf6HWyikICnxJ5f89gmMPIvYGRYxSibklulm5uYmVOcmqxbnJyYl5dapGukl5tZ\r
+       opeaUrqJERwwkrw7GN8dVDrEKMDBqMTDq6D+PkCINbGsuDL3EKMkB5OSKO8kA6AQX1J+SmVG\r
+       YnFGfFFpTmrxIUYJDmYlEd6WBe8ChHhTEiurUovyYVLSHCxK4rxXUm76CwmkJ5akZqemFqQW\r
+       wWRlODiUJHidgZEhJFiUmp5akZaZU4KQZuLgBBnOAzQ8EKSGt7ggMbc4Mx0if4pRl2P/k/bn\r
+       jEIsefl5qVLivDcsgIoEQIoySvPg5sAi/RWjONBbwrx+IKN4gEkCbtIroCVMQEvmTH0DsqQk\r
+       ESEl1cC46j3LjWqjleLn/KPPrXklNudi/tn2PWZtdpwnvl92f53etlZxo2qTUEClqOFdpemZ\r
+       CZcXsb5c0ipXySScGrORteI6q32W7LKZzOf1arV1Nslfdhb8s45Zdd1a2xd3nrtMvim65J3Q\r
+       rdaNzr1vjnwUj4z0vpZrm3XlvMMPU+ODz/7kalx45xelxFKckWioxVxUnAgAvFgnWc8CAAA=\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 21:59:58 -0000\r
+\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
+-- \r
+1.7.10.4\r
+\r