Gnus development mailing list
 help / color / mirror / Atom feed
* Server variables in ~/News/agent/lib/servers
@ 2002-06-06 10:49 Bjørn Mork
  2002-06-11 19:56 ` Simon Josefsson
  0 siblings, 1 reply; 13+ messages in thread
From: Bjørn Mork @ 2002-06-06 10:49 UTC (permalink / raw)


Short question: Why?

Having them there means that agent forgets the server every time you
change its select-method by adding, removing or changing a variable.
I can't really see any reason why that's necessary, but maybe I'm
missing something? Why not use a reference to the select-method like
its done in ~/newsrc.eld?


Bjørn
-- 
How can you say that "Head-for-the-mountains" Bush was bad?  



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-06 10:49 Server variables in ~/News/agent/lib/servers Bjørn Mork
@ 2002-06-11 19:56 ` Simon Josefsson
  2002-06-14 16:43   ` Bjørn Mork
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Josefsson @ 2002-06-11 19:56 UTC (permalink / raw)
  Cc: ding

Bjørn Mork <bmork@dod.no> writes:

> Having them there means that agent forgets the server every time you
> change its select-method by adding, removing or changing a variable.
> I can't really see any reason why that's necessary, but maybe I'm
> missing something? Why not use a reference to the select-method like
> its done in ~/newsrc.eld?

I think this should be done too.  Does anyone have a specific idea
(read: patch) on how to do it? :-)




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-11 19:56 ` Simon Josefsson
@ 2002-06-14 16:43   ` Bjørn Mork
  2002-06-15 17:34     ` Kai Großjohann
  0 siblings, 1 reply; 13+ messages in thread
From: Bjørn Mork @ 2002-06-14 16:43 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

Simon Josefsson <jas@extundo.com> writes:
> Bjørn Mork <bmork@dod.no> writes:
>
>> Having them there means that agent forgets the server every time you
>> change its select-method by adding, removing or changing a variable.
>> I can't really see any reason why that's necessary, but maybe I'm
>> missing something? Why not use a reference to the select-method like
>> its done in ~/newsrc.eld?
>
> I think this should be done too.  Does anyone have a specific idea
> (read: patch) on how to do it? :-)

The attached patch seems to fix it, but should be reviewed by someone
with a little lisp knowledge. I am pretty clueless in this area (too)
and have most likely done some very basic errors here.

Note that I've only changed the file format. It would probably have
been better to change the content of gnus-agent-covered-methods
instead of changing gnus-agent-{read,write}-servers, but that would
require more changes than I feel comfortable doing...

Although the file format changes, I still believe this change is
backwards compatible since Gnus always has been able to read the new
format. 


Bjørn
-- 
So, trees are crass?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: agent-servers.diff --]
[-- Type: text/x-patch, Size: 1445 bytes --]

Index: lisp/gnus-agent.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-agent.el,v
retrieving revision 6.72
diff -u -r6.72 gnus-agent.el
--- lisp/gnus-agent.el	2002/05/29 13:25:56	6.72
+++ lisp/gnus-agent.el	2002/06/14 16:56:15
@@ -627,17 +627,23 @@
 
 (defun gnus-agent-read-servers ()
   "Read the alist of covered servers."
-  (setq gnus-agent-covered-methods
-	(gnus-agent-read-file
-	 (nnheader-concat gnus-agent-directory "lib/servers"))))
+  (dolist (method (gnus-agent-read-file 
+		   (nnheader-concat gnus-agent-directory "lib/servers"))
+		  gnus-agent-covered-methods)
+    (unless method (setq method "native"))
+    (add-to-list 'gnus-agent-covered-methods 
+		 (gnus-server-get-method nil method))))
 
 (defun gnus-agent-write-servers ()
   "Write the alist of covered servers."
   (gnus-make-directory (nnheader-concat gnus-agent-directory "lib"))
   (let ((coding-system-for-write nnheader-file-coding-system)
-	(file-name-coding-system nnmail-pathname-coding-system))
+	(file-name-coding-system nnmail-pathname-coding-system)
+	(methods))
     (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
-      (prin1 gnus-agent-covered-methods (current-buffer)))))
+      (prin1 (dolist (method gnus-agent-covered-methods methods)
+	       (add-to-list 'methods (gnus-method-simplify method)))
+	     (current-buffer)))))
 
 ;;;
 ;;; Summary commands

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-14 16:43   ` Bjørn Mork
@ 2002-06-15 17:34     ` Kai Großjohann
  2002-06-16 19:43       ` Bjørn Mork
  2002-06-24 11:50       ` Steinar Bang
  0 siblings, 2 replies; 13+ messages in thread
