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

[PATCH] Multiple Servers / APPENDUID,UIDNEXT




1998-08-11  Jim Radford  <radford@robby.caltech.edu>

	* imap4rev1.el (imap-debug): disable undo on debug-buffers.
	
	* imap4rev1.el (imap-parse-line): Accept with APPENDUID and UIDNEXT.

	* nnimap.el (nnimap-possibly-change-group): Typo, wrong
	variable name.

	* nnimap.el (nnimap-debug): disable undo on debug-buffers.

	* nnimap.el (nnimap-request-group): Return max==0
	min==1 when there is zero articles.

	* nnimap.el (nnimap-send-command-wait): We need to quote "%"s for
 	`format' within gnus-message, but I don't know how without 10
 	lines of code.  If someone knows a simple way to replace "%" with
 	"%%" in a string let me know.

	* nnimap.el (nnimap-open-server): Only use gnus-parse-netrc
	if available.  Removed some extraneous quotes that made
	edebug die.

	* nnimap.el (nnimap-possibly-change-server): use the server
 	argument if non nil, otherwise we break multiple servers.

	* nnimap.el (nnimap-possibly-change-group): don't bother using
	sending a default server to `nnimap-possibly-change-server', It uses
	the same one anyway.

	* nnimap.el (nnimap-open-server): call nnoo-change-server from
	only one place.

--- imap4rev1.el.orig	Tue Aug 11 16:16:23 1998
+++ imap4rev1.el	Tue Aug 11 16:18:01 1998
@@ -165,6 +165,7 @@
 
 (when imap-debug ; (untrace-all)
   (require 'trace)
+  (buffer-disable-undo (get-buffer-create imap-debug))
   (mapc (lambda (f) (trace-function-background f imap-debug)) 
         '(imap-open-server
           imap-close-server
@@ -643,15 +644,15 @@
                    (mapconcat 'identity
                               '("\"[^\"]*\"" ; quoted strings
                                 "\\[\\|\\]" ; [] characters
-                                "UIDVALIDITY \\([0123456789]+\\)"
+                                "\\(UIDNEXT\\|UIDVALIDITY\\|APPENDUID\\) \\([0123456789]+\\)"
                                 "\\."   ; . characters
                                 "\\#"   ; # characters
                                 "\\\\"  ; \ characters
                                 "\r\n"  ; CRLF
                                 "{\\([^}]+\\)}") ; string literals
                               "\\|") nil t)) ; regexp or
-        (and (match-string 2)
-             (setq jump-amount (string-to-number (match-string 2))))
+        (and (match-string 3)
+             (setq jump-amount (string-to-number (match-string 3))))
         (let ((pc (preceding-char)))
           (cond ((eq pc ?\n)
                  (setq finished t))
@@ -665,7 +666,8 @@
                  (replace-match "}"))
                 ((and (>= pc ?0)
                       (<= pc ?9))
-                 (replace-match "UIDVALIDITY \"\\1\""))
+                 ;; replace numbers too big for emacs with strings
+                 (replace-match "\\1 \"\\2\""))
                 ((eq pc ?\})
                  (delete-region (match-beginning 0) (match-end 0))
                  (delete-char 2)
