emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master dc2e6f7: [gnorb] Add code path for users with nnselect ava


From: Eric Abrahamsen
Subject: [elpa] master dc2e6f7: [gnorb] Add code path for users with nnselect available
Date: Sun, 13 Sep 2020 17:17:52 -0400 (EDT)

branch: master
commit dc2e6f756fe351752033fc2f501c5f0dc305d862
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    [gnorb] Add code path for users with nnselect available
    
    Not flushing new version just yet.
    
    * packages/gnorb/gnorb-gnus.el (gnorb-gnus-nnselect-search): New
    function for searching using nnselect instead of nnir.
    (gnorb-gnus-search-messages): Pick a code path.
    * packages/gnorb/nngnorb.el (gnorb-run-search): Pull most of search
    functionality into a separate function that nnselect can call
    directly.
    (nnir-run-gnorb): For the nnir case, munge the query slightly then
    pass it on to the above function.
    * packages/gnorb/gnorb.org:
    * packages/gnorb/gnorb.texi:
    * packages/gnorb/gnorb.info: Document all this.
---
 packages/gnorb/gnorb-gnus.el |  78 ++++++++++++++-------
 packages/gnorb/gnorb.info    |  80 ++++++++++-----------
 packages/gnorb/gnorb.org     |   4 +-
 packages/gnorb/gnorb.texi    |  26 +++----
 packages/gnorb/nngnorb.el    | 161 ++++++++++++++++++++++---------------------
 5 files changed, 193 insertions(+), 156 deletions(-)

diff --git a/packages/gnorb/gnorb-gnus.el b/packages/gnorb/gnorb-gnus.el
index 210b518..c48d625 100644
--- a/packages/gnorb/gnorb-gnus.el
+++ b/packages/gnorb/gnorb-gnus.el
@@ -883,36 +883,63 @@ Org tags search, in which case links will be collected 
from all
 matching headings.
 
 In either case, once a collection of links have been made, they
-will all be displayed in an ephemeral group on the \"nngnorb\"
-server.  There must be an active \"nngnorb\" server for this to
-work.
+will all be displayed in an ephemeral Gnus group.  In Emacs 27
+and below this requires the presence of an active \"nngnorb\"
+server to work.  In Emacs 28 and later, no setup is required.
 
 If PERSIST is non-nil, make a permanent group, and offer
 HEAD-TEXT, if present, as its name.  Otherwise create an
 ephemeral one, with RET as the value of its quit-config."
   (interactive)
