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 DEA0C431E64
\r
6 for <notmuch@notmuchmail.org>; Wed, 1 Feb 2012 05:52:17 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 pf5JMIuSfMIz for <notmuch@notmuchmail.org>;
\r
16 Wed, 1 Feb 2012 05:52:17 -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 1E345431FAF for <notmuch@notmuchmail.org>; Wed, 1 Feb 2012 05:52:16 -0800
\r
22 Received: by wgbdt12 with SMTP id dt12so1145428wgb.2
\r
23 for <notmuch@notmuchmail.org>; Wed, 01 Feb 2012 05:52:15 -0800 (PST)
\r
24 Received: by 10.180.106.33 with SMTP id gr1mr41774252wib.6.1328104335813;
\r
25 Wed, 01 Feb 2012 05:52:15 -0800 (PST)
\r
26 Received: from localhost ([109.131.39.11])
\r
27 by mx.google.com with ESMTPS id n3sm73881488wiz.9.2012.02.01.05.52.14
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Wed, 01 Feb 2012 05:52:15 -0800 (PST)
\r
30 From: Pieter Praet <pieter@praet.org>
\r
31 To: David Bremner <david@tethera.net>
\r
32 Subject: [PATCH v2] emacs: globally replace non-branching "(if COND (progn
\r
33 ..." with "(when ..."
\r
34 Date: Wed, 1 Feb 2012 14:50:00 +0100
\r
35 Message-Id: <1328104200-13458-1-git-send-email-pieter@praet.org>
\r
36 X-Mailer: git-send-email 1.7.8.1
\r
37 In-Reply-To: <87y5sm64y1.fsf@praet.org>
\r
38 References: <87y5sm64y1.fsf@praet.org>
\r
39 Cc: Notmuch Mail <notmuch@notmuchmail.org>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Wed, 01 Feb 2012 13:52:18 -0000
\r
54 Less code, same results, without sacrificing readability.
\r
58 Rebased to current master.
\r
60 emacs/notmuch-show.el | 9 ++++-----
\r
61 emacs/notmuch-wash.el | 47 +++++++++++++++++++++++------------------------
\r
62 emacs/notmuch.el | 28 +++++++++++++---------------
\r
63 3 files changed, 40 insertions(+), 44 deletions(-)
\r
65 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
66 index de9421e..0a945ea 100644
\r
67 --- a/emacs/notmuch-show.el
\r
68 +++ b/emacs/notmuch-show.el
\r
69 @@ -1364,11 +1364,10 @@ any effects from previous calls to
\r
70 ;; If a small number of lines from the previous message are
\r
71 ;; visible, realign so that the top of the current message is at
\r
72 ;; the top of the screen.
\r
73 - (if (<= (count-screen-lines (window-start) start-of-message)
\r
74 - next-screen-context-lines)
\r
76 - (goto-char (notmuch-show-message-top))
\r
77 - (notmuch-show-message-adjust)))
\r
78 + (when (<= (count-screen-lines (window-start) start-of-message)
\r
79 + next-screen-context-lines)
\r
80 + (goto-char (notmuch-show-message-top))
\r
81 + (notmuch-show-message-adjust))
\r
82 ;; Move to the top left of the window.
\r
83 (goto-char (window-start)))
\r
85 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
\r
86 index 5c1e830..67143e5 100644
\r
87 --- a/emacs/notmuch-wash.el
\r
88 +++ b/emacs/notmuch-wash.el
\r
89 @@ -336,30 +336,29 @@ patch and then guesses the extent of the patch, there is scope
\r
92 (goto-char (point-min))
\r
93 - (if (re-search-forward diff-file-header-re nil t)
\r
95 - (beginning-of-line -1)
\r
96 - (let ((patch-start (point))
\r
97 - (patch-end (point-max))
\r
99 - (goto-char patch-start)
\r
101 - ;; Patch ends with signature.
\r
102 - (re-search-forward notmuch-wash-signature-regexp nil t)
\r
103 - ;; Patch ends with bugtraq comment.
\r
104 - (re-search-forward "^\\*\\*\\* " nil t))
\r
105 - (setq patch-end (match-beginning 0)))
\r
106 - (save-restriction
\r
107 - (narrow-to-region patch-start patch-end)
\r
108 - (setq part (plist-put part :content-type "inline-patch-fake-part"))
\r
109 - (setq part (plist-put part :content (buffer-string)))
\r
110 - (setq part (plist-put part :id -1))
\r
111 - (setq part (plist-put part :filename
\r
112 - (notmuch-wash-subject-to-patch-filename
\r
114 - (plist-get msg :headers) :Subject))))
\r
115 - (delete-region (point-min) (point-max))
\r
116 - (notmuch-show-insert-bodypart nil part depth))))))
\r
117 + (when (re-search-forward diff-file-header-re nil t)
\r
118 + (beginning-of-line -1)
\r
119 + (let ((patch-start (point))
\r
120 + (patch-end (point-max))
\r
122 + (goto-char patch-start)
\r
124 + ;; Patch ends with signature.
\r
125 + (re-search-forward notmuch-wash-signature-regexp nil t)
\r
126 + ;; Patch ends with bugtraq comment.
\r
127 + (re-search-forward "^\\*\\*\\* " nil t))
\r
128 + (setq patch-end (match-beginning 0)))
\r
129 + (save-restriction
\r
130 + (narrow-to-region patch-start patch-end)
\r
131 + (setq part (plist-put part :content-type "inline-patch-fake-part"))
\r
132 + (setq part (plist-put part :content (buffer-string)))
\r
133 + (setq part (plist-put part :id -1))
\r
134 + (setq part (plist-put part :filename
\r
135 + (notmuch-wash-subject-to-patch-filename
\r
137 + (plist-get msg :headers) :Subject))))
\r
138 + (delete-region (point-min) (point-max))
\r
139 + (notmuch-show-insert-bodypart nil part depth)))))
\r
143 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
144 index 72f78ed..5fa239a 100644
\r
145 --- a/emacs/notmuch.el
\r
146 +++ b/emacs/notmuch.el
\r
147 @@ -673,17 +673,16 @@ This function advances the next thread when finished."
\r
148 (goto-char (point-max))
\r
149 (if (eq status 'signal)
\r
150 (insert "Incomplete search results (search process was killed).\n"))
\r
151 - (if (eq status 'exit)
\r
153 - (if notmuch-search-process-filter-data
\r
154 - (insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data)))
\r
155 - (insert "End of search results.")
\r
156 - (unless (= exit-status 0)
\r
157 - (insert (format " (process returned %d)" exit-status)))
\r
160 - (not (string= notmuch-search-target-thread "found")))
\r
161 - (set 'never-found-target-thread t))))))
\r
162 + (when (eq status 'exit)
\r
163 + (if notmuch-search-process-filter-data
\r
164 + (insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data)))
\r
165 + (insert "End of search results.")
\r
166 + (unless (= exit-status 0)
\r
167 + (insert (format " (process returned %d)" exit-status)))
\r
170 + (not (string= notmuch-search-target-thread "found")))
\r
171 + (set 'never-found-target-thread t)))))
\r
172 (when (and never-found-target-thread
\r
173 notmuch-search-target-line)
\r
174 (goto-char (point-min))
\r
175 @@ -861,10 +860,9 @@ non-authors is found, assume that all of the authors match."
\r
176 (put-text-property beg (point) 'notmuch-search-thread-id thread-id)
\r
177 (put-text-property beg (point) 'notmuch-search-authors authors)
\r
178 (put-text-property beg (point) 'notmuch-search-subject subject)
\r
179 - (if (string= thread-id notmuch-search-target-thread)
\r
181 - (set 'found-target beg)
\r
182 - (set 'notmuch-search-target-thread "found"))))
\r
183 + (when (string= thread-id notmuch-search-target-thread)
\r
184 + (set 'found-target beg)
\r
185 + (set 'notmuch-search-target-thread "found")))
\r
186 (set 'line (match-end 0)))
\r
188 (while (and (< line (length string)) (= (elt string line) ?\n))
\r