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

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

[elpa] externals/gnorb 30a6171 404/449: Factor out function for finding


From: Stefan Monnier
Subject: [elpa] externals/gnorb 30a6171 404/449: Factor out function for finding nngnorb server
Date: Fri, 27 Nov 2020 23:16:21 -0500 (EST)

branch: externals/gnorb
commit 30a61718f1283a9a74fc01b4d5bcfb5706a47d3f
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Factor out function for finding nngnorb server
    
    * packages/gnorb/gnorb-gnus.el (gnorb-gnus-find-gnorb-server): New
      function, so this can be called from elsewhere.
      (gnorb-gnus-search-messages): Use this new function.
---
 gnorb-gnus.el | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/gnorb-gnus.el b/gnorb-gnus.el
index 77e21ce..9029163 100644
--- a/gnorb-gnus.el
+++ b/gnorb-gnus.el
@@ -807,20 +807,7 @@ HEAD-TEXT, if present, as its name.  Otherwise create an
 ephemeral one, with RET as the value of its quit-config."
   (interactive)
   (require 'nnir)
-  (let* ((nnir-address
-         (or (catch 'found
-               ;; Try very hard to find the server.
-               (when (assoc 'nngnorb gnus-secondary-select-methods)
-                 (throw 'found
-                        (format
-                         "nngnorb:%s"
-                         (nth 1 (assoc 'nngnorb
-                                       gnus-secondary-select-methods)))))
-               (dolist (s (append gnus-server-alist gnus-server-method-cache))
-                 (when (eq 'nngnorb (cadr s))
-                   (throw 'found (car s)))))
-             (user-error
-              "Please add a \"nngnorb\" backend to your gnus installation.")))
+  (let* ((nnir-address (gnorb-gnus-find-gnorb-server))
         (name (if persist
                   (read-string
                    (format "Name for group (default %s): " head-text)
@@ -840,6 +827,25 @@ ephemeral one, with RET as the value of its quit-config."
          (gnus-group-select-group))
       (gnus-group-read-ephemeral-group name method nil ret nil nil spec))))
 
+(defun gnorb-gnus-find-gnorb-server (&optional no-error)
+  "Try very hard to find a local nngnorb server.
+If NO-ERROR is non-nil, return nil on failure, otherwise an
+error."
+  (or (catch 'found
+       ;; Try very hard to find the server.
+       (when (assoc 'nngnorb gnus-secondary-select-methods)
+         (throw 'found
+                (format
+                 "nngnorb:%s"
+                 (nth 1 (assoc 'nngnorb
+                               gnus-secondary-select-methods)))))
+       (dolist (s (append gnus-server-alist gnus-server-method-cache))
+         (when (eq 'nngnorb (cadr s))
+           (throw 'found (car s)))))
+      (unless no-error
+       (user-error
+        "Please add a \"nngnorb\" backend to your gnus installation."))))
+
 (defun gnorb-gnus-summary-mode-hook ()
   "Check if we've entered a Gnorb-generated group, and activate
   `gnorb-summary-minor-mode', if so."



reply via email to

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