From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wJv7DDqvK188SAAA0tVLHw (envelope-from ) for ; Thu, 06 Aug 2020 07:20:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id KFqsCDqvK1+WXAAAbx9fmQ (envelope-from ) for ; Thu, 06 Aug 2020 07:20:26 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9005A9403EC for ; Thu, 6 Aug 2020 07:20:25 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9DB4B29AC9; Thu, 6 Aug 2020 03:19:45 -0400 (EDT) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 7A38729AA4 for ; Thu, 6 Aug 2020 03:19:15 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 1FA36B7D5C for ; Thu, 6 Aug 2020 09:19:12 +0200 (CEST) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id d5pWofU2MFDh for ; Thu, 6 Aug 2020 09:19:11 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id ADCCDB7D51 for ; Thu, 6 Aug 2020 09:19:11 +0200 (CEST) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH v2 08/23] emacs: Use 'unless' instead of 'when' and 'not' Date: Thu, 6 Aug 2020 09:18:55 +0200 Message-Id: <20200806071910.10369-9-jonas@bernoul.li> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200806071910.10369-1-jonas@bernoul.li> References: <20200726165818.400-1-jonas@bernoul.li> <20200806071910.10369-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: 2BHHIFYBEPAYA2FBQYG6WNNHHGPSC43O X-Message-ID-Hash: 2BHHIFYBEPAYA2FBQYG6WNNHHGPSC43O X-MailFrom: jonas@bernoul.li X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 0.03 X-TUID: vX5DYO2phK8p Also use 'unless' in a few cases where previously 'if' was used with 'not' but without an ELSE part. --- emacs/notmuch-hello.el | 6 +++--- emacs/notmuch-mua.el | 4 ++-- emacs/notmuch-parser.el | 2 +- emacs/notmuch-show.el | 3 +-- emacs/notmuch-tag.el | 4 ++-- emacs/notmuch-tree.el | 8 ++++---- emacs/notmuch.el | 4 ++-- test/test-lib.el | 6 +++--- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 1c084bf7..25e28a52 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -638,7 +638,7 @@ (defun notmuch-hello-window-configuration-change () (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 @@ (defun notmuch-hello-window-configuration-change () ;; 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 @@ (defun notmuch-hello-insert-searches (title query-list &rest options) (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 @@ (defun notmuch-mua-user-agent-emacs () (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 @@ (defun notmuch-mua-mail (&optional to subject other-headers continue (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 @@ (defun notmuch-sexp-read (sp) ;; 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 211be091..6102ca2e 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1060,8 +1060,7 @@ (defun notmuch-show-insert-msg (msg depth) ;; 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 @@ (defun notmuch-tag-completions (&rest search-terms) "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 @@ (defun notmuch-tree (&optional query query-context target buffer-name open-targe 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 @@ (defun notmuch-search-insert-authors (format-string authors) (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 @@ (defun visible-buffer-substring (start end) (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 @@ (defun test-process-running (pid) (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." -- 2.28.0