aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2020-11-16 22:28:33 +0100
committerDavid Bremner <david@tethera.net>2020-12-06 16:20:57 -0400
commitac8a117a84c8af8a27325b706e0b68a6ada8e478 (patch)
treea0725d1a041da9d2b8016bfc7bb23123c03445cf
parent1fbae387e3b2c1fabf87d9296269421a47976785 (diff)
emacs: remove unnecessary notmuch-remove-if-not
We could just have switched to using `cl-remove-if-not' instead, but the two uses of the *remove-if-not function are pretty strange to begin with so we refactor to not use any such function at all.
-rw-r--r--emacs/notmuch-hello.el43
-rw-r--r--emacs/notmuch-lib.el9
2 files changed, 20 insertions, 32 deletions
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index f5d9e0ec..fa31694f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -21,8 +21,7 @@
;;; Code:
-(eval-when-compile (require 'cl-lib))
-
+(require 'cl-lib)
(require 'widget)
(require 'wid-edit) ; For `widget-forward'.
@@ -542,21 +541,19 @@ options will be handled as specified for
--batch'. In general we recommend running matching versions of
the CLI and emacs interface."))
(goto-char (point-min))
- (notmuch-remove-if-not
- #'identity
- (mapcar
- (lambda (elem)
- (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
- (search-query (plist-get elem-plist :query))
- (filtered-query (notmuch-hello-filtered-query
- search-query (plist-get options :filter)))
- (message-count (prog1 (read (current-buffer))
- (forward-line 1))))
- (when (and filtered-query (or (plist-get options :show-empty-searches)
- (> message-count 0)))
- (setq elem-plist (plist-put elem-plist :query filtered-query))
- (plist-put elem-plist :count message-count))))
- query-list))))
+ (cl-mapcan
+ (lambda (elem)
+ (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
+ (search-query (plist-get elem-plist :query))
+ (filtered-query (notmuch-hello-filtered-query
+ search-query (plist-get options :filter)))
+ (message-count (prog1 (read (current-buffer))
+ (forward-line 1))))
+ (when (and filtered-query (or (plist-get options :show-empty-searches)
+ (> message-count 0)))
+ (setq elem-plist (plist-put elem-plist :query filtered-query))
+ (list (plist-put elem-plist :count message-count)))))
+ query-list)))
(defun notmuch-hello-insert-buttons (searches)
"Insert buttons for SEARCHES.
@@ -698,12 +695,12 @@ Complete list of currently available key bindings:
(defun notmuch-hello-generate-tag-alist (&optional hide-tags)
"Return an alist from tags to queries to display in the all-tags section."
- (mapcar (lambda (tag)
- (cons tag (concat "tag:" (notmuch-escape-boolean-term tag))))
- (notmuch-remove-if-not
- (lambda (tag)
- (not (member tag hide-tags)))
- (process-lines notmuch-command "search" "--output=tags" "*"))))
+ (cl-mapcan (lambda (tag)
+ (and (not (member tag hide-tags))
+ (list (cons tag
+ (concat "tag:"
+ (notmuch-escape-boolean-term tag))))))
+ (process-lines notmuch-command "search" "--output=tags" "*")))
(defun notmuch-hello-insert-header ()
"Insert the default notmuch-hello header."
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8ee3f17f..d7c6b737 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -534,15 +534,6 @@ This replaces spaces, percents, and double quotes in STR with
;;
-(defun notmuch-remove-if-not (predicate list)
- "Return a copy of LIST with all items not satisfying PREDICATE removed."
- (let (out)
- (while list
- (when (funcall predicate (car list))
- (push (car list) out))
- (setq list (cdr list)))
- (nreverse out)))
-
(defun notmuch-plist-delete (plist property)
(let* ((xplist (cons nil plist))
(pred xplist))