Gnus development mailing list
 help / color / mirror / Atom feed
From: dal-blazej@onenetbeyond.org
To: ding@gnus.org
Subject: Re: search engine for virtual group?
Date: Thu, 03 Mar 2022 17:56:49 +0100	[thread overview]
Message-ID: <87sfrzvusu.fsf@onenetbeyond.org> (raw)
In-Reply-To: <87tudicjnh.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Tue, 01 Feb 2022 22:21:54 +0000")


Hi,

Here are some of my observations about nnselect groups :

*** nnselect groups
:PROPERTIES:
:header-args: :noweb-ref gnus-nnselect-groups :tangle no
:END:

The nnselect method replaces the obsolete nnir method and most usage of virtual
groups.  Basically it lets you makes searches out of your servers, eventually
making it permanent as a new group.  It is designed to be build interactively
(and well, it's /kinda/ easier).  Can we wrap it non-interactively so it becomes
declarative ?  Yup.

#+begin_src emacs-lisp
(with-eval-after-load 'gnus
  (defun dal-gnus-group-make-group-batch (name meth address args)
    "Same as `gnus-group-make-group', but can be run non-interactively."
    (unless (gnus-get-info (gnus-group-prefixed-name name meth))
      (cl-letf (((symbol-function 'gnus-group-insert-group-line-info) #'ignore)
                ((symbol-function 'gnus-group-position-point) #'ignore))
        (save-excursion (gnus-group-make-group name meth address args))))))

(add-hook 'gnus-topic-mode-hook
          (lambda () (dal-gnus-group-make-group-batch
                      "recent" '(nnselect "nnselect") nil
                      '((nnselect-specs
                         (nnselect-function . gnus-search-run-query)
                         (nnselect-args
                          (search-query-spec (query . "sentsince:7d"))
                          (search-group-spec ("nnimap:Dal"))))
                        (nnselect-rescan . t)))))
#+end_src

The group creation does not allow to specify arbitrary group parameters, let's
correct that.

#+begin_src emacs-lisp
(with-eval-after-load 'nnoo
  ;; First the creation of the group does not allow to set parameters.
  (defun nnselect-request-create-group-a (group &optional _server args)
    (message "Creating nnselect group %s" group)
    (let* ((group (gnus-group-prefixed-name group '(nnselect "nnselect")))
           (specs (assq 'nnselect-specs args))
           (function-spec
            (or (alist-get 'nnselect-function specs)
                (intern (completing-read "Function: " obarray #'functionp))))
           (args-spec
            (or (alist-get 'nnselect-args specs)
                (read-from-minibuffer "Args: " nil nil t nil "nil")))
           (nnselect-specs (list (cons 'nnselect-function function-spec)
                                 (cons 'nnselect-args args-spec))))
      (gnus-group-set-parameter group 'nnselect-specs nnselect-specs)
      (gnus-group-set-parameter
       group 'nnselect-artlist
       (nnselect-compress-artlist (or (alist-get 'nnselect-artlist args)
                                      (nnselect-run nnselect-specs))))
      (setq args (assq-delete-all 'nnselect-specs args)) ;; patch
      (dolist (param args)
        (gnus-group-set-parameter group (car param) (cdr param)))
      (nnselect-request-update-info group (gnus-get-info group)))
    t)

  (advice-add 'nnselect-request-create-group :override
              #'nnselect-request-create-group-a)
#+end_src

Rescan the group regularly.  but that doesn't work ?! Wth ?

#+begin_src emacs-lisp
(add-to-list 'gnus-parameters '("nnselect:recent" (nnselect-rescan . t)))
#+end_src

It doesn't work because of a confusion between ~gnus-group-get-parameter~ and
~gnus-group-find-parameter~.

#+begin_src emacs-lisp
(defun nnselect-request-scan-a (group _method)
  (when (and group
             (gnus-group-find-parameter  (nnselect-add-prefix group) ; patch
      				   'nnselect-rescan t))
    (nnselect-request-group-scan group)))

(advice-add 'nnselect-request-scan :override #'nnselect-request-scan-a))
#+end_src


  reply	other threads:[~2022-03-03 18:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 18:46 Eric Abrahamsen
2022-02-01 22:21 ` Eric S Fraga
2022-03-03 16:56   ` dal-blazej [this message]
2022-03-07  0:39     ` Andrew Cohen
  -- strict thread matches above, loose matches on Subject: below --
2022-02-01  8:52 Eric S Fraga
2022-02-01 16:35 ` Eric Abrahamsen
2022-02-01 16:57   ` Andreas Schwab
2022-02-01 17:23     ` Eric Abrahamsen
2022-02-01 17:11   ` Eric S Fraga
2022-02-01 17:29     ` Eric Abrahamsen
2022-02-01 17:38       ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfrzvusu.fsf@onenetbeyond.org \
    --to=dal-blazej@onenetbeyond.org \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).