1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-22 18:35:09 +00:00

Allow searching of nnselect (search) groups

* lisp/gnus/gnus-group.el (gnus-group-make-search-group):
(gnus-group-read-ephemeral-search-group):  Ensure the server is
correctly identified even for nnselect groups.
* lisp/gnus/gnus-search.el (gnus-search-nnselect): New function.
(gnus-search-default-engines): Use it.
(gnus-search-make-spec): Queries from nnselect should always be raw.
* lisp/gnus/nnselect.el (gnus-search): Silence the byte-compiler.
This commit is contained in:
Andrew G Cohen 2022-02-11 15:09:46 +08:00
parent 20da50619f
commit 48e8569c87
3 changed files with 42 additions and 6 deletions

View File

@ -3226,7 +3226,8 @@ non-nil SPECS arg must be an alist with `search-query-spec' and
(if (gnus-server-server-name)
(list (list (gnus-server-server-name)))
(seq-group-by
(lambda (elt) (gnus-group-server elt))
(lambda (elt) (gnus-method-to-server
(gnus-find-method-for-group elt)))
(or gnus-group-marked
(if (gnus-group-group-name)
(list (gnus-group-group-name))
@ -3277,7 +3278,8 @@ non-nil SPECS arg must be an alist with `search-query-spec' and
(if (gnus-server-server-name)
(list (list (gnus-server-server-name)))
(seq-group-by
(lambda (elt) (gnus-group-server elt))
(lambda (elt) (gnus-method-to-server
(gnus-find-method-for-group elt)))
(or gnus-group-marked
(if (gnus-group-group-name)
(list (gnus-group-group-name))

View File

@ -762,6 +762,9 @@ the files in ARTLIST by that search key.")
(generate-new-buffer " *gnus-search-")))
(cl-call-next-method engine slots))
(defclass gnus-search-nnselect (gnus-search-engine)
nil)
(defclass gnus-search-imap (gnus-search-engine)
((literal-plus
:initarg :literal-plus
@ -907,13 +910,15 @@ quirks.")
(define-obsolete-variable-alias 'nnir-method-default-engines
'gnus-search-default-engines "28.1")
(defcustom gnus-search-default-engines '((nnimap . gnus-search-imap))
(defcustom gnus-search-default-engines '((nnimap . gnus-search-imap)
(nnselect . gnus-search-nnselect))
"Alist of default search engines keyed by server method."
:version "26.1"
:type `(repeat (cons (choice (const nnimap) (const nntp) (const nnspool)
(const nneething) (const nndir) (const nnmbox)
(const nnml) (const nnmh) (const nndraft)
(const nnfolder) (const nnmaildir))
(const nnfolder) (const nnmaildir)
(const nnselect))
(choice
,@(mapcar
(lambda (el) (list 'const (intern (car el))))
@ -1010,6 +1015,33 @@ Responsible for handling and, or, and parenthetical expressions.")
unseen all old new or not)
"Known IMAP search keys.")
(autoload 'nnselect-categorize "nnselect")
(autoload 'nnselect-get-artlist "nnselect" nil nil 'macro)
(autoload 'ids-by-group "nnselect")
;; nnselect interface
(cl-defmethod gnus-search-run-search ((_engine gnus-search-nnselect)
_srv query-spec groups)
(let ((artlist []))
(dolist (group groups)
(let* ((gnus-newsgroup-selection (nnselect-get-artlist group))
(group-spec
(nnselect-categorize
(mapcar 'car
(ids-by-group
(number-sequence 1
(length gnus-newsgroup-selection))))
(lambda (x)
(gnus-group-server x)))))
(setq artlist
(vconcat artlist
(seq-intersection
gnus-newsgroup-selection
(gnus-search-run-query
(list (cons 'search-query-spec query-spec)
(cons 'search-group-spec group-spec))))))))
artlist))
;; imap interface
(cl-defmethod gnus-search-run-search ((engine gnus-search-imap)
srv query groups)
@ -2155,7 +2187,8 @@ article came from is also searched."
(read-from-minibuffer
"Query: " nil gnus-search-minibuffer-map
nil 'gnus-search-history)))
(cons 'raw arg)))
(cons 'raw
(or (gnus-nnselect-group-p (gnus-group-group-name)) arg))))
(provide 'gnus-search)
;;; gnus-search.el ends here

View File

@ -47,7 +47,8 @@
;;; Setup:
(require 'gnus-art)
(require 'gnus-search)
(autoload 'gnus-search-run-query "gnus-search")
(autoload 'gnus-search-server-to-engine "gnus-search")
(eval-when-compile (require 'cl-lib))