]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Use 'unless' instead of 'when' and 'not'
authorJonas Bernoulli <jonas@bernoul.li>
Sat, 8 Aug 2020 11:49:42 +0000 (13:49 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 9 Aug 2020 23:51:26 +0000 (20:51 -0300)
Also use 'unless' in a few cases where previously 'if' was used with
'not' but without an ELSE part.

emacs/notmuch-hello.el
emacs/notmuch-mua.el
emacs/notmuch-parser.el
emacs/notmuch-show.el
emacs/notmuch-tag.el
emacs/notmuch-tree.el
emacs/notmuch.el
test/test-lib.el

index 89e03c366fc8c02ae4b85e5cb4ac2e605663c1bb..1c0b18485296edaa44ef16b7e24ca5f5121f072a 100644 (file)
@@ -638,7 +638,7 @@ with `notmuch-hello-query-counts'."
     (dolist (window (window-list))
       (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))
            (cur-buf (window-buffer window)))
-       (when (not (eq last-buf cur-buf))
+       (unless (eq last-buf cur-buf)
          ;; This window changed or is new.  Update recorded buffer
          ;; for next time.
          (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)
@@ -652,7 +652,7 @@ with `notmuch-hello-query-counts'."
       ;; 24, we can't do it right here because something in this
       ;; hook's call stack overrides hello's point placement.
       (run-at-time nil nil #'notmuch-hello t))
-    (when (null hello-buf)
+    (unless hello-buf
       ;; Clean up hook
       (remove-hook 'window-configuration-change-hook
                   #'notmuch-hello-window-configuration-change))))
@@ -908,7 +908,7 @@ Supports the following entries in OPTIONS as a plist:
                                (notmuch-hello-update))
                     "hide"))
     (widget-insert "\n")
-    (when (not is-hidden)
+    (unless is-hidden
       (let ((searches (apply 'notmuch-hello-query-counts query-list options)))
        (when (or (not (plist-get options :hide-if-empty))
                  searches)
index f6d8ffc55ca9de4abec415fa088ffc46910843fb..dc1f518caf03c784b134cf6728ae04ac7a068e14 100644 (file)
@@ -198,7 +198,7 @@ Typically this is added to `notmuch-mua-send-hook'."
 (defun notmuch-mua-add-more-hidden-headers ()
   "Add some headers to the list that are hidden by default."
   (mapc (lambda (header)
-         (when (not (member header message-hidden-headers))
+         (unless (member header message-hidden-headers)
            (push header message-hidden-headers)))
        notmuch-mua-hidden-headers))
 
@@ -368,7 +368,7 @@ modified. This function is notmuch addaptation of
   (interactive)
   (when notmuch-mua-user-agent-function
     (let ((user-agent (funcall notmuch-mua-user-agent-function)))
-      (when (not (string= "" user-agent))
+      (unless (string= "" user-agent)
        (push (cons 'User-Agent user-agent) other-headers))))
   (unless (assq 'From other-headers)
     (push (cons 'From (message-make-from
index 06e7487bd3270bcd3e424927abd62cbc6acf6f8f..fbcfc2efb4e6ca624a17198c4b84fc37669e5ec5 100644 (file)
@@ -78,7 +78,7 @@ returns the value."
         ;; parse, extend the partial parse to figure out when we
         ;; have a complete list.
         (catch 'return
-          (when (null (notmuch-sexp--partial-state sp))
+          (unless (notmuch-sexp--partial-state sp)
             (let ((start (point)))
               (condition-case nil
                   (throw 'return (read (current-buffer)))
index 531ce1ae5179a6db6e00e03137ed2a3e69d2a808..7a03315027e088f721ad0d25bf46093ec3ba0d68 100644 (file)
@@ -1066,8 +1066,7 @@ is t, hide the part initially and show the button."
       ;; If the subject of this message is the same as that of the
       ;; previous message, don't display it when this message is
       ;; collapsed.
-      (when (not (string= notmuch-show-previous-subject
-                         bare-subject))
+      (unless (string= notmuch-show-previous-subject bare-subject)
        (forward-line 1))
       (setq headers-start (point-marker)))
     (setq headers-end (point-marker))
index 2fcf5a9e9fa65073a9bf0f71b839ce8af3dfc2c1..1067f18513018802607276ae92edb4b2654adc0b 100644 (file)
@@ -382,8 +382,8 @@ the messages that were tagged."
   "Return a list of tags for messages matching SEARCH-TERMS.
 
 Returns all tags if no search terms are given."
-  (if (null search-terms)
-      (setq search-terms (list "*")))
+  (unless search-terms
+    (setq search-terms (list "*")))
   (split-string
    (with-output-to-string
      (with-current-buffer standard-output
index 37a5d1c843015c6226ec217f2d59bda414473914..a5ae0edb1dec98908065379ad77a69cb9921d7be 100644 (file)
@@ -1063,10 +1063,10 @@ The arguments are:
   OPEN-TARGET: If TRUE open the target message in the message pane.
   UNTHREADED: If TRUE only show matching messages in an unthreaded view."
   (interactive)
-  (if (null query)
-      (setq query (notmuch-read-query (concat "Notmuch "
-                                             (if unthreaded "unthreaded " "tree ")
-                                             "view search: "))))
+  (unless query
+    (setq query (notmuch-read-query (concat "Notmuch "
+                                           (if unthreaded "unthreaded " "tree ")
+                                           "view search: "))))
   (let ((buffer (get-buffer-create (generate-new-buffer-name
                                    (or buffer-name
                                        (concat "*notmuch-"
index 4120764352ff57115d9d4cae63f96ef87e227f02..93e92b391fde9753ae6d15f4a869fc19f89fb995 100644 (file)
@@ -803,13 +803,13 @@ non-authors is found, assume that all of the authors match."
        (setq invisible-string (notmuch-search-author-propertize invisible-string)))
       ;; If there is any invisible text, add it as a tooltip to the
       ;; visible text.
-      (when (not (string= invisible-string ""))
+      (unless (string= invisible-string "")
        (setq visible-string
              (propertize visible-string
                          'help-echo (concat "..." invisible-string))))
       ;; Insert the visible and, if present, invisible author strings.
       (insert visible-string)
-      (when (not (string= invisible-string ""))
+      (unless (string= invisible-string "")
        (let ((start (point))
              overlay)
          (insert invisible-string)
index aae9e8333f5f7558b4116b83c5263774a5769782..a12333900801736843d6032db91f071647a0b056 100644 (file)
@@ -81,7 +81,7 @@ invisible text."
   (let (str)
     (while (< start end)
       (let ((next-pos (next-char-property-change start end)))
-       (when (not (invisible-p start))
+       (unless (invisible-p start)
          (setq str (concat str (buffer-substring-no-properties
                                 start next-pos))))
        (setq start next-pos)))
@@ -97,8 +97,8 @@ invisible text."
 (defun orphan-watchdog-check (pid)
   "Periodically check that the process with id PID is still
 running, quit if it terminated."
-  (if (not (test-process-running pid))
-      (kill-emacs)))
+  (unless (test-process-running pid)
+    (kill-emacs)))
 
 (defun orphan-watchdog (pid)
   "Initiate orphan watchdog check."