GNU bug report logs - #9691
When `gnus-registry-install' is 'ask, nnregistry is broken

Previous Next

Package: gnus;

Reported by: Dave Abrahams <dave <at> boostpro.com>

Date: Fri, 7 Oct 2011 12:08:02 UTC

Severity: normal

Tags: fixed

Found in version 5.110018

Fixed in version 24.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 9691 <at> debbugs.gnu.org (full text, mbox):

From: Dave Abrahams <dave <at> boostpro.com>
To: 9691 <at> debbugs.gnu.org
Cc: Ted Zlatanov <tzz <at> lifelogs.com>
Subject: Patch Enclosed (When `gnus-registry-install' is 'ask,
	nnregistry is broken)
Date: Sat, 08 Oct 2011 22:55:56 -0400
[Message part 1 (text/plain, inline)]
Here is my proposed fix for this problem:

[0001-Rationalize-the-use-of-gnus-registry-install.patch (text/x-patch, inline)]
From dc140ae8315ef7ab9ca07123d94cd40c507c6763 Mon Sep 17 00:00:00 2001
From: Dave Abrahams <dave <at> boostpro.com>
Date: Sat, 8 Oct 2011 22:50:18 -0400
Subject: [PATCH] Rationalize the use of `gnus-registry-install'

- don't programmatically change `gnus-registry-install' (at least not
  permanently), because it's a user option.

- use a new variable, `gnus-registry-enabled', to indicate whether the
  registry is active.

- replace checks of `gnus-registry-install' with checks of
  `gnus-registry-enabled'

This also fixes the bug that with the default setting of
`gnus-registry-install' (`ask'), the nnregistry server is stuck at
`denied'.
---
 lisp/gnus-registry.el |   33 +++++++++++++++++++--------------
 lisp/nnir.el          |    6 ++----
 lisp/nnmairix.el      |    4 +---
 lisp/nnregistry.el    |    7 +++++--
 4 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/lisp/gnus-registry.el b/lisp/gnus-registry.el
index f8ff52f..652e816 100644
--- a/lisp/gnus-registry.el
+++ b/lisp/gnus-registry.el
@@ -164,6 +164,8 @@ nnmairix groups are specifically excluded because they are ephemeral."
                  (const :tag "Always Install" t)
                  (const :tag "Ask Me" ask)))
 
+(defvar gnus-registry-enabled)
+
 (defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning.
 
 (defvar gnus-registry-misc-menus nil)   ; ugly way to keep the menus
@@ -873,8 +875,9 @@ Uses `gnus-registry-marks' to find what shortcuts to install."
 
                  ;; if this is called and the user doesn't want the
                  ;; registry enabled, we'll ask anyhow