From: Kai Großjohann @ 2002-06-15 17:34 UTC (permalink / raw)
  Cc: ding

Bjørn Mork <bmork@dod.no> writes:

> Index: lisp/gnus-agent.el
> ===================================================================
> RCS file: /usr/local/cvsroot/gnus/lisp/gnus-agent.el,v
> retrieving revision 6.72
> diff -u -r6.72 gnus-agent.el
> --- lisp/gnus-agent.el	2002/05/29 13:25:56	6.72
> +++ lisp/gnus-agent.el	2002/06/14 16:56:15
> @@ -627,17 +627,23 @@
>  
>  (defun gnus-agent-read-servers ()
>    "Read the alist of covered servers."
> -  (setq gnus-agent-covered-methods
> -	(gnus-agent-read-file
> -	 (nnheader-concat gnus-agent-directory "lib/servers"))))
> +  (dolist (method (gnus-agent-read-file 
> +		   (nnheader-concat gnus-agent-directory "lib/servers"))
> +		  gnus-agent-covered-methods)
> +    (unless method (setq method "native"))
> +    (add-to-list 'gnus-agent-covered-methods 
> +		 (gnus-server-get-method nil method))))

I don't grok dolist (never used it), so I'm not 100% sure of what's
happening.  One thing I notice is that the old code always sets the
variable to a one-element list.  With the new code, the list could
grow more and more if gnus-agent-read-servers is called multiple
times.

I would write something like the following:

(setq gnus-agent-covered-methods
      (mapcar (lambda (m)
                (gnus-server-get-method
                 nil
                 (or m "native")))
              (gnus-agent-read-file
               (nnheader-concat gnus-agent-directory "lib/servers"))))

But maybe it does something else entirely.  Or it is incomprehensible.

>  (defun gnus-agent-write-servers ()
>    "Write the alist of covered servers."
>    (gnus-make-directory (nnheader-concat gnus-agent-directory "lib"))
>    (let ((coding-system-for-write nnheader-file-coding-system)
> -	(file-name-coding-system nnmail-pathname-coding-system))
> +	(file-name-coding-system nnmail-pathname-coding-system)
> +	(methods))
>      (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
> -      (prin1 gnus-agent-covered-methods (current-buffer)))))
> +      (prin1 (dolist (method gnus-agent-covered-methods methods)
> +	       (add-to-list 'methods (gnus-method-simplify method)))
> +	     (current-buffer)))))

Again, here I would use mapcar:

(prin1 (mapcar 'gnus-method-simplify gnus-agent-covered-methods)
       (current-buffer))

If this is what's happening, mapcar seems to be the winner :-)

>  ;;;
>  ;;; Summary commands

kai "a mapcar a day keeps the doctor away"
-- 
~/.signature is: umop 3p!sdn    (Frank Nobis)



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-15 17:34     ` Kai Großjohann
@ 2002-06-16 19:43       ` Bjørn Mork
  2002-06-16 19:48         ` Bjørn Mork
  2002-06-24 11:50       ` Steinar Bang
  1 sibling, 1 reply; 13+ messages in thread
From: Bjørn Mork @ 2002-06-16 19:43 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> I don't grok dolist (never used it),

Nor had I before. It was just something I found near the lines I
changed :-) 

> so I'm not 100% sure of what's
> happening.  One thing I notice is that the old code always sets the
> variable to a one-element list.  With the new code, the list could
> grow more and more if gnus-agent-read-servers is called multiple
> times.

No it wouldn't. add-to-list will take care of that. But my approach
was of course very inefficient and inelegant.

