From: Pieter Praet Date: Wed, 1 Feb 2012 13:50:00 +0000 (+0100) Subject: [PATCH v2] emacs: globally replace non-branching "(if COND (progn ..." with "(when... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=41ce9fba164a73d9c48298b5a297d47fef198552;p=notmuch-archives.git [PATCH v2] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..." --- diff --git a/ce/02cb7ac1d1fcf5dd9a79b525e81f3bc53b0a46 b/ce/02cb7ac1d1fcf5dd9a79b525e81f3bc53b0a46 new file mode 100644 index 000000000..5c00a93b8 --- /dev/null +++ b/ce/02cb7ac1d1fcf5dd9a79b525e81f3bc53b0a46 @@ -0,0 +1,191 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id DEA0C431E64 + for ; Wed, 1 Feb 2012 05:52:17 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id pf5JMIuSfMIz for ; + Wed, 1 Feb 2012 05:52:17 -0800 (PST) +Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com + [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 1E345431FAF for ; Wed, 1 Feb 2012 05:52:16 -0800 + (PST) +Received: by wgbdt12 with SMTP id dt12so1145428wgb.2 + for ; Wed, 01 Feb 2012 05:52:15 -0800 (PST) +Received: by 10.180.106.33 with SMTP id gr1mr41774252wib.6.1328104335813; + Wed, 01 Feb 2012 05:52:15 -0800 (PST) +Received: from localhost ([109.131.39.11]) + by mx.google.com with ESMTPS id n3sm73881488wiz.9.2012.02.01.05.52.14 + (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 01 Feb 2012 05:52:15 -0800 (PST) +From: Pieter Praet +To: David Bremner +Subject: [PATCH v2] emacs: globally replace non-branching "(if COND (progn + ..." with "(when ..." +Date: Wed, 1 Feb 2012 14:50:00 +0100 +Message-Id: <1328104200-13458-1-git-send-email-pieter@praet.org> +X-Mailer: git-send-email 1.7.8.1 +In-Reply-To: <87y5sm64y1.fsf@praet.org> +References: <87y5sm64y1.fsf@praet.org> +Cc: Notmuch Mail +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 01 Feb 2012 13:52:18 -0000 + +Less code, same results, without sacrificing readability. + +--- + +Rebased to current master. + + emacs/notmuch-show.el | 9 ++++----- + emacs/notmuch-wash.el | 47 +++++++++++++++++++++++------------------------ + emacs/notmuch.el | 28 +++++++++++++--------------- + 3 files changed, 40 insertions(+), 44 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index de9421e..0a945ea 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1364,11 +1364,10 @@ any effects from previous calls to + ;; If a small number of lines from the previous message are + ;; visible, realign so that the top of the current message is at + ;; the top of the screen. +- (if (<= (count-screen-lines (window-start) start-of-message) +- next-screen-context-lines) +- (progn +- (goto-char (notmuch-show-message-top)) +- (notmuch-show-message-adjust))) ++ (when (<= (count-screen-lines (window-start) start-of-message) ++ next-screen-context-lines) ++ (goto-char (notmuch-show-message-top)) ++ (notmuch-show-message-adjust)) + ;; Move to the top left of the window. + (goto-char (window-start))) + (t +diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el +index 5c1e830..67143e5 100644 +--- a/emacs/notmuch-wash.el ++++ b/emacs/notmuch-wash.el +@@ -336,30 +336,29 @@ patch and then guesses the extent of the patch, there is scope + for error." + + (goto-char (point-min)) +- (if (re-search-forward diff-file-header-re nil t) +- (progn +- (beginning-of-line -1) +- (let ((patch-start (point)) +- (patch-end (point-max)) +- part) +- (goto-char patch-start) +- (if (or +- ;; Patch ends with signature. +- (re-search-forward notmuch-wash-signature-regexp nil t) +- ;; Patch ends with bugtraq comment. +- (re-search-forward "^\\*\\*\\* " nil t)) +- (setq patch-end (match-beginning 0))) +- (save-restriction +- (narrow-to-region patch-start patch-end) +- (setq part (plist-put part :content-type "inline-patch-fake-part")) +- (setq part (plist-put part :content (buffer-string))) +- (setq part (plist-put part :id -1)) +- (setq part (plist-put part :filename +- (notmuch-wash-subject-to-patch-filename +- (plist-get +- (plist-get msg :headers) :Subject)))) +- (delete-region (point-min) (point-max)) +- (notmuch-show-insert-bodypart nil part depth)))))) ++ (when (re-search-forward diff-file-header-re nil t) ++ (beginning-of-line -1) ++ (let ((patch-start (point)) ++ (patch-end (point-max)) ++ part) ++ (goto-char patch-start) ++ (if (or ++ ;; Patch ends with signature. ++ (re-search-forward notmuch-wash-signature-regexp nil t) ++ ;; Patch ends with bugtraq comment. ++ (re-search-forward "^\\*\\*\\* " nil t)) ++ (setq patch-end (match-beginning 0))) ++ (save-restriction ++ (narrow-to-region patch-start patch-end) ++ (setq part (plist-put part :content-type "inline-patch-fake-part")) ++ (setq part (plist-put part :content (buffer-string))) ++ (setq part (plist-put part :id -1)) ++ (setq part (plist-put part :filename ++ (notmuch-wash-subject-to-patch-filename ++ (plist-get ++ (plist-get msg :headers) :Subject)))) ++ (delete-region (point-min) (point-max)) ++ (notmuch-show-insert-bodypart nil part depth))))) + + ;; + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index 72f78ed..5fa239a 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -673,17 +673,16 @@ This function advances the next thread when finished." + (goto-char (point-max)) + (if (eq status 'signal) + (insert "Incomplete search results (search process was killed).\n")) +- (if (eq status 'exit) +- (progn +- (if notmuch-search-process-filter-data +- (insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data))) +- (insert "End of search results.") +- (unless (= exit-status 0) +- (insert (format " (process returned %d)" exit-status))) +- (insert "\n") +- (if (and atbob +- (not (string= notmuch-search-target-thread "found"))) +- (set 'never-found-target-thread t)))))) ++ (when (eq status 'exit) ++ (if notmuch-search-process-filter-data ++ (insert (concat "Error: Unexpected output from notmuch search:\n" notmuch-search-process-filter-data))) ++ (insert "End of search results.") ++ (unless (= exit-status 0) ++ (insert (format " (process returned %d)" exit-status))) ++ (insert "\n") ++ (if (and atbob ++ (not (string= notmuch-search-target-thread "found"))) ++ (set 'never-found-target-thread t))))) + (when (and never-found-target-thread + notmuch-search-target-line) + (goto-char (point-min)) +@@ -861,10 +860,9 @@ non-authors is found, assume that all of the authors match." + (put-text-property beg (point) 'notmuch-search-thread-id thread-id) + (put-text-property beg (point) 'notmuch-search-authors authors) + (put-text-property beg (point) 'notmuch-search-subject subject) +- (if (string= thread-id notmuch-search-target-thread) +- (progn +- (set 'found-target beg) +- (set 'notmuch-search-target-thread "found")))) ++ (when (string= thread-id notmuch-search-target-thread) ++ (set 'found-target beg) ++ (set 'notmuch-search-target-thread "found"))) + (set 'line (match-end 0))) + (set 'more nil) + (while (and (< line (length string)) (= (elt string line) ?\n)) +-- +1.7.8.1 +