Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 32 / 6a851aabdb6d4475a2ad9936682d3797f40af8
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 BE06D431FCB\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Jan 2013 16:24:55 -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.574\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.574 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7, RDNS_NONE=1.274] 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 Mm9ad9CROnlE for <notmuch@notmuchmail.org>;\r
16         Tue, 22 Jan 2013 16:24:52 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (unknown [18.7.68.37])\r
18         by olra.theworths.org (Postfix) with ESMTP id D3AE3431FC0\r
19         for <notmuch@notmuchmail.org>; Tue, 22 Jan 2013 16:24:51 -0800 (PST)\r
20 X-AuditID: 12074425-b7fec6d000007584-75-50ff2dd34fc5\r
21 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
22         by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
23         id 03.EC.30084.3DD2FF05; Tue, 22 Jan 2013 19:24:51 -0500 (EST)\r
24 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
25         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r0N0OoRt007754; \r
26         Tue, 22 Jan 2013 19:24:51 -0500\r
27 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
28         (authenticated bits=0)\r
29         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
30         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id r0N0OmX9012539\r
31         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
32         Tue, 22 Jan 2013 19:24:50 -0500 (EST)\r
33 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
34         (envelope-from <amdragon@mit.edu>)\r
35         id 1Txo92-0004Te-MA; Tue, 22 Jan 2013 19:24:48 -0500\r
36 From: Austin Clements <amdragon@MIT.EDU>\r
37 To: Damien Cassou <damien.cassou@gmail.com>,\r
38         notmuch mailing list <notmuch@notmuchmail.org>\r
39 Subject: Re: emacs: Customize how each tag is displayed\r
40 In-Reply-To: <1358525039-13569-1-git-send-email-damien.cassou@gmail.com>\r
41 References: <1358525039-13569-1-git-send-email-damien.cassou@gmail.com>\r
42 User-Agent: Notmuch/0.14+243~g18d79d1 (http://notmuchmail.org) Emacs/23.4.1\r
43         (i486-pc-linux-gnu)\r
44 Date: Tue, 22 Jan 2013 19:24:48 -0500\r
45 Message-ID: <87k3r4d9v3.fsf@awakening.csail.mit.edu>\r
46 MIME-Version: 1.0\r
47 Content-Type: text/plain; charset=us-ascii\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFnrLIsWRmVeSWpSXmKPExsUixG6nontZ93+AwfUGMYtdd7cyWVy/OZPZ\r
50         gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4MqYvvMdS8EBvYpzN6obGL8odzFyckgImEic\r
51         adzDDGGLSVy4t56ti5GLQ0hgH6PEti3rGCGcDYwSJ5feYoFwLjJJzD59lAnCWcIosfHdU7B+\r
52         NgENiW37lzOC2CICKRJb73xgA7GFBcwltt2YyQRicwp4SFy8MYsVxBYScJd4P38dWK+oQLzE\r
53         nA1T2UFsFgFVie0zj7OA2LxA9116e5IRwhaUODnzCVicWUBL4sa/l0wTGAVmIUnNQpJawMi0\r
54         ilE2JbdKNzcxM6c4NVm3ODkxLy+1SNdCLzezRC81pXQTIzgkXVR3ME44pHSIUYCDUYmHN+HZ\r
55         vwAh1sSy4srcQ4ySHExKorxzdP4HCPEl5adUZiQWZ8QXleakFh9ilOBgVhLhVd4IVM6bklhZ\r
56         lVqUD5OS5mBREue9kXLTX0ggPbEkNTs1tSC1CCYrw8GhJMFbCDJUsCg1PbUiLTOnBCHNxMEJ\r
57         MpwHaPhqkBre4oLE3OLMdIj8KUZdjv1P2p8zCrHk5eelSolDDBIAKcoozYObA0slrxjFgd4S\r
58         5p0IUsUDTENwk14BLWECWsK7+DfIkpJEhJRUA2PVr0S7BrtlP/QWhBR8Cd7G92/7y6xMN+X/\r
59         phra1x/c3T75mznbhSPBRjqPF005wp411ebN9cTO53tfS/38dkZR6XSO5auD4rH1Rv8nzO/5\r
60         3/30U1v929ykeP1/OgcaEhN2mlxc/+BDc/PRKWfljaJqp1fO9VyZudZUO98nqjZutlaKwcNT\r
61         f+crsRRnJBpqMRcVJwIAMtlYtwADAAA=\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Wed, 23 Jan 2013 00:24:55 -0000\r
75 \r
76 On Fri, 18 Jan 2013, Damien Cassou <damien.cassou@gmail.com> wrote:\r
77 > [PATCH 1/4] emacs: Add notmuch-intersperse to notmuch-lib/\r
78 > [PATCH 2/4] emacs: pictures that might be used as icons for tags\r
79 > [PATCH 3/4] emacs: possibility to customize the rendering of tags\r
80 > [PATCH 4/4] emacs: provide convenience functions for notmuch-tagger\r
81 >\r
82 >\r
83 > These patches are the first of an upcoming series whose goal is to\r
84 > integrate notmuch-labeler into notmuch. See the following for more\r
85 > details: https://github.com/DamienCassou/notmuch-labeler\r
86 >\r
87 > Points of discussion:\r
88 >\r
89 > - This series does not have any unit-test to make it smaller and more\r
90 >   amenable to comments. I will send a patch when requested.\r
91 >\r
92 > - Patch 3/4 formats tags as mode-line templates so that we can show\r
93 >   tags in the header-line in a later series.\r
94 >\r
95 > - Patch 3/4 introduces `notmuch-tagger-formats', a list of pairs (KEY\r
96 >   FORMAT) to format a tag matching KEY using a special format.\r
97 >   Currently, an example of such a list is:\r
98 >\r
99 >     (("unread"\r
100 >          (:propertize "unread" face\r
101 >                       (:foreground "red")))\r
102 >      ("flagged"\r
103 >          (:propertize "flagged" display\r
104 >                       (image :type svg\r
105 >                              :file ,(notmuch-tagger-image-path "star.svg")\r
106 >                              :ascent center :mask heuristic))))\r
107 >\r
108 >   to set the unread tag to be red and the flagged tag to have a star\r
109 >   picture attached. Because this variable is hard to edit without\r
110 >   making mistakes, patch 4/4 introduces customization functions that\r
111 >   the user can call on their init.el file like this:\r
112 >\r
113 >   (notmuch-tagger-propertize "unread" :foreground "red")\r
114 >   (notmuch-tagger-image-star "flagged")\r
115 >\r
116 >   Nevertheless, implementing a customize interface for this variable\r
117 >   is difficult as Emacs does not provide customization widgets for\r
118 >   text-property lists. A possible solution could be to change the list\r
119 >   value so that it looks like:\r
120 >\r
121 >     (("unread" (propertize :foreground "red"))\r
122 >      ("flagged" (image-star)))\r
123 >\r
124 >   where the FORMAT part of each pair would be the suffix of a\r
125 >   notmuch-tagger customization function name (as introduced by patch\r
126 >   4/4) and the rest would be parameters to pass to this function\r
127 >   (except the KEY parameter that is already in each pair of the\r
128 >   `notmuch-tagger-formats' list). This solution would be more amenable\r
129 >   to the customization interface, but maybe less powerful.\r
130 \r
131 I'm not sold on your mode-line-format approach.  On the one hand, it's\r
132 rather quaint that you can reuse all of the mode-line formatting\r
133 mechanism.  But, on the other hand, 90% of the mode-line formatting\r
134 mechanism makes no sense in this context, and all of the utility\r
135 functions you add to make this variable accessible as well as the\r
136 difficulty in creating a customize interface for it suggest that this is\r
137 a false economy: that mode-line formatting is, in fact, the wrong\r
138 abstraction for this.\r
139 \r
140 I'm not sure what the best representation is, but here's one idea.\r
141 Instead of inventing (or reusing) some specialized formatting language,\r
142 use the language already at your disposal: make the tag format a list of\r
143 Elisp expressions that transform the tag string into an arbitrary\r
144 propertized string to use in place of the tag.  You can't get much more\r
145 powerful than that, and, plus, it would be really easy to implement.\r
146 \r
147 Here's what I'm imagining, complete with working (slightly hairy)\r
148 customize interface:\r
149 \r
150 (defcustom notmuch-tag-formats\r
151   '(("unread" (propertize tag 'face '(:foreground "red")))\r
152     ("flagged" (notmuch-tag-format-image tag "star.svg")))\r
153 \r
154   "Custom formats for individual tags.\r
155 \r
156 This gives a list that maps from tag names to lists of formatting\r
157 expressions.  The car of each element gives a tag name and the\r
158 cdr gives a list of Elisp expressions that modify the tag.  If\r
159 the list is empty, the tag will simply be hidden.  Otherwise,\r
160 each expression will be evaluated in order: for the first\r
161 expression, the variable `tag' will be bound to the tag name; for\r
162 each later expression, the variable `tag' will be bound to the\r
163 result of the previous expression.  In this way, each expression\r
164 can build on the formatting performed by the previous expression.\r
165 The result of the last expression will displayed in place of the\r
166 tag.\r
167 \r
168 For example, to replace a tag with another string, simply use\r
169 that string as a formatting expression.  To change the foreground\r
170 of a tag to red, use the expression\r
171   (propertize tag 'face '(:foreground \"red\"))\r
172 \r
173 See also `notmuch-tag-format-image', which can help replace tags\r
174 with images."\r
175 \r
176   :group 'notmuch-search\r
177   :group 'notmuch-show\r
178   :type '(alist :key-type (string :tag "Tag")\r
179                 :extra-offset -3\r
180                 :value-type\r
181                 (radio :format "%v"\r
182                        (const :tag "Hidden" nil)\r
183                        (set :tag "Modified"\r
184                             (string :tag "Display as")\r
185                             (list :tag "Face" :extra-offset -4\r
186                                   (const :format "" :inline t\r
187                                          (propertize tag 'face))\r
188                                   (list :format "%v"\r
189                                         (const :format "" quote)\r
190                                         custom-face-edit))\r
191                             (list :format "%v" :extra-offset -4\r
192                                   (const :format "" :inline t\r
193                                          (notmuch-tag-format-image tag))\r
194                                   (choice :tag "Image"\r
195                                           (const :tag "Star" "star.svg")\r
196                                           (const :tag "Empty star"\r
197                                                  "star-empty.svg")\r
198                                           (const :tag "Tag" "tag.svg")\r
199                                           (string :tag "Custom")))\r
200                             (sexp :tag "Custom")))))\r
201 \r
202 where I'm imagining notmuch-tag-format-image would be very similar to\r
203 your existing image utilities, with an interface something like\r
204 \r
205 (defun notmuch-tag-format-image (tag image)\r
206   "Replace TAG with IMAGE, if available.\r
207 \r
208 Returns a propertized string that will display IMAGE in place of\r
209 TAG.  If IMAGE is a relative path, it will be looked for in the\r
210 standard notmuch image directory.  This is designed for use in\r
211 `notmuch-tag-formats'."\r
212   ...)\r
213 \r
214 Thoughts?\r
215 \r