Subject: Re: bug#19583: nntp-open-server: wrong buffer for nnoo-change-server; breaks url-news

From: Ivan Shmakov <[email-masked]>
Date: Sun, 15 Feb 2015 05:42:37 +0000

>>>>> Lars Ingebrigtsen <[email-masked]> writes:
>>>>> Ivan Shmakov <[email-masked]> writes:
>>>>> Lars Ingebrigtsen <[email-masked]> writes:

 >>> No certificates are rejected; they're normally all prompted for by
 >>> the network security manager.  So the question is why that isn't
 >>> happening here, if indeed that's the problem.

 >> It seems so; cf.:

 >> (with-temp-buffer (kill-buffer " *nntpd*")
 >>   (setq nntp-open-connection-function 'nntp-open-network-stream)
 >>   (nntp-open-server "news.gmane.org" '((nntp-port-number 119))))
 >> nil

 > Works for me in emacs -Q:

 > (with-temp-buffer
 >   (require 'nntp)
 >   (nntp-open-server "news.gmane.org"))

	Yet still url-retrieve fails for news: URIs referencing this
	same server?

	Also, AIUI, $ emacs -Q doesn’t prevent the use of
	nsm-settings-file.  Could you please try the above with that
	variable pointing to some non-existent file?

	BTW, I don’t seem to understand which nntp- functions do expect
	to be called from the server buffer.  For one thing,
	nntp-open-connection uses the nntp- variables intended (unless I
	be mistaken) to be local to the server buffer, yet I fail to see
	where the buffer gets switched.

	Perhaps this revised patch MIMEd makes more sense.

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
--- a/lisp/gnus/nntp.el
+++ b/lisp/gnus/nntp.el
@@ -1066,11 +1066,12 @@ deffoo nntp-open-server (server &optional defs connectionless)
       (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs))))
     (unless (assq 'nntp-address defs)
       (setq defs (append defs (list (list 'nntp-address server)))))
-    (nnoo-change-server 'nntp server defs)
-    (if connectionless
-	t
-      (or (nntp-find-connection nntp-server-buffer)
-	  (nntp-open-connection nntp-server-buffer)))))
+    (with-current-buffer nntp-server-buffer
+      (nnoo-change-server 'nntp server defs)
+      (if connectionless
+	  t
+	(or (nntp-find-connection nntp-server-buffer)
+	    (nntp-open-connection nntp-server-buffer))))))
 
 (deffoo nntp-close-server (&optional server)
   (nntp-possibly-change-group nil server t)