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

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

[elpa] externals/gnorb e86d24a 119/449: Robustification of nngnorb nnir


From: Stefan Monnier
Subject: [elpa] externals/gnorb e86d24a 119/449: Robustification of nngnorb nnir message viewing
Date: Fri, 27 Nov 2020 23:15:21 -0500 (EST)

branch: externals/gnorb
commit e86d24a18fb557d407036c67d7bcec4f75c6e8ab
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Robustification of nngnorb nnir message viewing
    
    lisp/gnorb-gnus.el (gnorb-gnus-search-messages): We should only be
                   touching those variables at all under gnus 5.13
    
    lisp/nngnorb.el: (nnir-run-gnorb): Various guards: check for a running
                 gnus, silently pass over malformed links, try
                 activating the link's group and drop it if we can't
                 activate, make sure the article number is a positive
                 integer, and return nil instead of an empty vector if
                 no messages are found.
---
 lisp/gnorb-gnus.el | 25 +++++++++++++------------
 lisp/nngnorb.el    | 26 +++++++++++++++-----------
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index 696f511..e73767a 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -438,11 +438,11 @@ variable `org-id-track-globally' set to t."
 
 (defun gnorb-gnus-search-messages (str &optional ret)
   "Initiate a search for gnus message links in an org subtree.
-  The arg STR can be one of two things: an Org heading id value
-  \(IDs should be prefixed with \"id+\"\), in which case links
-  will be collected from that heading, or a string corresponding
-  to an Org tags search, in which case links will be collected
-  from all matching headings.
+The arg STR can be one of two things: an Org heading id value
+\(IDs should be prefixed with \"id+\"\), in which case links will
+be collected from that heading, or a string corresponding to an
+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\"
@@ -452,15 +452,16 @@ work."
   (let ((nnir-address
         (or (gnus-method-to-server '(nngnorb))
             (user-error
-             "Please add a \"nngnorb\" backend to your gnus installation.")))
-       (nnir-current-query nil)
-       (nnir-current-server nil)
-       (nnir-current-group-marked nil)
-       (nnir-artlist nil))
+             "Please add a \"nngnorb\" backend to your gnus installation."))))
+    (when (version= "5.13" gnus-version-number)
+      (setq nnir-current-query nil
+           nnir-current-server nil
+           nnir-current-group-marked nil
+           nnir-artlist nil))
     (gnus-group-read-ephemeral-group
      ;; in 24.4, the group name is mostly decorative. in 24.3, the
-     ;; actual query itself is embedded there. It should look like
-     ;; (concat "nnir:" (prin1-to-string '((query str))))
+     ;; query itself is read from there. It should look like (concat
+     ;; "nnir:" (prin1-to-string '((query str))))
      (if (version= "5.13" gnus-version-number)
         (concat "nnir:" (prin1-to-string `((query ,str))))
        (concat "gnorb-" str))
diff --git a/lisp/nngnorb.el b/lisp/nngnorb.el
index 9505877..581d95f 100644
--- a/lisp/nngnorb.el
+++ b/lisp/nngnorb.el
@@ -113,19 +113,23 @@ be scanned for gnus messages, and those messages 
displayed."
          (goto-char (point-min))
          (setq links (gnorb-scan-links (point-max) 'gnus))))
       (setq links (delete-dups (plist-get links :gnus)))
-      (dolist (m links (nreverse vectors))
+      (unless (gnus-alive-p)
+       (gnus))
+      (dolist (m links (when vectors
+                        (nreverse vectors)))
        (let (server-group msg-id artno)
          (setq m (org-link-unescape m))
-         (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" m))
-             (error "Error in Gnus link"))
-         (setq server-group (match-string 1 m)
-               msg-id (match-string 3 m))
-         ;; I swear just finding the `gnus-request-head' function
-         ;; was a trial in itself. But I've only tried it with
-         ;; nnimap -- does it work for other backends?
-         (setq artno (cdr (gnus-request-head msg-id server-group)))
-         (when (> artno 0)
-           (push (vector server-group artno 100) vectors)))))))
+         (when (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" m)
+           (setq server-group (match-string 1 m)
+                 msg-id (match-string 3 m))
+           ;; I swear just finding the `gnus-request-head' function
+           ;; was a trial in itself. But I've only tried it with
+           ;; nnimap -- does it work for other backends?
+           (when (gnus-activate-group server-group)
+            (setq artno
+                  (cdr (gnus-request-head msg-id server-group)))
+            (when (and (integerp artno) (> artno 0))
+              (push (vector server-group artno 100) vectors)))))))))
 
 (defvar nngnorb-status-string "")
 



reply via email to

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