> If this is what's happening, mapcar seems to be the winner :-)

Yup, beautiful. This is what I wanted to do. I just didn't know
how. Thanks. I've attached a new version of the patch using your
code. 



Bjørn
-- 
Your bad grammar reminds me of a Jewish grandmother.  


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: agent-servers.diff --]
[-- Type: text/x-patch, Size: 1165 bytes --]

Index: lisp/gnus-agent.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-agent.el,v
retrieving revision 6.72
diff -u -r6.72 gnus-agent.el
--- lisp/gnus-agent.el	2002/05/29 13:25:56	6.72
+++ lisp/gnus-agent.el	2002/06/16 19:59:24
@@ -628,8 +628,12 @@
 (defun gnus-agent-read-servers ()
   "Read the alist of covered servers."
   (setq gnus-agent-covered-methods
-	(gnus-agent-read-file
-	 (nnheader-concat gnus-agent-directory "lib/servers"))))
+	(mapcar (lambda (m)
+		  (gnus-server-get-method
+		   nil
+		   (or m "native")))
+		(gnus-agent-read-file
+		 (nnheader-concat gnus-agent-directory "lib/servers"))))
 
 (defun gnus-agent-write-servers ()
   "Write the alist of covered servers."
@@ -637,7 +641,8 @@
   (let ((coding-system-for-write nnheader-file-coding-system)
 	(file-name-coding-system nnmail-pathname-coding-system))
     (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
-      (prin1 gnus-agent-covered-methods (current-buffer)))))
+      (prin1 (mapcar 'gnus-method-simplify gnus-agent-covered-methods)
+	     (current-buffer)))))
 
 ;;;
 ;;; Summary commands

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-16 19:43       ` Bjørn Mork
@ 2002-06-16 19:48         ` Bjørn Mork
  2002-06-16 20:47           ` Kai Großjohann
  0 siblings, 1 reply; 13+ messages in thread
From: Bjørn Mork @ 2002-06-16 19:48 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 213 bytes --]

Bjørn Mork <bmork@dod.no> writes:

> I've attached a new version of the patch using your code.

Which could have been better tested. Sorry. This one should be
correct.


Bjørn
-- 
Stupid underpriviledged fool!  


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: agent-servers.diff --]
[-- Type: text/x-patch, Size: 1166 bytes --]

Index: lisp/gnus-agent.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-agent.el,v
retrieving revision 6.72
diff -u -r6.72 gnus-agent.el
--- lisp/gnus-agent.el	2002/05/29 13:25:56	6.72
+++ lisp/gnus-agent.el	2002/06/16 20:11:51
@@ -628,8 +628,12 @@
 (defun gnus-agent-read-servers ()
   "Read the alist of covered servers."
   (setq gnus-agent-covered-methods
-	(gnus-agent-read-file
-	 (nnheader-concat gnus-agent-directory "lib/servers"))))
+	(mapcar (lambda (m)
+		  (gnus-server-get-method
+		   nil
+		   (or m "native")))
+		(gnus-agent-read-file
+		 (nnheader-concat gnus-agent-directory "lib/servers")))))
 
 (defun gnus-agent-write-servers ()
   "Write the alist of covered servers."
@@ -637,7 +641,8 @@
   (let ((coding-system-for-write nnheader-file-coding-system)
 	(file-name-coding-system nnmail-pathname-coding-system))
     (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
-      (prin1 gnus-agent-covered-methods (current-buffer)))))
+      (prin1 (mapcar 'gnus-method-simplify gnus-agent-covered-methods)
+	     (current-buffer)))))
 
 ;;;
 ;;; Summary commands

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-16 19:48         ` Bjørn Mork
@ 2002-06-16 20:47           ` Kai Großjohann
  2002-06-16 20:56             ` Simon Josefsson
  0 siblings, 1 reply; 13+ messages in thread
From: Kai Großjohann @ 2002-06-16 20:47 UTC (permalink / raw)
  Cc: ding

Bjørn Mork <bmork@dod.no> writes:

> Which could have been better tested. Sorry. This one should be
> correct.

Committed.

