Re: [PATCH v4 08/16] reorganize indexing of multipart/signed and multipart/encrypted
[notmuch-archives.git] / 72 / 2c06165b3bbca72bc9a5b77a2992a80008b8ce
1 Return-Path: <amdragon@mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 7EEF6431FB6\r
6         for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 13:59:58 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id Sd17MZIdembT for <notmuch@notmuchmail.org>;\r
16         Thu, 10 Jan 2013 13:59:58 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
18         [18.9.25.13])\r
19         by olra.theworths.org (Postfix) with ESMTP id CD852431FAF\r
20         for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 13:59:57 -0800 (PST)\r
21 X-AuditID: 1209190d-b7efd6d000001a82-bf-50ef39dd6386\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id A1.DD.06786.DD93FE05; Thu, 10 Jan 2013 16:59:57 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r0ALxtWF004008; \r
27         Thu, 10 Jan 2013 16:59:55 -0500\r
28 Received: from drake.dyndns.org (a069.catapulsion.net [70.36.81.69])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id r0ALxlrB003569\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 10 Jan 2013 16:59:54 -0500 (EST)\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1TtQA7-0008M8-2k; Thu, 10 Jan 2013 16:59:47 -0500\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH] emacs: Fix point motion in `beginning-of-visual-line'\r
40 Date: Thu, 10 Jan 2013 16:59:36 -0500\r
41 Message-Id: <1357855176-31653-1-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.10.4\r
43 In-Reply-To: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com>\r
44 References: <1357852215-16788-1-git-send-email-markwalters1009@gmail.com>\r
45 X-Brightmail-Tracker:\r
46  H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrHvX8n2AQcdJEYvrN2cyOzB6PFt1\r
47         izmAMYrLJiU1J7MstUjfLoErY15DQsFs4YrurauYGxhf8XcxcnBICJhItN336mLkBDLFJC7c\r
48         W8/WxcjFISSwj1Hi/aSbUM4GRok70y4yQzgHmCQ2tx2CysxllFhw4iIjSD+bgIbEtv3LwWwR\r
49         AWmJnXdns4KsYBZQk/jTpQISFhZwk1hxdyI7SJhFQFVi3dQ0kDCvgIPEnc/zWCCuUJTofjaB\r
50         DcTmFPCS2Nf6HWyikICnxJ5f89gmMPIvYGRYxSibklulm5uYmVOcmqxbnJyYl5dapGukl5tZ\r
51         opeaUrqJERwwkrw7GN8dVDrEKMDBqMTDq6D+PkCINbGsuDL3EKMkB5OSKO8kA6AQX1J+SmVG\r
52         YnFGfFFpTmrxIUYJDmYlEd6WBe8ChHhTEiurUovyYVLSHCxK4rxXUm76CwmkJ5akZqemFqQW\r
53         wWRlODiUJHidgZEhJFiUmp5akZaZU4KQZuLgBBnOAzQ8EKSGt7ggMbc4Mx0if4pRl2P/k/bn\r
54         jEIsefl5qVLivDcsgIoEQIoySvPg5sAi/RWjONBbwrx+IKN4gEkCbtIroCVMQEvmTH0DsqQk\r
55         ESEl1cC46j3LjWqjleLn/KPPrXklNudi/tn2PWZtdpwnvl92f53etlZxo2qTUEClqOFdpemZ\r
56         CZcXsb5c0ipXySScGrORteI6q32W7LKZzOf1arV1Nslfdhb8s45Zdd1a2xd3nrtMvim65J3Q\r
57         rdaNzr1vjnwUj4z0vpZrm3XlvMMPU+ODz/7kalx45xelxFKckWioxVxUnAgAvFgnWc8CAAA=\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Thu, 10 Jan 2013 21:59:58 -0000\r
71 \r
72 `beginning-of-visual-line' interacts poorly with our use of invisible\r
73 overlays and often moves point into the previous message or part even\r
74 though it looks like it's in the next message or part (e.g., if you\r
75 press C-a on a header line and the previous message is invisible,\r
76 point will move into the previous message, even though it appears to\r
77 still be on the header line).  This advises `beginning-of-visual-line'\r
78 to address this behavior.\r
79 ---\r
80 \r
81 This is a completely different approach that should fix the HTML\r
82 problem, as well as other problems.  I also have an alternate approach\r
83 to this that sets 'field properties on the header line and part\r
84 buttons, which has the same effect, but seems to have more\r
85 side-effects (e.g., if point is at the end of a part button, C-a won't\r
86 go to the beginning).  This patch, OTOH, strikes directly at the\r
87 strange (maybe even buggy) behavior of beginning-of-visual-line.  The\r
88 downside is that it's advice, and advice always feels a little\r
89 sketchy.\r
90 \r
91  emacs/notmuch-show.el |   22 ++++++++++++++++++++++\r
92  1 file changed, 22 insertions(+)\r
93 \r
94 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
95 index 5751d98..6f5c53a 100644\r
96 --- a/emacs/notmuch-show.el\r
97 +++ b/emacs/notmuch-show.el\r
98 @@ -1120,6 +1120,28 @@ function is used."\r
99      (notmuch-show-goto-first-wanted-message)\r
100      (current-buffer)))\r
101  \r
102 +(defadvice beginning-of-visual-line (around constrain-invisible activate)\r
103 +  "Fix point motion around invisible overlays.\r
104 +\r
105 +In `notmuch-show-mode', we often hide overlays that end with a\r
106 +newline (e.g., messages, parts, etc).  This has the effect of\r
107 +collapsing the overlayed text into the beginning of the next\r
108 +line.  Unfortunately, this causes `visual-motion' and hence\r
109 +`beginning-of-visual-line' to move to the first character of the\r
110 +invisible overlay rather than the more obvious first character of\r
111 +the visible line.  Visually, these two points are\r
112 +indistinguishable, but this tends to make actions mysteriously\r
113 +apply to the previous message when it looks like they should\r
114 +apply to the next message.\r
115 +\r
116 +This advice fixes this behavior in `notmuch-show-mode' by\r
117 +restricting the motion of `beginning-of-visual-line'."\r
118 +  (if (eq major-mode 'notmuch-show-mode)\r
119 +      (save-restriction\r
120 +       (narrow-to-region (line-beginning-position) (point-max))\r
121 +       ad-do-it)\r
122 +    ad-do-it))\r
123 +\r
124  (defun notmuch-show-build-buffer ()\r
125    (let ((inhibit-read-only t))\r
126  \r
127 -- \r
128 1.7.10.4\r
129 \r