-                 (when (eq gnus-registry-install nil)
-                   (setq gnus-registry-install 'ask))
+                 (unless gnus-registry-install
+                   (let ((gnus-registry-install 'ask))
+                     (gnus-registry-install-p)))
 
                  ;; now the user is asked if gnus-registry-install is 'ask
                  (when (gnus-registry-install-p)
@@ -1151,7 +1154,6 @@ only the last one's marks are returned."
 "Initialize the Gnus registry."
   (interactive)
   (gnus-message 5 "Initializing the registry")
-  (setq gnus-registry-install t)        ; in case it was 'ask or nil
   (gnus-registry-install-hooks)
   (gnus-registry-install-shortcuts)
   (gnus-registry-read))
@@ -1160,6 +1162,7 @@ only the last one's marks are returned."
 (defun gnus-registry-install-hooks ()
   "Install the registry hooks."
   (interactive)
+  (setq gnus-registry-enabled t)
   (add-hook 'gnus-summary-article-move-hook 'gnus-registry-action)
   (add-hook 'gnus-summary-article-delete-hook 'gnus-registry-action)
   (add-hook 'gnus-summary-article-expire-hook 'gnus-registry-action)
@@ -1181,23 +1184,25 @@ only the last one's marks are returned."
   (remove-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
   (remove-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
 
-  (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
+  (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids)
+  (setq gnus-registry-enabled nil))
 
 (add-hook 'gnus-registry-unload-hook 'gnus-registry-unload-hook)
 
 (defun gnus-registry-install-p ()
+  "If the registry is not already enabled, and `gnus-registry-install' is t,
+the registry is enabled.  If `gnus-registry-install' is `ask',
+the user is asked first.  Returns non-nil iff the registry is enabled."
   (interactive)
-  (when (eq gnus-registry-install 'ask)
-    (setq gnus-registry-install
-          (gnus-y-or-n-p
-           (concat "Enable the Gnus registry?  "
-                   "See the variable `gnus-registry-install' "
-                   "to get rid of this query permanently. ")))
-    (when gnus-registry-install
-      ;; we just set gnus-registry-install to t, so initialize the registry!
+  (unless gnus-registry-enabled
+    (when (if (eq gnus-registry-install 'ask)
+              (gnus-y-or-n-p
+               (concat "Enable the Gnus registry?  "
+                       "See the variable `gnus-registry-install' "
+                       "to get rid of this query permanently. "))
+            gnus-registry-install)
       (gnus-registry-initialize)))
-;;; we could call it here: (customize-variable 'gnus-registry-install)
-  gnus-registry-install)
+  gnus-registry-enabled)
 
 ;; TODO: a few things
 
diff --git a/lisp/nnir.el b/lisp/nnir.el
index 0be6a17..cbd3f74 100644
--- a/lisp/nnir.el
+++ b/lisp/nnir.el
@@ -290,8 +290,7 @@ is `(valuefunc member)'."
   (autoload 'nnimap-command "nnimap")
   (autoload 'nnimap-possibly-change-group "nnimap")
   (autoload 'nnimap-make-thread-query "nnimap")
-  (autoload 'gnus-registry-action "gnus-registry")
-  (defvar gnus-registry-install))
+  (autoload 'gnus-registry-action "gnus-registry"))
 
 
 (nnoo-declare nnir)
@@ -1741,8 +1740,7 @@ environment unless `not-global' is non-nil."
   (when (eq (car (gnus-find-method-for-group gnus-newsgroup-name)) 'nnir)
     (setq gnus-summary-line-format
 	  (or nnir-summary-line-format gnus-summary-line-format))
-    (when (and (boundp 'gnus-registry-install)
-		       (eq gnus-registry-install t))
+    (when (bound-and-true-p gnus-registry-enabled)
       (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action t)
       (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action t)
       (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action t)
diff --git a/lisp/nnmairix.el b/lisp/nnmairix.el
index 3d1ac02..f81aa03 100644
--- a/lisp/nnmairix.el
+++ b/lisp/nnmairix.el
@@ -603,7 +603,6 @@ Other back ends might or might not work.")
     nil))
 
 ;; Silence byte-compiler.
-(defvar gnus-registry-install)
 (autoload 'gnus-registry-get-id-key "gnus-registry")
 
 (deffoo nnmairix-request-set-mark (group actions &optional server)
@@ -1636,8 +1635,7 @@ search in raw mode."
 
 (defun nnmairix-determine-original-group-from-registry (mid)
   "Try to determinale original group for message-id MID from the registry."
-  (when (and (boundp 'gnus-registry-install)
-	     gnus-registry-install)
+  (when (bound-and-true-p gnus-registry-enabled)
     (unless (string-match "^<" mid)
       (set mid (concat "<" mid)))
     (unless (string-match ">$" mid)
diff --git a/lisp/nnregistry.el b/lisp/nnregistry.el
index 359050c..75a640a 100644
--- a/lisp/nnregistry.el
+++ b/lisp/nnregistry.el
@@ -36,8 +36,11 @@
 
 (nnoo-declare nnregistry)
 
+;; Suppress byte-compiler warning `reference to free variable'
+(defvar gnus-registry-enabled)
+
 (deffoo nnregistry-server-opened (server)
-  (eq gnus-registry-install t))
+  gnus-registry-enabled)
 
 (deffoo nnregistry-close-server (server)
   t)
@@ -46,7 +49,7 @@
   nil)
 
 (deffoo nnregistry-open-server (server &optional defs)
-  (eq gnus-registry-install t))
+  gnus-registry-enabled)
 
 (defvar nnregistry-within-nnregistry nil)
 
-- 
1.7.3.4

[Message part 3 (text/plain, inline)]
-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com


This bug report was last modified 13 years and 141 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.