kai
-- 
People mountain, people sea, today no see, tomorrow see.  (from Chinese)



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-16 20:47           ` Kai Großjohann
@ 2002-06-16 20:56             ` Simon Josefsson
  2002-06-16 21:14               ` Bjørn Mork
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Josefsson @ 2002-06-16 20:56 UTC (permalink / raw)
  Cc: ding

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> Bjørn Mork <bmork@dod.no> writes:
>
>> Which could have been better tested. Sorry. This one should be
>> correct.
>
> Committed.

How about auto-agentizing non-primary remote servers as well?

Perhaps we should wait longer to see if agentizing causes problems
though, I think we have one bug that may be caused by it now (the
daemon not working correctly).  I have always agentized all remote
servers for a long time, and haven't seen anything weird.

Hm, my servers file looks like:

("nntp:quimby.gnus.org" "nntp:news.uslinuxtraining.com" "nnimap:yxa" nil)

where did the nil come from?  Maybe the code should fall back to using
fully qualified servers if it cannot be "collapsed" into a smaller
one.  I think the nil entry was a server that no longer exists, or a
server that still exists but used different parameters, or something
like that.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-16 20:56             ` Simon Josefsson
@ 2002-06-16 21:14               ` Bjørn Mork
  2002-06-17  7:27                 ` Simon Josefsson
  0 siblings, 1 reply; 13+ messages in thread
From: Bjørn Mork @ 2002-06-16 21:14 UTC (permalink / raw)


Simon Josefsson <jas@extundo.com> writes:

> Hm, my servers file looks like:
>
> ("nntp:quimby.gnus.org" "nntp:news.uslinuxtraining.com" "nnimap:yxa" nil)
>
> where did the nil come from?

It's your primary select method. It's collapsed to nil by 
gnus-method-simplify. Try removing it from agent and you'll see that
the nil disappears. 

I don't know why gnus-method-simplify does this. It caused a small
problem since gnus-server-get-method doesn't expand the nil. That's
the reason for the (or m "native") hack.

>  Maybe the code should fall back to using
> fully qualified servers if it cannot be "collapsed" into a smaller
> one.  I think the nil entry was a server that no longer exists, or a
> server that still exists but used different parameters, or something
> like that.

gnus-method-simplify will do this already. You'll get a complete entry
like before if you agentize a foreign server.


Bjørn
-- 
I can't believe how unpleasant you are.  



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-16 21:14               ` Bjørn Mork
@ 2002-06-17  7:27                 ` Simon Josefsson
  2002-06-17  9:09                   ` Bjørn Mork
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Josefsson @ 2002-06-17  7:27 UTC (permalink / raw)
  Cc: ding

Bjørn Mork <bmork@dod.no> writes:

> Simon Josefsson <jas@extundo.com> writes:
>
>> Hm, my servers file looks like:
>>
>> ("nntp:quimby.gnus.org" "nntp:news.uslinuxtraining.com" "nnimap:yxa" nil)
>>
>> where did the nil come from?
>
> It's your primary select method. It's collapsed to nil by 
> gnus-method-simplify. Try removing it from agent and you'll see that
> the nil disappears. 

Aha.  Hm.  If I make my primary server a secondary server, this
breaks, does it not?  Moving servers around between primary,
secondary, archive etc works OK, I believe, so how about expanding
even the primary server as a string?  Then the "m" native hack
wouldn't be needed, I think.  Would this do something else bad?




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-17  7:27                 ` Simon Josefsson
@ 2002-06-17  9:09                   ` Bjørn Mork
  2002-06-17  9:55                     ` Simon Josefsson
  0 siblings, 1 reply; 13+ messages in thread
From: Bjørn Mork @ 2002-06-17  9:09 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

Simon Josefsson <jas@extundo.com> writes:
> Bjørn Mork <bmork@dod.no> writes:
>
>> It's your primary select method. It's collapsed to nil by 
>> gnus-method-simplify. Try removing it from agent and you'll see that
>> the nil disappears. 
>
> Aha.  Hm.  If I make my primary server a secondary server, this
> breaks, does it not? 

