Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / bb / bf0e0316d179071bff094d63970bbaf2f488b8
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 454DA431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 27 Jan 2012 21:22:46 -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 FA+IpXQlePGr for <notmuch@notmuchmail.org>;\r
16         Fri, 27 Jan 2012 21:22:45 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id 858C6431FAE\r
20         for <notmuch@notmuchmail.org>; Fri, 27 Jan 2012 21:22:45 -0800 (PST)\r
21 X-AuditID: 1209190f-b7f8a6d000000914-d9-4f23862416c7\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 94.F5.02324.426832F4; Sat, 28 Jan 2012 00:22:44 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0S5Mijv030362; \r
27         Sat, 28 Jan 2012 00:22:44 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\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 q0S5MhYB009718\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Sat, 28 Jan 2012 00:22:44 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1Rr0jg-00050q-W1; Sat, 28 Jan 2012 00:22:01 -0500\r
37 Date: Sat, 28 Jan 2012 00:22:00 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: David Edmondson <dme@dme.org>\r
40 Subject: Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.\r
41 Message-ID: <20120128052200.GB17991@mit.edu>\r
42 References: <1327496913-4946-1-git-send-email-dme@dme.org>\r
43         <1327499314-7887-1-git-send-email-dme@dme.org>\r
44         <1327499314-7887-4-git-send-email-dme@dme.org>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To: <1327499314-7887-4-git-send-email-dme@dme.org>\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1lVpU/Y3WLDc0GLfnS1MFtdvzmR2\r
52         YPLY9fwvk8ezVbeYA5iiuGxSUnMyy1KL9O0SuDL+v5vHXNAsWzFzDmcD4wbxLkZODgkBE4kz\r
53         J74zQthiEhfurWfrYuTiEBLYxyixeNMnJghnA6PEsSXbmCGck0wSb+5PZIFwljBKdN06yATS\r
54         zyKgKnH5VRfYLDYBDYlt+5eD2SICihL/v61gB7GZBaQlvv1uBqsXFvCQaL63FMzmFdCRWL/5\r
55         EtSGOYwSq3qfsEMkBCVOznzCAtGsJXHj30ugBg6wQcv/cYCYnALWEmu/soFUiAqoSEw5uY1t\r
56         AqPQLCTNs5A0z0JoXsDIvIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXRC83s0QvNaV0EyM4rCX5\r
57         dzB+O6h0iFGAg1GJh/fCKyV/IdbEsuLK3EOMkhxMSqK8sq3K/kJ8SfkplRmJxRnxRaU5qcWH\r
58         GCU4mJVEeO94KfoL8aYkVlalFuXDpKQ5WJTEedW03vkJCaQnlqRmp6YWpBbBZGU4OJQkeJeA\r
59         DBUsSk1PrUjLzClBSDNxcIIM5wEangNSw1tckJhbnJkOkT/FqCglztsLkhAASWSU5sH1wtLO\r
60         K0ZxoFeEeTeBVPEAUxZc9yugwUxAgyOuglxdXJKIkJJqYJx65p5g6qJF2Z9mhdZ6bYj7z6Ep\r
61         k2n5WudXFo/1TJv7ZRHS1n8jW25Mz87MYxORT6+3vu7029vT9Mzd/fnLeQ6/u3WchaGW8Zb4\r
62         VFG+C6bry1KstAomv/1hVrJRYofU6og9+yVr5rlPeqvsF5O9x0msUJhF2m5HsLVimaTmpFXf\r
63         vv9nOlHBo8RSnJFoqMVcVJwIANLUFp8WAwAA\r
64 Cc: notmuch@notmuchmail.org\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Sat, 28 Jan 2012 05:22:46 -0000\r
78 \r
79 LGTM other than what Mark pointed out about this not applying to\r
80 subjects in the search buffer.\r
81 \r
82 Quoth David Edmondson on Jan 25 at  1:48 pm:\r
83 > ---\r
84 >  emacs/notmuch-lib.el   |    6 ++++++\r
85 >  emacs/notmuch-print.el |    8 ++++++--\r
86 >  emacs/notmuch-show.el  |    5 ++++-\r
87 >  emacs/notmuch.el       |    5 +----\r
88 >  4 files changed, 17 insertions(+), 7 deletions(-)\r
89\r
90 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
91 > index 241fe8c..5b8a41c 100644\r
92 > --- a/emacs/notmuch-lib.el\r
93 > +++ b/emacs/notmuch-lib.el\r
94 > @@ -130,6 +130,12 @@ the user hasn't set this variable with the old or new value."\r
95 >    (interactive)\r
96 >    (kill-buffer (current-buffer)))\r
97 >  \r
98 > +(defun notmuch-prettify-subject (subject)\r
99 > +  (if (and subject\r
100 > +        (string-match "^[ \t]*$" subject))\r
101 > +      (setq subject "[No Subject]"))\r
102 > +  subject)\r
103 > +\r
104 >  ;;\r
105 >  \r
106 >  (defun notmuch-common-do-stash (text)\r
107 > diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el\r
108 > index 83eb525..51bb740 100644\r
109 > --- a/emacs/notmuch-print.el\r
110 > +++ b/emacs/notmuch-print.el\r
111 > @@ -19,6 +19,8 @@\r
112 >  ;;\r
113 >  ;; Authors: David Edmondson <dme@dme.org>\r
114 >  \r
115 > +(require 'notmuch-lib)\r
116 > +\r
117 >  (defcustom notmuch-print-mechanism 'notmuch-print-lpr\r
118 >    "How should printing be done?"\r
119 >    :group 'notmuch\r
120 > @@ -56,14 +58,16 @@ Optional OUTPUT allows passing a list of flags to muttprint."\r
121 >  \r
122 >  (defun notmuch-print-ps-print (msg)\r
123 >    "Print a message buffer using the ps-print package."\r
124 > -  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))\r
125 > +  (let ((subject (notmuch-prettify-subject\r
126 > +               (plist-get (notmuch-show-get-prop :headers msg) :Subject))))\r
127 >      (rename-buffer subject t)\r
128 >      (ps-print-buffer)))\r
129 >  \r
130 >  (defun notmuch-print-ps-print/evince (msg)\r
131 >    "Preview a message buffer using ps-print and evince."\r
132 >    (let ((ps-file (make-temp-file "notmuch"))\r
133 > -     (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))\r
134 > +     (subject (notmuch-prettify-subject\r
135 > +               (plist-get (notmuch-show-get-prop :headers msg) :Subject))))\r
136 >      (rename-buffer subject t)\r
137 >      (ps-print-buffer ps-file)\r
138 >      (notmuch-print-run-evince ps-file)))\r
139 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
140 > index e6a5b31..c602b3e 100644\r
141 > --- a/emacs/notmuch-show.el\r
142 > +++ b/emacs/notmuch-show.el\r
143 > @@ -985,7 +985,7 @@ buffer."\r
144 >        (notmuch-show-next-open-message))\r
145 >  \r
146 >      ;; Set the header line to the subject of the first open message.\r
147 > -    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))\r
148 > +    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))\r
149 >  \r
150 >      (notmuch-show-mark-read)))\r
151 >  \r
152 > @@ -1216,6 +1216,9 @@ Some useful entries are:\r
153 >  (defun notmuch-show-get-depth ()\r
154 >    (notmuch-show-get-prop :depth))\r
155 >  \r
156 > +(defun notmuch-show-get-pretty-subject ()\r
157 > +  (notmuch-prettify-subject (notmuch-show-get-subject)))\r
158 > +\r
159 >  (defun notmuch-show-set-tags (tags)\r
160 >    "Set the tags of the current message."\r
161 >    (notmuch-show-set-prop :tags tags)\r
162 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
163 > index 3f6b977..ce1e232 100644\r
164 > --- a/emacs/notmuch.el\r
165 > +++ b/emacs/notmuch.el\r
166 > @@ -440,10 +440,7 @@ Complete list of currently available key bindings:\r
167 >    "Display the currently selected thread."\r
168 >    (interactive "P")\r
169 >    (let ((thread-id (notmuch-search-find-thread-id))\r
170 > -     (subject (notmuch-search-find-subject)))\r
171 > -\r
172 > -    (if (string-match "^[ \t]*$" subject)\r
173 > -     (setq subject "[No Subject]"))\r
174 > +     (subject (notmuch-prettify-subject (notmuch-search-find-subject))))\r
175 >  \r
176 >      (if (> (length thread-id) 0)\r
177 >       (notmuch-show thread-id\r