Function: gnus-search-run-query

gnus-search-run-query is a byte-compiled function defined in gnus-search.el.gz.

Signature

(gnus-search-run-query SPECS)

Documentation

Invoke appropriate search engine function.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-search.el.gz
;;; Util Code:

(defun gnus-search-run-query (specs)
  "Invoke appropriate search engine function."
  ;; For now, run the searches synchronously.  At some point
  ;; multiple-server searches can each be run in their own thread,
  ;; allowing concurrent searches of multiple backends.  At present
  ;; this causes problems when searching more than one server that
  ;; uses `nntp-server-buffer', as their return values are written
  ;; interleaved into that buffer.  Anyway, that's the reason for the
  ;; `mapc'.
  (let* ((results [])
	 (prepared-query (gnus-search-prepare-query
			  (alist-get 'search-query-spec specs)))
	 (limit (alist-get 'limit prepared-query)))
    (mapc
     (pcase-lambda (`(,server . ,groups))
       (condition-case err
	   (let ((search-engine (gnus-search-server-to-engine server)))
	     (setq results
		   (vconcat
		    (gnus-search-run-search
		     search-engine server prepared-query groups)
		    results)))
	 (gnus-search-config-error
	  (if (< 1 (length (alist-get 'search-group-spec specs)))
	      (apply #'nnheader-message 4
		     "Search engine for %s improperly configured: %s"
		     server (cdr err))
	    (signal 'gnus-search-config-error err)))))
     (alist-get 'search-group-spec specs))
    ;; Some search engines do their own limiting, but some don't, so
    ;; do it again here.  This is bad because, if the user is
    ;; searching multiple groups, they would reasonably expect the
    ;; limiting to apply to the search results *after sorting*.  Doing
    ;; it this way is liable to, for instance, eliminate all results
    ;; from a later group entirely.
    (if limit
	(seq-subseq results 0 (min limit (length results)))
      results)))