Yes. Didn't know that was a common operation. I still have some
problems being open-minded enough regarding what people want to do
with Gnus :-)

Doesn't this also break other things, like group subscribtions?

> Moving servers around between primary,
> secondary, archive etc works OK, I believe, so how about expanding
> even the primary server as a string?  Then the "m" native hack
> wouldn't be needed, I think.  Would this do something else bad?

Can't imagine so. I've attached an attempt, but it got slightly
ugly...


Bjørn
-- 
Save the diseases!  


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: agent-servers.diff --]
[-- Type: text/x-patch, Size: 1236 bytes --]

Index: lisp/gnus-agent.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-agent.el,v
retrieving revision 6.73
diff -u -r6.73 gnus-agent.el
--- lisp/gnus-agent.el	2002/06/16 21:13:49	6.73
+++ lisp/gnus-agent.el	2002/06/17 09:28:32
@@ -628,10 +628,7 @@
 (defun gnus-agent-read-servers ()
   "Read the alist of covered servers."
   (setq gnus-agent-covered-methods
-	(mapcar (lambda (m)
-		  (gnus-server-get-method
-		   nil
-		   (or m "native")))
+	(mapcar 'gnus-server-get-method
 		(gnus-agent-read-file
 		 (nnheader-concat gnus-agent-directory "lib/servers")))))
 
@@ -641,7 +638,16 @@
   (let ((coding-system-for-write nnheader-file-coding-system)
 	(file-name-coding-system nnmail-pathname-coding-system))
     (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
-      (prin1 (mapcar 'gnus-method-simplify gnus-agent-covered-methods)
+      (prin1 (mapcar (lambda (m)
+		       (cond ((stringp m)
+			      m)
+			     ((or 
+			       (gnus-native-method-p m) 
+			       (gnus-secondary-method-p m))
+			      (format "%s:%s" (nth 0 m) (nth 1 m)))
+			     (t
+			      m)))
+		     gnus-agent-covered-methods)
 	     (current-buffer)))))
 
 ;;;

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-17  9:09                   ` Bjørn Mork
@ 2002-06-17  9:55                     ` Simon Josefsson
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Josefsson @ 2002-06-17  9:55 UTC (permalink / raw)
  Cc: ding

Bjørn Mork <bmork@dod.no> writes:

>>> It's your primary select method. It's collapsed to nil by 
>>> gnus-method-simplify. Try removing it from agent and you'll see that
>>> the nil disappears. 
>>
>> Aha.  Hm.  If I make my primary server a secondary server, this
>> breaks, does it not? 
>
> Yes. Didn't know that was a common operation. I still have some
> problems being open-minded enough regarding what people want to do
> with Gnus :-)
>
> Doesn't this also break other things, like group subscribtions?

Hm, yes, never mind, not a good idea.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Server variables in ~/News/agent/lib/servers
  2002-06-15 17:34     ` Kai Großjohann
  2002-06-16 19:43       ` Bjørn Mork
@ 2002-06-24 11:50       ` Steinar Bang
  1 sibling, 0 replies; 13+ messages in thread
From: Steinar Bang @ 2002-06-24 11:50 UTC (permalink / raw)


>>>>> Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann):

> kai "a mapcar a day keeps the doctor away"

Shouldn't that be "a mapcar a day keeps `M-x doctor RET' away"?



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-06-24 11:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-06 10:49 Server variables in ~/News/agent/lib/servers Bjørn Mork
2002-06-11 19:56 ` Simon Josefsson
2002-06-14 16:43   ` Bjørn Mork
2002-06-15 17:34     ` Kai Großjohann
2002-06-16 19:43       ` Bjørn Mork
2002-06-16 19:48         ` Bjørn Mork
2002-06-16 20:47           ` Kai Großjohann
2002-06-16 20:56             ` Simon Josefsson
2002-06-16 21:14               ` Bjørn Mork
2002-06-17  7:27                 ` Simon Josefsson
2002-06-17  9:09                   ` Bjørn Mork
2002-06-17  9:55                     ` Simon Josefsson
2002-06-24 11:50       ` Steinar Bang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).