Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 06 / bc1162b1d72ccc38ef3aeca9ca5e4db471c15c
1 Return-Path: <pieter@praet.org>\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 0E261429E49\r
6         for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 01:19:13 -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 1v7gAW9-R5Ru for <notmuch@notmuchmail.org>;\r
16         Sat, 14 Jan 2012 01:19:12 -0800 (PST)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  1FCC3431FB6    for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 01:19:12 -0800\r
21  (PST)\r
22 Received: by wgbds11 with SMTP id ds11so3536513wgb.2\r
23         for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 01:19:10 -0800 (PST)\r
24 Received: by 10.180.19.130 with SMTP id f2mr2118616wie.12.1326532750838;\r
25         Sat, 14 Jan 2012 01:19:10 -0800 (PST)\r
26 Received: from localhost ([109.131.75.86])\r
27         by mx.google.com with ESMTPS id gf8sm14181614wbb.11.2012.01.14.01.19.10\r
28         (version=TLSv1/SSLv3 cipher=OTHER);\r
29         Sat, 14 Jan 2012 01:19:10 -0800 (PST)\r
30 From: Pieter Praet <pieter@praet.org>\r
31 To: David Edmondson <dme@dme.org>,\r
32         Jani Nikula <jani@nikula.org>\r
33 Subject: [PATCH] emacs: globally replace non-branching "(if COND (progn ..."\r
34         with "(when ..."\r
35 Date: Sat, 14 Jan 2012 10:17:18 +0100\r
36 Message-Id: <1326532638-22068-1-git-send-email-pieter@praet.org>\r
37 X-Mailer: git-send-email 1.7.8.1\r
38 In-Reply-To: <87k44uprvy.fsf@praet.org>\r
39 References: <87k44uprvy.fsf@praet.org>\r
40 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sat, 14 Jan 2012 09:19:13 -0000\r
54 \r
55 Less code, same results, without sacrificing readability.\r
56 \r
57 ---\r
58  emacs/notmuch-show.el |   20 +++++++++-----------\r
59  emacs/notmuch-wash.el |   47 +++++++++++++++++++++++------------------------\r
60  emacs/notmuch.el      |   28 +++++++++++++---------------\r
61  3 files changed, 45 insertions(+), 50 deletions(-)\r
62 \r
63 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
64 index 0cbf354..1e190ae 100644\r
65 --- a/emacs/notmuch-show.el\r
66 +++ b/emacs/notmuch-show.el\r
67 @@ -1226,11 +1226,10 @@ any effects from previous calls to\r
68        ;; If a small number of lines from the previous message are\r
69        ;; visible, realign so that the top of the current message is at\r
70        ;; the top of the screen.\r
71 -      (if (<= (count-screen-lines (window-start) start-of-message)\r
72 -             next-screen-context-lines)\r
73 -         (progn\r
74 -           (goto-char (notmuch-show-message-top))\r
75 -           (notmuch-show-message-adjust)))\r
76 +      (when (<= (count-screen-lines (window-start) start-of-message)\r
77 +               next-screen-context-lines)\r
78 +       (goto-char (notmuch-show-message-top))\r
79 +       (notmuch-show-message-adjust))\r
80        ;; Move to the top left of the window.\r
81        (goto-char (window-start)))\r
82       (t\r
83 @@ -1423,12 +1422,11 @@ argument, hide all of the messages."\r
84    ;; Move to the next item in the search results, if any.\r
85    (let ((parent-buffer notmuch-show-parent-buffer))\r
86      (notmuch-kill-this-buffer)\r
87 -    (if parent-buffer\r
88 -       (progn\r
89 -         (switch-to-buffer parent-buffer)\r
90 -         (forward-line)\r
91 -         (if show-next\r
92 -             (notmuch-search-show-thread))))))\r
93 +    (when parent-buffer\r
94 +      (switch-to-buffer parent-buffer)\r
95 +      (forward-line)\r
96 +      (if show-next\r
97 +         (notmuch-search-show-thread)))))\r
98  \r
99  (defun notmuch-show-archive-thread ()\r
100    "Archive each message in thread, then show next thread from search.\r
101 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
102 index 5c1e830..67143e5 100644\r
103 --- a/emacs/notmuch-wash.el\r
104 +++ b/emacs/notmuch-wash.el\r
105 @@ -336,30 +336,29 @@ patch and then guesses the extent of the patch, there is scope\r
106  for error."\r
107  \r
108    (goto-char (point-min))\r
109 -  (if (re-search-forward diff-file-header-re nil t)\r
110 -      (progn\r
111 -       (beginning-of-line -1)\r
112 -       (let ((patch-start (point))\r
113 -             (patch-end (point-max))\r
114 -             part)\r
115 -         (goto-char patch-start)\r
116 -         (if (or\r
117 -              ;; Patch ends with signature.\r
118 -              (re-search-forward notmuch-wash-signature-regexp nil t)\r
119 -              ;; Patch ends with bugtraq comment.\r
120 -              (re-search-forward "^\\*\\*\\* " nil t))\r
121 -             (setq patch-end (match-beginning 0)))\r
122 -         (save-restriction\r
123 -           (narrow-to-region patch-start patch-end)\r
124 -           (setq part (plist-put part :content-type "inline-patch-fake-part"))\r
125 -           (setq part (plist-put part :content (buffer-string)))\r
126 -           (setq part (plist-put part :id -1))\r
127 -           (setq part (plist-put part :filename\r
128 -                                 (notmuch-wash-subject-to-patch-filename\r
129 -                                  (plist-get\r
130 -                                   (plist-get msg :headers) :Subject))))\r
131 -           (delete-region (point-min) (point-max))\r
132 -           (notmuch-show-insert-bodypart nil part depth))))))\r
133 +  (when (re-search-forward diff-file-header-re nil t)\r
134 +    (beginning-of-line -1)\r
135 +    (let ((patch-start (point))\r
136 +         (patch-end (point-max))\r
137 +         part)\r
138 +      (goto-char patch-start)\r
139 +      (if (or\r
140 +          ;; Patch ends with signature.\r
141 +          (re-search-forward notmuch-wash-signature-regexp nil t)\r
142 +          ;; Patch ends with bugtraq comment.\r
143 +          (re-search-forward "^\\*\\*\\* " nil t))\r
144 +         (setq patch-end (match-beginning 0)))\r
145 +      (save-restriction\r
146 +       (narrow-to-region patch-start patch-end)\r
147 +       (setq part (plist-put part :content-type "inline-patch-fake-part"))\r
148 +       (setq part (plist-put part :content (buffer-string)))\r
149 +       (setq part (plist-put part :id -1))\r
150 +       (setq part (plist-put part :filename\r
151 +                             (notmuch-wash-subject-to-patch-filename\r
152 +                              (plist-get\r
153 +                               (plist-get msg :headers) :Subject))))\r
154 +       (delete-region (point-min) (point-max))\r
155 +       (notmuch-show-insert-bodypart nil part depth)))))\r
156  \r
157  ;;\r
158  \r
159 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
160 index ba84494..0d37a74 100644\r
161 --- a/emacs/notmuch.el\r
162 +++ b/emacs/notmuch.el\r
163 @@ -631,17 +631,16 @@ This function advances the next thread when finished."\r
164                   (goto-char (point-max))\r
165                   (if (eq status 'signal)\r
166                       (insert "Incomplete search results (search process was killed).\n"))\r
167 -                 (if (eq status 'exit)\r
168 -                     (progn\r
169 -                       (if notmuch-search-process-filter-data\r
170 -                           (insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data)))\r
171 -                       (insert "End of search results.")\r
172 -                       (unless (= exit-status 0)\r
173 -                         (insert (format " (process returned %d)" exit-status)))\r
174 -                       (insert "\n")\r
175 -                       (if (and atbob\r
176 -                                (not (string= notmuch-search-target-thread "found")))\r
177 -                           (set 'never-found-target-thread t))))))\r
178 +                 (when (eq status 'exit)\r
179 +                   (if notmuch-search-process-filter-data\r
180 +                       (insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data)))\r
181 +                   (insert "End of search results.")\r
182 +                   (unless (= exit-status 0)\r
183 +                     (insert (format " (process returned %d)" exit-status)))\r
184 +                   (insert "\n")\r
185 +                   (if (and atbob\r
186 +                            (not (string= notmuch-search-target-thread "found")))\r
187 +                       (set 'never-found-target-thread t)))))\r
188               (when (and never-found-target-thread\r
189                        notmuch-search-target-line)\r
190                   (goto-char (point-min))\r
191 @@ -818,10 +817,9 @@ non-authors is found, assume that all of the authors match."\r
192                         (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
193                         (put-text-property beg (point) 'notmuch-search-authors authors)\r
194                         (put-text-property beg (point) 'notmuch-search-subject subject)\r
195 -                       (if (string= thread-id notmuch-search-target-thread)\r
196 -                           (progn\r
197 -                             (set 'found-target beg)\r
198 -                             (set 'notmuch-search-target-thread "found"))))\r
199 +                       (when (string= thread-id notmuch-search-target-thread)\r
200 +                         (set 'found-target beg)\r
201 +                         (set 'notmuch-search-target-thread "found")))\r
202                       (set 'line (match-end 0)))\r
203                   (set 'more nil)\r
204                   (while (and (< line (length string)) (= (elt string line) ?\n))\r
205 -- \r
206 1.7.8.1\r
207 \r