[PATCH 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / c0 / a79889c18574a990f9540d7aa6717f7225824a
1 Return-Path: <markwalters1009@gmail.com>\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 A4038431FDF\r
6         for <notmuch@notmuchmail.org>; Sat, 14 Dec 2013 15:53:48 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=unavailable\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id mwxu-y9V4QWd for <notmuch@notmuchmail.org>;\r
18         Sat, 14 Dec 2013 15:53:48 -0800 (PST)\r
19 Received: from mail-wg0-f67.google.com (mail-wg0-f67.google.com\r
20  [74.125.82.67])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  7BA6E431FDD    for <notmuch@notmuchmail.org>; Sat, 14 Dec 2013 15:53:43 -0800\r
23  (PST)\r
24 Received: by mail-wg0-f67.google.com with SMTP id n12so896952wgh.6\r
25         for <notmuch@notmuchmail.org>; Sat, 14 Dec 2013 15:53:42 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=VKppVlhkumcYb6e3h/MgHQaeYzWWMYjKK63rruOZ0LQ=;\r
29         b=YnYiqiM8W8D/iJX9TysrkioD3GAj/+GqljDXN4sG4pgqV2K9m0eKb+jDk67pAYeFj4\r
30         UQZBoHmId/cQKAeSw5dW431TG2M3xAAGT6j692nNrrIgZqw6C37wwTgdCIyJKGA1O6lO\r
31         Vv3mYLrSTbDOhCJEH/y+mXWXmphUJdIy5wAwlmyZXpoHRxNRluEDIs4mrUKyz8y3Aqky\r
32         AtC/1lfPc0xHAmz0hU9wxjTNOMZhK2YP8n06O/kuBc+AFLI/uHb0y2mF4CjwHLkNBV1L\r
33         oIvgLgXoFELfgpVijA/z3SdUaOSeChqK70hYnsBDqL8JSszxWmGa9PunwsYiAWEdJyNO\r
34         lbAw==\r
35 X-Received: by 10.194.93.3 with SMTP id cq3mr7978330wjb.26.1387065222395;\r
36         Sat, 14 Dec 2013 15:53:42 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id q8sm11134599wiy.8.2013.12.14.15.53.41\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 14 Dec 2013 15:53:41 -0800 (PST)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v2 5/5] emacs: show: make `seen' mean user viewed whole\r
45  message\r
46 Date: Sat, 14 Dec 2013 23:53:17 +0000\r
47 Message-Id: <1387065197-15776-6-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.9.1\r
49 In-Reply-To: <1387065197-15776-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1387065197-15776-1-git-send-email-markwalters1009@gmail.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sat, 14 Dec 2013 23:53:49 -0000\r
64 \r
65 This changes `seen' to mean that the user viewed `enough' of the whole\r
66 message: more precisely, a message is deemed seen if the top of the\r
67 message and either the bottom of the message or a point at least some\r
68 customisable number of lines into the message have each been visible\r
69 in the buffer at some point.\r
70 \r
71 This is placed into the post-command-hook infrastructure introudced in\r
72 the previous patch.\r
73 ---\r
74  emacs/notmuch-show.el |   73 +++++++++++++++++++++++++++++++++++++++++++++++-\r
75  1 files changed, 71 insertions(+), 2 deletions(-)\r
76 \r
77 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
78 index 51366e9..4850bd0 100644\r
79 --- a/emacs/notmuch-show.el\r
80 +++ b/emacs/notmuch-show.el\r
81 @@ -211,6 +211,19 @@ For example, if you wanted to remove an \"unread\" tag and add a\r
82    :type '(repeat string)\r
83    :group 'notmuch-show)\r
84  \r
85 +(defcustom notmuch-show-seen-lines-needed 0.75\r
86 +  "Control which messages get marked seen.\r
87 +\r
88 +A message is marked seen if both the top of the message and a\r
89 +point far \"enough\" down in the message have each been visible\r
90 +in the buffer at some point. This parameter controls the\r
91 +definition of enough.  Seeing the bottom of message is always\r
92 +deemed enough, but additionally...it an integer n then at least n\r
93 +lines of message must be visible in the window. If it is a float\r
94 +x then at least that proportion of the window must contain the\r
95 +message."\r
96 +  :type 'number\r
97 +  :group 'notmuch-show)\r
98  \r
99  (defmacro with-current-notmuch-show-message (&rest body)\r
100    "Evaluate body with current buffer set to the text of current message"\r
101 @@ -1541,9 +1554,65 @@ marked as unread, i.e. the tag changes in\r
102      (apply 'notmuch-show-tag-message\r
103            (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))\r
104  \r
105 +(defun notmuch-show-update-seen (top-or-bottom)\r
106 +  "Update seen status of current message\r
107 +\r
108 +Mark that we have seen the TOP-OR-BOTTOM of current message."\r
109 +  (let* ((current (notmuch-show-get-prop :seen-local))\r
110 +        new)\r
111 +    (unless (eq current 'both)\r
112 +      (if (eq top-or-bottom 'top)\r
113 +         (if (eq current 'bottom)\r
114 +             (setq new 'both)\r
115 +           (setq new 'top))\r
116 +       (if (eq current 'top)\r
117 +           (setq new 'both)\r
118 +         (setq new 'bottom)))\r
119 +      (unless (eq current new)\r
120 +       (notmuch-show-set-prop :seen-local new))\r
121 +      (when (eq new 'both)\r
122 +       (notmuch-show-mark-read)))))\r
123 +\r
124 +(defun notmuch-show-do-message-seen (start end)\r
125 +  "Update seen status for the current message.\r
126 +\r
127 +A message is seen if both the top and enough of the rest of the\r
128 +message have been visible in the buffer.  Enough means either the\r
129 +bottom of the message or a point in the message more than\r
130 +LINES-NEEDED lines into the message. LINES-NEEDED is\r
131 +`notmuch-show-seen-lines-needed` if that is an integer and that\r
132 +times the current window height if it is a float."\r
133 +  (let* ((lines-needed (if (integerp notmuch-show-seen-lines-needed)\r
134 +                          notmuch-show-seen-lines-needed\r
135 +                        (truncate (* notmuch-show-seen-lines-needed (window-body-height)))))\r
136 +        (top (notmuch-show-message-top))\r
137 +        (bottom (notmuch-show-message-bottom)))\r
138 +    (when (notmuch-show-message-visible-p)\r
139 +      (when (>= top start)\r
140 +       (notmuch-show-update-seen 'top))\r
141 +      (when (or (<= bottom end)\r
142 +               (> (count-screen-lines top end) lines-needed))\r
143 +       (notmuch-show-update-seen 'bottom)))))\r
144 +\r
145  (defun notmuch-show-do-seen (start end)\r
146 -  "Update seen status for all messages between start and end."\r
147 -  )\r
148 +  "Update seen status for all messages between start and end.\r
149 +\r
150 +A message is seen if both the top and enough of the rest of the\r
151 +message have been visible in the buffer. See\r
152 +`notmuch-show-do-message-seen` for the definition of enough. Seen\r
153 +is a buffer local property. The unread status is removed from all\r
154 +seen messages when the user quits the show buffer."\r
155 +  (save-excursion\r
156 +    (goto-char start)\r
157 +    (while (and (or (notmuch-show-do-message-seen start end) t)\r
158 +               (< (notmuch-show-message-bottom) end)\r
159 +               (notmuch-show-goto-message-next)))\r
160 +\r
161 +    ;; This is a work around because emacs gives weird answers for\r
162 +    ;; window-end if the buffer ends with invisible text.\r
163 +    (when (and (pos-visible-in-window-p (point-max))\r
164 +              (notmuch-show-message-visible-p))\r
165 +      (notmuch-show-update-seen 'bottom))))\r
166  \r
167  (defun notmuch-show-command-hook ()\r
168    (when (eq major-mode 'notmuch-show-mode)\r
169 -- \r
170 1.7.9.1\r
171 \r