From 4b24c759e19aa2998a150f424e8187b052d7d5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Mon, 16 Dec 2024 01:28:16 +0200 Subject: [PATCH] Implement search for nnvirtual Gnus groups * lisp/gnus/nnvirtual.el (nnvirtual-request-list): Implement request list backend function for nnvirtual. * lisp/gnus/gnus-search.el (gnus-search-nnvirtual): Implement function to build search queries for nnvirtual. (gnus-search-default-search-engines, gnus-search-server-to-enngine): Include nnvirtual. --- lisp/gnus/gnus-search.el | 29 ++++++++++++++++++++++++++--- lisp/gnus/nnvirtual.el | 7 +++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index ca82546ef82..4a7cf902b32 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -795,6 +795,9 @@ shared-initialize (defclass gnus-search-nnselect (gnus-search-engine) nil) +(defclass gnus-search-nnvirtual (gnus-search-engine) + nil) + (defclass gnus-search-imap (gnus-search-engine) ((literal-plus :initarg :literal-plus @@ -953,14 +956,16 @@ 'nnir-method-default-engines 'gnus-search-default-engines "28.1") (defcustom gnus-search-default-engines '((nnimap . gnus-search-imap) - (nnselect . gnus-search-nnselect)) + (nnselect . gnus-search-nnselect) + (nnvirtual . gnus-search-nnvirtual)) "Alist of default search engines keyed by server method." - :version "26.1" + :version "31.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 nnselect)) + (const nnselect) + (const nnvirtual)) (choice ,@(mapcar (lambda (el) (list 'const (intern (car el)))) @@ -1086,6 +1091,23 @@ gnus-search-run-search (cons 'search-group-spec group-spec)))))))) artlist)) +;; nnvirtual interface +(cl-defmethod gnus-search-run-search ((_engine gnus-search-nnvirtual) + srv query-spec _groups) + ;; fixme groups vs srv which of? + ;; in theory the function could get multiple groups of one server + ;; but for nnvirtual server = group + (save-excursion + (let* (;; Not really a server but the matching groups for the nnvirtual group + (grouplist (mapcar #'gnus-group-short-name (gnus-search-get-active srv))) + ;; group each group as list containing each server and their groups + (group-spec (nnselect-categorize grouplist (lambda (x) (gnus-group-server x)))) + (artlist [])) + (setq artlist (vconcat artlist + (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) @@ -2153,6 +2175,7 @@ gnus-search-server-to-engine ('namazu 'gnus-search-namazu) ('find-grep 'gnus-search-find-grep) ('imap 'gnus-search-imap) + ('nnvirtual 'gnus-search-nnvirtual) (_ server)) inst (cond diff --git a/lisp/gnus/nnvirtual.el b/lisp/gnus/nnvirtual.el index 79747dca31f..edc97a8ca63 100644 --- a/lisp/gnus/nnvirtual.el +++ b/lisp/gnus/nnvirtual.el @@ -293,6 +293,13 @@ nnvirtual-close-group (nnvirtual-update-read-and-marked t t)) t) +(deffoo nnvirtual-request-list (&optional server) + (when (nnvirtual-possibly-change-server server) + (with-current-buffer nntp-server-buffer + (erase-buffer) + (dolist (group nnvirtual-component-groups) + (insert (format "%S 0 1 y\n" group)))) + t)) (deffoo nnvirtual-request-newgroups (_date &optional _server) (nnheader-report 'nnvirtual "NEWGROUPS is not supported.")) -- 2.45.2