unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Pieter Praet <pieter@praet.org>
To: David Edmondson <dme@dme.org>, Jani Nikula <jani@nikula.org>
Cc: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."
Date: Sat, 14 Jan 2012 10:17:18 +0100	[thread overview]
Message-ID: <1326532638-22068-1-git-send-email-pieter@praet.org> (raw)
In-Reply-To: <87k44uprvy.fsf@praet.org>

Less code, same results, without sacrificing readability.

---
 emacs/notmuch-show.el |   20 +++++++++-----------
 emacs/notmuch-wash.el |   47 +++++++++++++++++++++++------------------------
 emacs/notmuch.el      |   28 +++++++++++++---------------
 3 files changed, 45 insertions(+), 50 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 0cbf354..1e190ae 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1226,11 +1226,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
@@ -1423,12 +1422,11 @@ argument, hide all of the messages."
   ;; Move to the next item in the search results, if any.
   (let ((parent-buffer notmuch-show-parent-buffer))
     (notmuch-kill-this-buffer)
-    (if parent-buffer
-	(progn
-	  (switch-to-buffer parent-buffer)
-	  (forward-line)
-	  (if show-next
-	      (notmuch-search-show-thread))))))
+    (when parent-buffer
+      (switch-to-buffer parent-buffer)
+      (forward-line)
+      (if show-next
+	  (notmuch-search-show-thread)))))
 
 (defun notmuch-show-archive-thread ()
   "Archive each message in thread, then show next thread from search.
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 ba84494..0d37a74 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -631,17 +631,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))
@@ -818,10 +817,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

  reply	other threads:[~2012-01-14  9:19 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-11 21:48 [PATCH] emacs: support "notmuch new" as a notmuch-poll-script Jani Nikula
2011-12-11 22:00 ` Dmitry Kurochkin
2011-12-11 22:19   ` Jani Nikula
2011-12-11 22:39     ` Dmitry Kurochkin
2011-12-11 22:58   ` Austin Clements
2011-12-11 23:10     ` Jani Nikula
2011-12-12  0:31       ` Austin Clements
2011-12-12  0:39         ` Dmitry Kurochkin
2011-12-12 10:15         ` Tomi Ollila
2011-12-12 10:21           ` Dmitry Kurochkin
2011-12-12 11:38             ` Tomi Ollila
2011-12-12 15:42             ` Austin Clements
2011-12-12 19:57 ` [PATCH v2] " Jani Nikula
2011-12-12 20:12   ` Dmitry Kurochkin
2011-12-12 20:24   ` Austin Clements
2011-12-12 20:50 ` [PATCH v3] " Jani Nikula
2011-12-12 20:53   ` Dmitry Kurochkin
2011-12-12 21:13     ` Jani Nikula
2011-12-12 21:24       ` Austin Clements
2011-12-12 21:34         ` Dmitry Kurochkin
2011-12-12 21:01   ` Austin Clements
2011-12-15  4:24   ` David Bremner
2012-01-12 17:31   ` Pieter Praet
2012-01-12 17:33     ` [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..." Pieter Praet
2012-01-12 17:40       ` Dmitry Kurochkin
2012-01-12 22:10       ` Xavier Maillard
2012-01-13  8:23       ` David Edmondson
2012-01-13 12:42         ` Xavier Maillard
2012-01-13 12:37           ` Tomi Ollila
2012-01-13 13:01           ` David Edmondson
2012-01-14  9:14         ` Pieter Praet
2012-01-14  9:17           ` Pieter Praet [this message]
2012-01-28 12:41             ` [PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..." David Bremner
2012-01-28 12:55               ` Jani Nikula
2012-01-28 17:14                 ` David Bremner
2012-01-30  9:23                   ` David Edmondson
2012-02-01 13:46                     ` Pieter Praet
2012-02-01 14:21                       ` Dmitry Kurochkin
2012-01-30  7:03               ` Pieter Praet
2012-01-30  7:59                 ` Tomi Ollila
2012-02-01 13:46                   ` Pieter Praet
2012-01-31  3:34             ` David Bremner
2012-02-01 13:47               ` Pieter Praet
2012-02-01 13:50                 ` [PATCH v2] " Pieter Praet
2012-02-01 14:05                   ` David Edmondson
2012-02-02  1:31                   ` David Bremner
2012-01-14  9:52           ` [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..." Pieter Praet
2012-01-13 16:06       ` David Edmondson
2012-01-14  9:18         ` Pieter Praet
2012-01-15 11:55           ` David Edmondson
2012-01-16 10:56             ` [PATCH v2] " Pieter Praet
2012-01-16 11:06               ` David Edmondson
2012-01-16 12:39               ` Tomi Ollila
2012-01-21 12:21               ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326532638-22068-1-git-send-email-pieter@praet.org \
    --to=pieter@praet.org \
    --cc=dme@dme.org \
    --cc=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).