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

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

[elpa] master 7d3f43c 1/5: Factor out function for finding nngnorb serve


From: Eric Abrahamsen
Subject: [elpa] master 7d3f43c 1/5: Factor out function for finding nngnorb server
Date: Thu, 3 May 2018 15:37:59 -0400 (EDT)

branch: master
commit 7d3f43cbe76663db52e7b6d9b19d1c497b43349c
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    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.
---
 packages/gnorb/gnorb-gnus.el | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/packages/gnorb/gnorb-gnus.el b/packages/gnorb/gnorb-gnus.el
index 77e21ce..9029163 100644
--- a/packages/gnorb/gnorb-gnus.el
+++ b/packages/gnorb/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]