[PATCH 31/32] emacs: use string-empty-p

Subject: [PATCH 31/32] emacs: use string-empty-p

Date: Mon, 14 Dec 2020 17:24:00 +0100

To: notmuch@notmuchmail.org

Cc:

From: Jonas Bernoulli


Unfortunately that means we have to explicitly require subr-x, which
arguably should always be loaded without packages having to require
it, but the Emacs developers decided otherwise.  Loading it explicitly
most likely comes without any additional cost because almost certainly
some other packages would load it anyway--the functions it defines are
that popular.  And we are likely to use other functions from subr-x in
the future.
---
 emacs/notmuch-lib.el  | 3 ++-
 emacs/notmuch-mua.el  | 3 ++-
 emacs/notmuch-show.el | 5 +++--
 emacs/notmuch-tag.el  | 3 ++-
 emacs/notmuch.el      | 5 +++--
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index cbac8859..7a64e728 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'subr-x)
 
 (require 'mm-util)
 (require 'mm-view)
@@ -283,7 +284,7 @@ (defun notmuch-poll ()
   (interactive)
   (message "Polling mail...")
   (if (stringp notmuch-poll-script)
-      (unless (string= notmuch-poll-script "")
+      (unless (string-empty-p notmuch-poll-script)
 	(unless (equal (call-process notmuch-poll-script nil nil) 0)
 	  (error "Notmuch: poll script `%s' failed!" notmuch-poll-script)))
     (notmuch-call-notmuch-process "new"))
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2e4dc71a..a8643522 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'subr-x)
 
 (require 'message)
 (require 'mm-view)
@@ -390,7 +391,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)))
-      (unless (string= "" user-agent)
+      (unless (string-empty-p 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-show.el b/emacs/notmuch-show.el
index 27925669..13d08b62 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -26,6 +26,7 @@
 (eval-when-compile
   (require 'cl-lib)
   (require 'pcase))
+(require 'subr-x)
 
 (require 'mm-view)
 (require 'message)
@@ -337,7 +338,7 @@ (defun notmuch-show-with-message-as-text (fn)
 	 (header (concat
 		  "Subject: " subject "\n"
 		  "To: " to "\n"
-		  (if (not (string= cc ""))
+		  (if (not (string-empty-p cc))
 		      (concat "Cc: " cc "\n")
 		    "")
 		  "From: " from "\n"
@@ -1794,7 +1795,7 @@ (defun notmuch-show-filter-thread (query)
 Reshows the current thread with matches defined by the new query-string."
   (interactive (list (notmuch-read-query "Filter thread: ")))
   (let ((msg-id (notmuch-show-get-message-id)))
-    (setq notmuch-show-query-context (if (string= query "") nil query))
+    (setq notmuch-show-query-context (if (string-empty-p query) nil query))
     (notmuch-show-refresh-view t)
     (notmuch-show-goto-message msg-id)))
 
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 3c958dd4..1e8f7d4d 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -26,6 +26,7 @@
 (require 'cl-lib)
 (eval-when-compile
   (require 'pcase))
+(require 'subr-x)
 
 (require 'crm)
 
@@ -456,7 +457,7 @@ (defun notmuch-update-tags (tags tag-changes)
 from TAGS if present."
   (let ((result-tags (copy-sequence tags)))
     (dolist (tag-change tag-changes)
-      (let ((tag (and (not (string= tag-change ""))
+      (let ((tag (and (not (string-empty-p tag-change))
 		      (substring tag-change 1))))
 	(cl-case (aref tag-change 0)
 	  (?+ (unless (member tag result-tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6553893b..860b3d6a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -66,6 +66,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'subr-x)
 
 (require 'mm-view)
 (require 'message)
@@ -816,13 +817,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.
-      (unless (string= invisible-string "")
+      (unless (string-empty-p 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)
-      (unless (string= invisible-string "")
+      (unless (string-empty-p invisible-string)
 	(let ((start (point))
 	      overlay)
 	  (insert invisible-string)
-- 
2.29.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: