summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2020-08-08 13:49:42 +0200
committerDavid Bremner <david@tethera.net>2020-08-09 20:51:26 -0300
commit09f6533c3781b61ea634790d4bad38aadf89115c (patch)
tree7d91a0aa4e5dab8721befee1b8ad79879f8772e6
parentdfb1b8eb89e814f4bf6f6e62b700c72aa1b4659a (diff)
emacs: Use 'unless' instead of 'when' and 'not'
Also use 'unless' in a few cases where previously 'if' was used with 'not' but without an ELSE part.
-rw-r--r--emacs/notmuch-hello.el6
-rw-r--r--emacs/notmuch-mua.el4
-rw-r--r--emacs/notmuch-parser.el2
-rw-r--r--emacs/notmuch-show.el3
-rw-r--r--emacs/notmuch-tag.el4
-rw-r--r--emacs/notmuch-tree.el8
-rw-r--r--emacs/notmuch.el4
-rw-r--r--test/test-lib.el6
8 files changed, 18 insertions, 19 deletions
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 89e03c36..1c0b1848 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -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)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index f6d8ffc5..dc1f518c 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -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
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index 06e7487b..fbcfc2ef 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -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)))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 531ce1ae..7a033150 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -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))
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 2fcf5a9e..1067f185 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -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
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 37a5d1c8..a5ae0edb 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -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-"
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 41207643..93e92b39 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -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)
diff --git a/test/test-lib.el b/test/test-lib.el
index aae9e833..a1233390 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -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."