]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: globally replace non-branching "(if (not ..." with "(unless ..."
authorPieter Praet <pieter@praet.org>
Mon, 16 Jan 2012 10:56:40 +0000 (11:56 +0100)
committerDavid Bremner <bremner@debian.org>
Sat, 21 Jan 2012 12:17:56 +0000 (08:17 -0400)
Less code, same results, without sacrificing readability.

emacs/notmuch-address.el
emacs/notmuch-hello.el
emacs/notmuch-show.el
emacs/notmuch.el

index 2e8b8402f2c29fa8580adabc92aec61438bcddf4..2bf762ba9b1a0ae3a3970cf2ac2dfdc4ef4071f1 100644 (file)
@@ -38,9 +38,9 @@ line."
 (defvar notmuch-address-history nil)
 
 (defun notmuch-address-message-insinuate ()
-  (if (not (memq notmuch-address-message-alist-member message-completion-alist))
-      (setq message-completion-alist
-           (push notmuch-address-message-alist-member message-completion-alist))))
+  (unless (memq notmuch-address-message-alist-member message-completion-alist)
+    (setq message-completion-alist
+         (push notmuch-address-message-alist-member message-completion-alist))))
 
 (defun notmuch-address-options (original)
   (process-lines notmuch-address-command original))
index bff95acc8413865e2ed49927e9c5f92f8f0ad0e4..ba48cd639467e94f824617034ac87c68169dfdd6 100644 (file)
@@ -320,8 +320,8 @@ should be. Returns a cons cell `(tags-per-line width)'."
 
     ;; If the last line was not full (and hence did not include a
     ;; carriage return), insert one now.
-    (if (not (eq (% count tags-per-line) 0))
-       (widget-insert "\n"))
+    (unless (eq (% count tags-per-line) 0)
+      (widget-insert "\n"))
     found-target-pos))
 
 (defun notmuch-hello-goto-search ()
@@ -404,7 +404,7 @@ Complete list of currently available key bindings:
 
   ; Jump through a hoop to get this value from the deprecated variable
   ; name (`notmuch-folders') or from the default value.
-  (if (not notmuch-saved-searches)
+  (unless notmuch-saved-searches
     (setq notmuch-saved-searches (notmuch-saved-searches)))
 
   (if no-display
@@ -570,18 +570,18 @@ Complete list of currently available key bindings:
          (widget-insert "\n\n")
          (let ((start (point)))
            (setq found-target-pos (notmuch-hello-insert-tags alltags-alist widest target))
-           (if (not final-target-pos)
-               (setq final-target-pos found-target-pos))
+           (unless final-target-pos
+             (setq final-target-pos found-target-pos))
            (indent-rigidly start (point) notmuch-hello-indent)))
 
        (widget-insert "\n")
 
-       (if (not notmuch-show-all-tags-list)
-           (widget-create 'push-button
-                          :notify (lambda (widget &rest ignore)
-                                    (setq notmuch-show-all-tags-list t)
-                                    (notmuch-hello-update))
-                          "Show all tags")))
+       (unless notmuch-show-all-tags-list
+         (widget-create 'push-button
+                        :notify (lambda (widget &rest ignore)
+                                  (setq notmuch-show-all-tags-list t)
+                                  (notmuch-hello-update))
+                        "Show all tags")))
 
       (let ((start (point)))
        (widget-insert "\n\n")
index fc1346276d7830cf07821683e1aff4d53068fba7..92d3811c995b1b17bc2e92c0c011a911211255ff 100644 (file)
@@ -662,8 +662,8 @@ current buffer, if possible."
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
   ;; Ensure that the part ends with a carriage return.
-  (if (not (bolp))
-      (insert "\n")))
+  (unless (bolp)
+    (insert "\n")))
 
 (defun notmuch-show-insert-body (msg body depth)
   "Insert the body BODY at depth DEPTH in the current thread."
@@ -743,8 +743,8 @@ current buffer, if possible."
     (setq body-start (point-marker))
     (notmuch-show-insert-body msg (plist-get msg :body) depth)
     ;; Ensure that the body ends with a newline.
-    (if (not (bolp))
-       (insert "\n"))
+    (unless (bolp)
+      (insert "\n"))
     (setq body-end (point-marker))
     (setq content-end (point-marker))
 
@@ -885,8 +885,8 @@ buffer."
       (run-hooks 'notmuch-show-hook))
 
     ;; Move straight to the first open message
-    (if (not (notmuch-show-message-visible-p))
-       (notmuch-show-next-open-message))
+    (unless (notmuch-show-message-visible-p)
+      (notmuch-show-next-open-message))
 
     ;; Set the header line to the subject of the first open message.
     (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
index 3602361bd93b5d4679e92ea2d3712248c188c32d..da75fafce62f61a5bb600c5359767dfc62cb3951 100644 (file)
@@ -651,8 +651,8 @@ This function advances the next thread when finished."
                        (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.")
-                       (if (not (= exit-status 0))
-                           (insert (format " (process returned %d)" exit-status)))
+                       (unless (= exit-status 0)
+                         (insert (format " (process returned %d)" exit-status)))
                        (insert "\n")
                        (if (and atbob
                                 (not (string= notmuch-search-target-thread "found")))
@@ -1022,8 +1022,8 @@ Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
 depending on the value of `notmuch-poll-script'."
   (interactive)
   (if (stringp notmuch-poll-script)
-      (if (not (string= notmuch-poll-script ""))
-         (call-process notmuch-poll-script nil nil))
+      (unless (string= notmuch-poll-script "")
+       (call-process notmuch-poll-script nil nil))
     (call-process notmuch-command nil nil nil "new")))
 
 (defun notmuch-search-poll-and-refresh-view ()