-  (require 'nnir)
   (unless (gnus-alive-p)
     (gnus))
-  (let* ((nnir-address (gnorb-gnus-find-gnorb-server))
-        (name (if persist
-                  (read-string
-                   (format "Name for group (default %s): " head-text)
-                   nil nil head-text)
-                (concat "gnorb-" str)))
-        (method (list 'nnir nnir-address))
-        (spec (list
-               (cons 'nnir-specs (list (cons 'nnir-query-spec
-                                             `((query . ,str)))
-                                       (cons 'nnir-group-spec
-                                             `((,nnir-address ,(list name))))))
-               (cons 'nnir-artlist nil))))
-    (if persist
-       (progn
-         (switch-to-buffer gnus-group-buffer)
-         (gnus-group-make-group name method nil spec)
-         (gnus-group-select-group))
-      (gnus-group-read-ephemeral-group name method nil ret nil nil spec))))
+  (if (featurep 'nnselect)
+      (gnorb-gnus-nnselect-search str persist head-text ret)
+    (require 'nnir)
+    (let* ((nnir-address (gnorb-gnus-find-gnorb-server))
+          (name (if persist
+                    (read-string
+                     (format "Name for group (default %s): " head-text)
+                     nil nil head-text)
+                  (concat "gnorb-" str)))
+          (method (list 'nnir nnir-address))
+          (spec (list
+                 (cons 'nnir-specs (list (cons 'nnir-query-spec
+                                               `((query . ,str)))
+                                         (cons 'nnir-group-spec
+                                               `((,nnir-address ,(list 
name))))))
+                 (cons 'nnir-artlist nil))))
+      (if persist
+         (progn
+           (switch-to-buffer gnus-group-buffer)
+           (gnus-group-make-group name method nil spec)
+           (gnus-group-select-group))
+       (gnus-group-read-ephemeral-group name method nil ret nil nil spec)))))
+
+(defun gnorb-gnus-nnselect-search (str persist &optional head-text ret)
+  "Display gnus messages using the nnselect backend."
+  (if persist
+      (let ((name (gnus-read-group
+                  (format "Name for group (default %s): " head-text)
+                  head-text)))
+       (with-current-buffer gnus-group-buffer
+         (gnus-group-make-group
+          name (list 'nnselect "nnselect-gnorb")
+          nil (list
+               (cons 'nnselect-specs
+                     (list (cons 'nnselect-function 'gnorb-run-search)
+                           (cons 'nnselect-args str)))
+               (cons 'nnselect-artlist nil)))))
+    (gnus-group-read-ephemeral-group
+     (concat "nnselect-" (message-unique-id))
+     (list 'nnselect "nnselect-gnorb")
+     nil ret nil nil
+     (list
+      (cons 'nnselect-specs
+           (list
+            (cons 'nnselect-function 'gnorb-run-search)
+            (cons 'nnselect-args str)))
+      (cons 'nnselect-artlist nil)))))
 
 (defun gnorb-gnus-find-gnorb-server (&optional no-error)
   "Try very hard to find a local nngnorb server.
@@ -936,8 +963,9 @@ error."
 (defun gnorb-gnus-summary-mode-hook ()
   "Check if we've entered a Gnorb-generated group, and activate
   `gnorb-summary-minor-mode', if so."
-  (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
-    (when (string-match-p "Gnorb" (cadr method))
+  (let ((method (gnus-find-method-for-group gnus-newsgroup-name))
+       (case-fold-search t))
+    (when (string-match-p "gnorb" (cadr method))
       (gnorb-summary-minor-mode))))
 
 ;;; Automatic noticing of relevant messages
diff --git a/packages/gnorb/gnorb.info b/packages/gnorb/gnorb.info
index b888083..8677397 100644
--- a/packages/gnorb/gnorb.info
+++ b/packages/gnorb/gnorb.info
@@ -1,4 +1,4 @@
-This is gnorb.info, produced by makeinfo version 6.5 from gnorb.texi.
+This is gnorb.info, produced by makeinfo version 6.7 from gnorb.texi.
 
 INFO-DIR-SECTION Emacs
 START-INFO-DIR-ENTRY
@@ -48,12 +48,12 @@ Misc BBDB
 Misc Org
 
 * Inserting BBDB links::
-* User Options: User Options 1.
+* User Options: User Options (1).
 
 Misc Gnus
 
 * Searching With the Registry::
-* User Options: User Options 2.
+* User Options: User Options (2).
 
 
 
@@ -171,7 +171,7 @@ on it.  You choose “todo state”, and change the heading 
keyword to WAIT.
 
    Two days later, Jimmy replies to your message, saying that March is
 perfect.  When you open his response, Gnorb politely reminds you that
-the message is relevant to an existing TODO. You hit “C-c t” on the
+the message is relevant to an existing TODO.  You hit “C-c t” on the
 message, and are again taken to the TODO and asked to trigger an action.
 Again you choose “todo state”, and change the heading keyword back to
 REPLY.
@@ -215,7 +215,9 @@ Email tracking requires the following steps:
      should be enough).
   3. Add a nngnorb entry to your ‘gnus-secondary-select-methods’
      variable.  It will look like (nngnorb “Server name”).  This does
-     nothing but provide a place to hang nnir searches.
+     nothing but provide a place to hang nnir searches.  If you are
+     using the Gnus that comes with Emacs 28 or later (or check
+     ‘(featurep 'nnselect)’ to be sure), this step is unnecessary.
   4. Then put a call to ‘gnorb-tracking-initialize’ in your init files.
   5. If you’re not using a local archive method for saving your sent
      messages (ie you’re using IMAP), you’ll also need to tell Gnorb
@@ -233,7 +235,7 @@ File: gnorb.info,  Node: Beginning and Continuing the 
Tracking Process,  Next: T
 
 Email tracking starts in one of three ways:
 
-  1. With an Org heading that represents an email TODO. Call
+  1. With an Org heading that represents an email TODO.  Call
      ‘gnorb-org-handle-mail’ (see below) on the heading to compose a new
      message, and start the tracking process.
   2. By calling org-capture on a received message.  Capturing from a
@@ -598,10 +600,10 @@ File: gnorb.info,  Node: Misc Org,  Next: Misc Gnus,  
Prev: Misc BBDB,  Up: Top
 * Menu:
 
 * Inserting BBDB links::
-* User Options: User Options 1.
+* User Options: User Options (1).
 
 
-File: gnorb.info,  Node: Inserting BBDB links,  Next: User Options 1,  Up: 
Misc Org
+File: gnorb.info,  Node: Inserting BBDB links,  Next: User Options (1),  Up: 
Misc Org
 
 10.1 Inserting BBDB links
 =========================
@@ -610,7 +612,7 @@ Calling ‘gnorb-org-contact-link’ will prompt for a BBDB 
record and
 insert an Org link to that record at point.
 
 
-File: gnorb.info,  Node: User Options 1,  Prev: Inserting BBDB links,  Up: 
Misc Org
+File: gnorb.info,  Node: User Options (1),  Prev: Inserting BBDB links,  Up: 
Misc Org
 
 10.2 User Options
 =================
@@ -675,10 +677,10 @@ File: gnorb.info,  Node: Misc Gnus,  Next: Default 
Keybindings,  Prev: Misc Org,
 * Menu:
 
 * Searching With the Registry::
-* User Options: User Options 2.
+* User Options: User Options (2).
 
 
-File: gnorb.info,  Node: Searching With the Registry,  Next: User Options 2,  
Up: Misc Gnus
+File: gnorb.info,  Node: Searching With the Registry,  Next: User Options (2), 
 Up: Misc Gnus
 
 11.1 Searching With the Registry
 ================================
@@ -707,7 +709,7 @@ set of groups beforehand.
        (define-key gnus-group-group-map (kbd "?") 
#'gnorb-helm-search-registry))
 
 
-File: gnorb.info,  Node: User Options 2,  Prev: Searching With the Registry,  
Up: Misc Gnus
+File: gnorb.info,  Node: User Options (2),  Prev: Searching With the Registry, 
 Up: Misc Gnus
 
 11.2 User Options
 =================
@@ -820,33 +822,33 @@ If you don’t like these defaults, you can always do your 
own setup.
 
 Tag Table:
 Node: Top194
-Node: Introduction1034
-Node: Installation2359
-Node: Setup2737
-Node: Email Tracking3190
-Node: Likely Workflow4394
-Node: Tracking Setup7164
-Node: Beginning and Continuing the Tracking Process8444
-Node: Trigger Actions12636
-Node: Viewing Things13710
-Node: Hinting in Gnus15826
-Node: Message Attachments16891
-Node: Registry Usage18130
-Node: Restoring Window Layout18557
-Node: Recent Mails From BBDB Contacts18954
-Node: Tagging Messages and Contacts19960
-Node: BBDB posting styles21611
-Node: Misc BBDB22518
-Node: Searching for messages from BBDB contacts22734
-Node: Citing BBDB contacts23180
-Node: User Options23501
-Node: Misc Org25024
-Node: Inserting BBDB links25199
-Node: User Options 125455
-Node: Misc Gnus28353
-Node: Searching With the Registry28547
-Node: User Options 229849
-Node: Default Keybindings33279
+Node: Introduction1038
+Node: Installation2363
+Node: Setup2741
+Node: Email Tracking3194
+Node: Likely Workflow4398
+Node: Tracking Setup7169
+Node: Beginning and Continuing the Tracking Process8596
+Node: Trigger Actions12789
+Node: Viewing Things13863
+Node: Hinting in Gnus15979
+Node: Message Attachments17044
+Node: Registry Usage18283
+Node: Restoring Window Layout18710
+Node: Recent Mails From BBDB Contacts19107
+Node: Tagging Messages and Contacts20113
+Node: BBDB posting styles21764
+Node: Misc BBDB22671
+Node: Searching for messages from BBDB contacts22887
+Node: Citing BBDB contacts23333
+Node: User Options23654
+Node: Misc Org25177
+Node: Inserting BBDB links25354
+Node: User Options (1)25612
+Node: Misc Gnus28512
+Node: Searching With the Registry28708
+Node: User Options (2)30012
+Node: Default Keybindings33444
 
 End Tag Table
 
diff --git a/packages/gnorb/gnorb.org b/packages/gnorb/gnorb.org
index e37036b..2c0a449 100644
--- a/packages/gnorb/gnorb.org
+++ b/packages/gnorb/gnorb.org
@@ -126,7 +126,9 @@ Email tracking requires the following steps:
    should be enough).
 3. Add a nngnorb entry to your `gnus-secondary-select-methods'
    variable. It will look like (nngnorb "Server name"). This does
-   nothing but provide a place to hang nnir searches.
+   nothing but provide a place to hang nnir searches. If you are using
+   the Gnus that comes with Emacs 28 or later (or check ~(featurep
+   'nnselect)~ to be sure), this step is unnecessary.
 4. Then put a call to `gnorb-tracking-initialize' in your init files.
 5. If you're not using a local archive method for saving your sent
    messages (ie you're using IMAP), you'll also need to tell Gnorb
diff --git a/packages/gnorb/gnorb.texi b/packages/gnorb/gnorb.texi
index 7082fc1..2ad74c4 100644
--- a/packages/gnorb/gnorb.texi
+++ b/packages/gnorb/gnorb.texi
@@ -60,12 +60,12 @@ Misc BBDB
 Misc Org
 
 * Inserting BBDB links::
-* User Options: User Options 1.
+* User Options: User Options (1).
 
 Misc Gnus
 
 * Searching With the Registry::
-* User Options: User Options 2.
+* User Options: User Options (2).
 
 @end detailmenu
 @end menu
@@ -168,14 +168,14 @@ Jimmy's email and starts a reply to it.
 You tell Jimmy the room's available in March, and send the message.
 Gnorb takes you back to the heading, and asks you to trigger an action
 on it. You choose ``todo state'', and change the heading keyword to
-WAIT.
+WAIT@.
 
 Two days later, Jimmy replies to your message, saying that March is
 perfect. When you open his response, Gnorb politely reminds you that
-the message is relevant to an existing TODO. You hit ``C-c t'' on the
+the message is relevant to an existing TODO@. You hit ``C-c t'' on the
 message, and are again taken to the TODO and asked to trigger an
 action. Again you choose ``todo state'', and change the heading keyword
-back to REPLY.
+back to REPLY@.
 
 You get another email, from Samantha, warning you not to rent the room
 to Jimmy. She even attaches a picture of a room in her house, as it
@@ -217,7 +217,9 @@ should be enough).
 @item
 Add a nngnorb entry to your `gnus-secondary-select-methods'
 variable. It will look like (nngnorb ``Server name''). This does
-nothing but provide a place to hang nnir searches.
+nothing but provide a place to hang nnir searches. If you are using
+the Gnus that comes with Emacs 28 or later (or check @code{(featurep
+   'nnselect)} to be sure), this step is unnecessary.
 @item
 Then put a call to `gnorb-tracking-initialize' in your init files.
 @item
@@ -238,7 +240,7 @@ Email tracking starts in one of three ways:
 
 @enumerate
 @item
-With an Org heading that represents an email TODO. Call
+With an Org heading that represents an email TODO@. Call
 `gnorb-org-handle-mail' (see below) on the heading to compose a new
 message, and start the tracking process.
 @item
@@ -403,7 +405,7 @@ TODOs, Gnorb can alert you to that fact. When
 `gnorb-gnus-hint-relevant-article' is t (the default), Gnorb will
 display a message in the minibuffer when opening potentially relevant
 messages. You can then use `gnorb-gnus-incoming-to-todo' to trigger an
-action on the relevant TODO.
+action on the relevant TODO@.
 
 This hinting can happen in the Gnus summary buffer as well. If you use
 the escape indicated by `gnorb-gnus-summary-mark-format-letter' as
@@ -586,7 +588,7 @@ the docstring for details).
 
 @menu
 * Inserting BBDB links::
-* User Options: User Options 1.
+* User Options: User Options (1).
 @end menu
 
 @node Inserting BBDB links
@@ -595,7 +597,7 @@ the docstring for details).
 Calling `gnorb-org-contact-link' will prompt for a BBDB record and
 insert an Org link to that record at point.
 
-@node User Options 1
+@node User Options (1)
 @section User Options
 
 @table @asis
@@ -665,7 +667,7 @@ bbdb-pop-up-layout.
 
 @menu
 * Searching With the Registry::
-* User Options: User Options 2.
+* User Options: User Options (2).
 @end menu
 
 @node Searching With the Registry
@@ -699,7 +701,7 @@ These functions are not bound by default; you might 
consider:
   (define-key gnus-group-group-map (kbd "?") #'gnorb-helm-search-registry))
 @end lisp
 
-@node User Options 2
+@node User Options (2)
 @section User Options
 
 @table @asis
diff --git a/packages/gnorb/nngnorb.el b/packages/gnorb/nngnorb.el
index 9375094..fe2b0d6 100644
--- a/packages/gnorb/nngnorb.el
+++ b/packages/gnorb/nngnorb.el
@@ -78,85 +78,88 @@ be scanned for gnus messages, and those messages displayed."
   (if (cdr-safe (assq 'articles query))
       ;; The work has already been done elsewhere.
       (cdr (assq 'articles query))
-    (save-window-excursion
-      (let ((q (cdr (assq 'query query)))
-           (buf (get-buffer-create nnir-tmp-buffer))
-           msg-ids org-ids links vectors)
-       (with-current-buffer buf
-         (erase-buffer)
-         (setq nngnorb-attachment-file-list nil))
-       (when (and (equal "5.13" gnus-version-number) (version< emacs-version 
"24.4"))
-         (setq q (car q)))
-       (cond ((string-match "id\\+\\([[:alnum:]-]+\\)$" q)
-              (with-demoted-errors "Error: %S"
-                (org-id-goto (match-string 1 q))
-                (save-restriction
-                  (org-narrow-to-subtree)
-                  (append-to-buffer
-                   buf
-                   (point-min)
-                   (point-max))
-                  (setq org-ids
-                        (append
-                         (gnorb-collect-ids)
-                         org-ids))
-                  (when org-ids
-                    (with-current-buffer buf
-                      ;; The file list var is buffer local, so set it
-                      ;; (local to the nnir-tmp-buffer) to a full list
-                      ;; of all files in the subtree.
-                      (dolist (id org-ids)
-                        (setq nngnorb-attachment-file-list
-                              (append (gnorb-org-attachment-list id)
-                                      nngnorb-attachment-file-list))))))))
-             ((listp q)
-              ;; be a little careful: this could be a list of links, or
-              ;; it could be the full plist
-              (setq links (if (plist-member q :gnus)
-                              (plist-get q :gnus)
-                            q)))
-             (t (org-map-entries
-                 (lambda ()
-                   (push (org-id-get) org-ids)
-                   (append-to-buffer
-                    buf
-                    (point)
-                    (save-excursion
-                      (outline-next-heading)
-                      (point))))
-                 q
-                 'agenda)))
-       (with-current-buffer buf
-         (goto-char (point-min))
-         (setq links (append
-                      (alist-get 'gnus (gnorb-scan-links (point-max) 'gnus))
-                      links))
-
-         (goto-char (point-min)))
-       ;; First add all links to messages (elements of messages should
-       ;; look like (group-name message-id)).
-       (dolist (l links)
-         (push (org-link-unescape
-                (nth 1 (split-string l "#")))
-               msg-ids))
-
-       (unless (gnus-alive-p)
-         (gnus))
-
-       ;; Then use the registry to turn list of org-ids into list of
-       ;; msg-ids.
-       (dolist (i (delq nil (delete-dups org-ids)))
-         (when-let ((rel-msg-id (gnorb-registry-org-id-search i)))
-           (setq msg-ids (append (delq nil rel-msg-id) msg-ids))))
-
-       ;; Then find the group and article number for each msg-id, and
-       ;; push that onto our return value "vectors".
-       (when msg-ids
-         (dolist (id (delete-dups msg-ids) (when vectors
-                                             (nreverse vectors)))
-           (pcase-let ((`(,group . ,artno) (gnorb-msg-id-request-head id)))
-             (when (and artno (integerp artno) (> artno 0))
-               (push (vector group artno 100) vectors)))))))))
+    (let ((q (cdr (assq 'query query))))
+      (when (and (equal "5.13" gnus-version-number) (version< emacs-version 
"24.4"))
+       (setq q (car q)))
+      (gnorb-run-search q))))
+
+(defun gnorb-run-search (q)
+  (save-window-excursion
+    (let ((buf (get-buffer-create nnir-tmp-buffer))
+         msg-ids org-ids links vectors)
+      (with-current-buffer buf
+       (erase-buffer)
+       (setq nngnorb-attachment-file-list nil))
+      (cond ((string-match "id\\+\\([[:alnum:]-]+\\)$" q)
+            (with-demoted-errors "Error: %S"
+              (org-id-goto (match-string 1 q))
+              (save-restriction
+                (org-narrow-to-subtree)
+                (append-to-buffer
+                 buf
+                 (point-min)
+                 (point-max))
+                (setq org-ids
+                      (append
+                       (gnorb-collect-ids)
+                       org-ids))
+                (when org-ids
+                  (with-current-buffer buf
+                    ;; The file list var is buffer local, so set it
+                    ;; (local to the nnir-tmp-buffer) to a full list
+                    ;; of all files in the subtree.
+                    (dolist (id org-ids)
+                      (setq nngnorb-attachment-file-list
+                            (append (gnorb-org-attachment-list id)
+                                    nngnorb-attachment-file-list))))))))
+           ((listp q)
+            ;; be a little careful: this could be a list of links, or
+            ;; it could be the full plist
+            (setq links (if (plist-member q :gnus)
+                            (plist-get q :gnus)
+                          q)))
+           (t (org-map-entries
+               (lambda ()
+                 (push (org-id-get) org-ids)
+                 (append-to-buffer
+                  buf
+                  (point)
+                  (save-excursion
+                    (outline-next-heading)
+                    (point))))
+               q
+               'agenda)))
+      (with-current-buffer buf
+       (goto-char (point-min))
+       (setq links (append
+                    (alist-get 'gnus (gnorb-scan-links (point-max) 'gnus))
+                    links))
+
+       (goto-char (point-min)))
+      ;; First add all links to messages (elements of messages should
+      ;; look like (group-name message-id)).
+      (dolist (l links)
+       (push (org-link-unescape
+              (nth 1 (split-string l "#")))
+             msg-ids))
+
+      (unless (gnus-alive-p)
+       (gnus))
+
+      ;; Then use the registry to turn list of org-ids into list of
+      ;; msg-ids.
+      (dolist (i (delq nil (delete-dups org-ids)))
+       (when-let ((rel-msg-id (gnorb-registry-org-id-search i)))
+         (setq msg-ids (append (delq nil rel-msg-id) msg-ids))))
+
+      ;; Then find the group and article number for each msg-id, and
+      ;; push that onto our return value "vectors".
+      (when msg-ids
+       (dolist (id (delete-dups msg-ids) (when vectors
+                                           (nreverse vectors)))
+         (pcase-let ((`(,group . ,artno) (gnorb-msg-id-request-head id)))
+           (when (and artno (integerp artno) (> artno 0))
+             (push (vector group artno 100) vectors))))))))
 
 (defvar gnorb-summary-minor-mode-map (make-sparse-keymap)
   "Keymap for use in Gnorb's *Summary* minor mode.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]