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.
This commit is contained in:
Jonas Bernoulli 2020-11-16 22:28:33 +01:00 committed by David Bremner
parent 1fbae387e3
commit ac8a117a84
2 changed files with 20 additions and 32 deletions

View file

@ -21,8 +21,7 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'cl-lib)) (require 'cl-lib)
(require 'widget) (require 'widget)
(require 'wid-edit) ; For `widget-forward'. (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 --batch'. In general we recommend running matching versions of
the CLI and emacs interface.")) the CLI and emacs interface."))
(goto-char (point-min)) (goto-char (point-min))
(notmuch-remove-if-not (cl-mapcan
#'identity (lambda (elem)
(mapcar (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
(lambda (elem) (search-query (plist-get elem-plist :query))
(let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)) (filtered-query (notmuch-hello-filtered-query
(search-query (plist-get elem-plist :query)) search-query (plist-get options :filter)))
(filtered-query (notmuch-hello-filtered-query (message-count (prog1 (read (current-buffer))
search-query (plist-get options :filter))) (forward-line 1))))
(message-count (prog1 (read (current-buffer)) (when (and filtered-query (or (plist-get options :show-empty-searches)
(forward-line 1)))) (> message-count 0)))
(when (and filtered-query (or (plist-get options :show-empty-searches) (setq elem-plist (plist-put elem-plist :query filtered-query))
(> message-count 0))) (list (plist-put elem-plist :count message-count)))))
(setq elem-plist (plist-put elem-plist :query filtered-query)) query-list)))
(plist-put elem-plist :count message-count))))
query-list))))
(defun notmuch-hello-insert-buttons (searches) (defun notmuch-hello-insert-buttons (searches)
"Insert buttons for 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) (defun notmuch-hello-generate-tag-alist (&optional hide-tags)
"Return an alist from tags to queries to display in the all-tags section." "Return an alist from tags to queries to display in the all-tags section."
(mapcar (lambda (tag) (cl-mapcan (lambda (tag)
(cons tag (concat "tag:" (notmuch-escape-boolean-term tag)))) (and (not (member tag hide-tags))
(notmuch-remove-if-not (list (cons tag
(lambda (tag) (concat "tag:"
(not (member tag hide-tags))) (notmuch-escape-boolean-term tag))))))
(process-lines notmuch-command "search" "--output=tags" "*")))) (process-lines notmuch-command "search" "--output=tags" "*")))
(defun notmuch-hello-insert-header () (defun notmuch-hello-insert-header ()
"Insert the default notmuch-hello header." "Insert the default notmuch-hello header."

View file

@ -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) (defun notmuch-plist-delete (plist property)
(let* ((xplist (cons nil plist)) (let* ((xplist (cons nil plist))
(pred xplist)) (pred xplist))