@@ -781,6 +783,8 @@
     (when var
       (cond ((equal var 'ALERT)
              (y-or-n-p (concat "IMAP: ALERT! " string)))
+            ((equal var 'APPENDUID)
+             (imap-folder-set 'appenduid (cons value (caddr code))))
             ((equal var 'PERMANENTFLAGS)
              (imap-folder-set 'permanentflags value))
             ((equal var 'READ-ONLY)
--- nnimap.el.orig	Tue Aug 11 16:16:17 1998
+++ nnimap.el	Tue Aug 11 14:42:54 1998
@@ -238,6 +238,7 @@
 
 (when nnimap-debug
   (require 'trace)
+  (buffer-disable-undo (get-buffer-create nnimap-debug))
   (mapc (lambda (f) (trace-function-background f nnimap-debug))
         '(
           nnimap-close-group
@@ -342,7 +343,8 @@
           'headers)))))
 
 (deffoo nnimap-open-server (server &optional defs)
-  (or (nnimap-server-opened server)
+  (or (and (nnimap-server-opened server)
+           (nnoo-change-server 'nnimap server defs))
       (progn
         (unless (assq 'nnimap-server-address defs)
           (push (list 'nnimap-server-address server) defs))
@@ -370,10 +372,13 @@
 		  (sit-for 2)
 		  (error))
 		;; Login
-		(let* ((list (gnus-parse-netrc nnimap-authinfo-file))
-		       (alist (gnus-netrc-machine list nnimap-server-address))
+		(let (list alist user passwd)
+                  (and (fboundp 'gnus-parse-netrc)
+                       (setq (list (gnus-parse-netrc nnimap-authinfo-file))
+                             (alist (gnus-netrc-machine
+                                     list nnimap-server-address))
 		       (user (gnus-netrc-get alist "login"))
-		       (passwd (gnus-netrc-get alist "password")))
+                             (passwd (gnus-netrc-get alist "password"))))
 		  (with-current-buffer nnimap-server-buffer
 		    (setq imap-password passwd))
 		  (while (not (imap-login user nnimap-server-buffer))
@@ -383,9 +388,9 @@
 		    (sleep-for 2)))
 		(push (cons server nnimap-server-buffer)
 		      nnimap-server-buffer-alist))
-	    ('error (kill-buffer nnimap-server-buffer)
+	    (error (kill-buffer nnimap-server-buffer)
 		    nil)
-	    ('quit (let (imap-last-status)
+	    (quit (let (imap-last-status)
 		     (imap-close-server nnimap-server-buffer)
 		     (kill-buffer nnimap-server-buffer)
 		     nil)))))))
@@ -493,7 +498,7 @@
 	    (with-current-buffer nntp-server-buffer
 	      (erase-buffer)
 	      (insert (format "211 %d %d %d %s\n" 
-			      exists (apply 'min articles)
+			      exists (max 1 (apply 'min articles))
 			      (apply 'max articles) group)))
 	    t)))));)
 
@@ -954,13 +959,14 @@
    ","))
 
 (defun nnimap-send-command-wait (command &optional buffer)
-  (gnus-message 10 (apply 'concat
+  (unless (and (stringp command) (string-match "%" command))
+    (gnus-message 5 (apply 'concat
                          (if (listp command)
                              (mapcar
                               (lambda (s-b) 
                                 (if (bufferp s-b) (buffer-name s-b) s-b)) 
                               command)
-                           (list command))))
+                              (list command)))))
   (imap-send-command-wait command buffer))
 
 (defun nnimap-ok-p (status)
@@ -978,13 +984,11 @@
 (defun nnimap-possibly-change-server (server)
   "Change to server SERVER if needed (open it if it's closed). If SERVER is
 nil, change to current server."
-  (and (nnimap-open-server (nnoo-current-server 'nnimap))
-       (nnoo-change-server 'nnimap (or server (nnoo-current-server 'nnimap))
-			   nil)))
+  (and (setq server (or server (nnoo-current-server 'nnimap)))
+       (nnimap-open-server server)))
 
 (defun nnimap-possibly-change-group (group &optional server)
-  (when (nnimap-possibly-change-server (or server (nnoo-current-server 
-						   'nnimap)))
+  (when (nnimap-possibly-change-server server)
     (with-current-buffer nnimap-server-buffer
       (when group
 	(unless (string= group imap-current-folder)
@@ -1008,7 +1012,7 @@
 	      (if old-uid
 		  (when (not (equal old-uid new-uid))
 		    (message "UIDVALIDITY clash. Old value `%s', new `%s'"
-			     old-uidvalidity new-uidvalidity)
+			     old-uid new-uid)
 		    (setq imap-current-folder nil))
 		(gnus-group-add-parameter groupname 
 					  (cons 'uidvalidity new-uid)))))))