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
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
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
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
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
55 Less code, same results, without sacrificing readability.
\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
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
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
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
89 - (switch-to-buffer parent-buffer)
\r
92 - (notmuch-search-show-thread))))))
\r
93 + (when parent-buffer
\r
94 + (switch-to-buffer parent-buffer)
\r
97 + (notmuch-search-show-thread)))))
\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
108 (goto-char (point-min))
\r
109 - (if (re-search-forward diff-file-header-re nil t)
\r
111 - (beginning-of-line -1)
\r
112 - (let ((patch-start (point))
\r
113 - (patch-end (point-max))
\r
115 - (goto-char patch-start)
\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
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
138 + (goto-char patch-start)
\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
153 + (plist-get msg :headers) :Subject))))
\r
154 + (delete-region (point-min) (point-max))
\r
155 + (notmuch-show-insert-bodypart nil part depth)))))
\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
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
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
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
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
204 (while (and (< line (length string)) (= (elt string line) ?\n))
\r