[Date Prev][Date Next] [Chronological] [Thread] [Top]

nnimap 0.108 -> 0.109 patches



Index: nnimap/ChangeLog
diff -c nnimap/ChangeLog:1.216 nnimap/ChangeLog:1.220
*** nnimap/ChangeLog:1.216	Wed May 26 14:12:23 1999
--- nnimap/ChangeLog	Thu May 27 10:05:53 1999
***************
*** 1,3 ****
--- 1,17 ----
+ 1999-05-27  Simon Josefsson  <jas@pdc.kth.se>
+ 
+ 	* nnimap 0.109 released.
+ 
+ 	* imap.el (imap-fetch): Handle nouidfetch properly.
+ 
+ 	* nnimap.el (nnimap-verify-uidvalidity): New function.
+ 	(nnimap-possibly-change-group): Rewritten.
+ 	(nnimap-expand-newtext): Removed.
+ 	(nnimap-split-to-groups): Use nnmail-expand-newtext
+ 	(nnimap-get-server-buffer): Defsubst for speed.
+ 	(nnimap-retrieve-headers): Clear server buffer.
+ 	(nnimap-request-group): Rewritten.
+ 
  1999-05-26  Simon Josefsson  <jas@pdc.kth.se>
  
  	* nnimap 0.108 released.
Index: nnimap/imap.el
diff -c nnimap/imap.el:1.138 nnimap/imap.el:1.139
*** nnimap/imap.el:1.138	Wed May 26 14:01:40 1999
--- nnimap/imap.el	Thu May 27 09:36:24 1999
***************
*** 870,876 ****
  is non-nil return theese properties."
    (with-current-buffer (or buffer (current-buffer))
      (when (imap-ok-p (imap-send-command-wait 
! 		      (format "%sFETCH %s %s" (or nouidfetch "UID ")
  			      (if (listp uids)
  				  (imap-list-to-message-set uids)
  				uids)
--- 870,876 ----
  is non-nil return theese properties."
    (with-current-buffer (or buffer (current-buffer))
      (when (imap-ok-p (imap-send-command-wait 
! 		      (format "%sFETCH %s %s" (if nouidfetch "" "UID ")
  			      (if (listp uids)
  				  (imap-list-to-message-set uids)
  				uids)
Index: nnimap/nnimap.el
diff -c nnimap/nnimap.el:1.169 nnimap/nnimap.el:1.173
*** nnimap/nnimap.el:1.169	Wed May 26 14:22:30 1999
--- nnimap/nnimap.el	Thu May 27 09:37:15 1999
***************
*** 99,105 ****
  (gnus-declare-backend "nnimap" 'mail 'address 'prompt-address 
  		      'physical-address)
  
! (defconst nnimap-version "nnimap 0.108")
  
  (defvoo nnimap-address nil
    "Address of physical IMAP server.  If nil, use the virtual server's name.")
--- 99,105 ----
  (gnus-declare-backend "nnimap" 'mail 'address 'prompt-address 
  		      'physical-address)
  
! (defconst nnimap-version "nnimap 0.109")
  
  (defvoo nnimap-address nil
    "Address of physical IMAP server.  If nil, use the virtual server's name.")
***************
*** 191,196 ****
--- 191,208 ----
  ~/Mail/overview/nnimap/pdc/INBOX/spam if `gnus-use-long-file-name' is
  nil")
  
+ (defvoo nnimap-expunge-on-close 'always ; 'ask, 'never
+   "When a IMAP group with articles marked for deletion is closed, this
+ variable determine if nnimap should actually remove the articles or
+ not.
+ 
+ If always, nnimap always perform a expunge when closing the group.
+ If never, nnimap never expunges articles marked for deletion.
+ If ask, nnimap will ask you if you wish to expunge marked articles.
+ 
+ When setting this variable to `never', you can only expunge articles
+ by using `G x' (gnus-group-nnimap-expunge) from the Group buffer.")
+ 
  (defcustom nnimap-authinfo-file "~/.authinfo"
    "Authorization information for IMAP servers. In .netrc format."
    :type
***************
*** 253,270 ****
  (defvoo nnimap-imap-defs nil
    "*Definitions of variables to set up in the IMAP buffer.")
  
- (defvoo nnimap-expunge-on-close 'always ; 'ask, 'never
-   "When a IMAP group with articles marked for deletion is closed, this
- variable determine if nnimap should actually remove the articles or
- not.
- 
- If always, nnimap always perform a expunge when closing the group.
- If never, nnimap never expunges articles marked for deletion.
- If ask, nnimap will ask you if you wish to expunge marked articles.
- 
- When setting this variable to `never', you can only expunge articles
- by using `G x' (gnus-group-nnimap-expunge) from the Group buffer.")
- 
  
  ;; Internal variables.
  (defvar nnimap-server-buffer-alist nil) ;; Map server name to buffers.
--- 265,270 ----
***************
*** 279,290 ****
  ;; nnimap 1.x functions:
  
  (nnoo-define-basics nnimap)
  
! (defmacro nnimap-get-server-buffer (server)
    "Return buffer for SERVER. If SERVER is nil, the current server is
  used."
!   `(nth 1 (assoc (or ,server nnimap-current-server)
! 		 nnimap-server-buffer-alist)))
  
  (defun nnimap-possibly-change-server (server)
    ;; Return buffer of server SERVER. If SERVER is nil, return current
--- 279,291 ----
  ;; nnimap 1.x functions:
  
  (nnoo-define-basics nnimap)
+ 
+ ;; Utility functions:
  
! (defsubst nnimap-get-server-buffer (server)
    "Return buffer for SERVER. If SERVER is nil, the current server is
  used."
!   (cadr (assoc (or server nnimap-current-server) nnimap-server-buffer-alist)))
  
  (defun nnimap-possibly-change-server (server)
    ;; Return buffer of server SERVER. If SERVER is nil, return current
***************
*** 292,297 ****
--- 293,330 ----
    (setq nnimap-current-server (or server nnimap-current-server)
  	nnimap-server-buffer (nnimap-get-server-buffer nnimap-current-server)))
  
+ (defun nnimap-verify-uidvalidity (group server)
+   (let* ((gnusgroup (gnus-group-prefixed-name 
+ 		     group (gnus-server-to-method 
+ 			    (format "nnimap:%s" server))))
+ 	 (new-uidvalidity (imap-mailbox-get 'uidvalidity))
+ 	 (old-uidvalidity (gnus-group-get-parameter gnusgroup 'uidvalidity)))
+     (if old-uidvalidity
+ 	(if (not (equal old-uidvalidity new-uidvalidity))
+ 	    nil ;; uidvalidity clash
+ 	  (gnus-group-set-parameter gnusgroup 'uidvalidity new-uidvalidity)
+ 	  t)
+       (gnus-group-add-parameter gnusgroup (cons 'uidvalidity new-uidvalidity))
+       t)))
+ 
+ (defun nnimap-possibly-change-group (group &optional server)
+   (when (nnimap-possibly-change-server server)
+     (with-current-buffer nnimap-server-buffer
+       (if (null group)
+ 	  imap-current-mailbox
+ 	(if (and imap-current-mailbox (string= group imap-current-mailbox))
+ 	    t
+ 	  (when imap-current-mailbox
+ 	    (nnimap-expunge-close-group))
+ 	  (when (imap-mailbox-select group)
+ 	    (if (nnimap-verify-uidvalidity group 
+ 					   (or server nnimap-current-server))
+ 		imap-current-mailbox
+ 	      (imap-mailbox-unselect)
+ 	      (message "nnimap: Group %s is not uid-valid." group)
+ 	      (ding)
+ 	      nil)))))))
+ 
  (defun nnimap-replace-whitespace (string)
    "Return STRING with all whitespace replaced with space."
    (when string
***************
*** 299,304 ****
--- 332,339 ----
        (setq string (replace-match " " t t string)))
      string))
  
+ ;; Required backend functions
+ 
  (defun nnimap-retrieve-headers-progress ()
    (and (numberp nnmail-large-newsgroup)
         (> nnimap-length nnmail-large-newsgroup)
***************
*** 352,357 ****
--- 387,394 ----
  
  (deffoo nnimap-retrieve-headers (articles &optional group server fetch-old)
    (when (nnimap-possibly-change-group group server)
+     (with-current-buffer nntp-server-buffer
+       (erase-buffer))
      (let ((uids (nnimap-retrieve-headers-get-uids articles fetch-old))
  	  (imap-fetch-data-hook '(nnimap-retrieve-headers-progress))
  	  (nnimap-length (length articles))
***************
*** 486,491 ****
--- 523,548 ----
    (nnimap-request-article-part
     article "RFC822.TEXT.PEEK" 'RFC822.TEXT group server to-buffer))
  
+ (deffoo nnimap-request-group (group &optional server fast)
+   (nnimap-request-update-info-internal
+    group
+    (gnus-get-info (gnus-group-prefixed-name 
+ 		   group (gnus-server-to-method (format "nnimap:%s" server))))
+    server)
+   (when (nnimap-possibly-change-group group server)
+     (with-current-buffer nnimap-server-buffer
+       (unless fast
+ 	(let ((minuid 1) (maxuid 0))
+ 	  (imap-fetch "1,*" "UID" nil 'nouidfetch)
+ 	  (imap-message-map (lambda (uid Uid)
+ 			      (setq minuid (min minuid uid)
+ 				    maxuid (max maxuid uid)))
+ 			    'UID)
+ 	  (nnheader-insert "211 %d %d %d %s\n" (imap-mailbox-get 'exists)
+ 			   (max 1 minuid) maxuid group)))
+       (nnheader-report 'nnimap "Group %s selected" group)
+       t)))
+       
  (defun nnimap-expunge-close-group (&optional server)
    (with-current-buffer nnimap-server-buffer
      (when (nnimap-possibly-change-server server)
***************
*** 535,573 ****
  
  ;; Optional backend functions
  
! ;; This is from nnmail.el:nnmail-expand-newtext, written by Larsi.
! (defun nnimap-expand-newtext (newtext)
!   (let ((len (length newtext))
! 	(pos 0)
! 	c expanded beg N did-expand)
!     (while (< pos len)
!       (setq beg pos)
!       (while (and (< pos len)
! 		  (not (= (aref newtext pos) ?\\)))
! 	(setq pos (1+ pos)))
!       (unless (= beg pos)
! 	(push (substring newtext beg pos) expanded))
!       (when (< pos len)
! 	;; We hit a \; expand it.
! 	(setq did-expand t
! 	      pos (1+ pos)
! 	      c (aref newtext pos))
! 	(if (not (or (= c ?\&)
! 		     (and (>= c ?1)
! 			  (<= c ?9))))
! 	    ;; \ followed by some character we don't expand.
! 	    (push (char-to-string c) expanded)
! 	  ;; \& or \N
! 	  (if (= c ?\&)
! 	      (setq N 0)
! 	    (setq N (- c ?0)))
! 	  (when (match-beginning N)
! 	    (push (buffer-substring (match-beginning N) (match-end N))
! 		  expanded))))
!       (setq pos (1+ pos)))
!     (if did-expand
! 	(apply 'concat (nreverse expanded))
!       newtext)))
  
  (defun nnimap-split-to-groups (rules)
    ;; tries to match all rules in nnimap-split-rule against content of 
--- 592,638 ----
  
  ;; Optional backend functions
  
! (deffoo nnimap-request-type (group &optional article)
!   'mail)
! 
! (deffoo nnimap-request-set-mark (group actions &optional server)
!   (when (nnimap-possibly-change-group group server)
!     (with-current-buffer nnimap-server-buffer
!       (let (action)
! 	(gnus-message 7 "Setting marks in %s:%s..."  
! 		      (nnoo-current-server 'nnimap) group)
! 	(while (setq action (pop actions))
! 	  (let ((range (nth 0 action))
! 		(what  (nth 1 action))
! 		(cmdmarks (nth 2 action))
! 		marks)
! 	    ;; cache flags are pointless on the server
! 	    (setq cmdmarks (delq 'cache cmdmarks))
! 	    ;; flag dormant articles as ticked
! 	    (if (memq 'dormant cmdmarks)
! 		(setq cmdmarks (cons 'tick cmdmarks)))
! 	    ;; remove stuff we are forbidden to store
! 	    (mapcar (lambda (mark)
! 		      (if (imap-message-flag-permanent-p
! 			   (nnimap-mark-to-flag mark))
! 			  (setq marks (cons mark marks))))
! 		    cmdmarks)
! 	    (when (and range marks)
! 	      (cond ((eq what 'del)
! 		     (imap-message-flags-del
! 		      (nnimap-range-to-string range)
! 		      (nnimap-mark-to-flag marks nil t)))
! 		    ((eq what 'add)
! 		     (imap-message-flags-add 
! 		      (nnimap-range-to-string range)
! 		      (nnimap-mark-to-flag marks nil t)))
! 		    ((eq what 'set)
! 		     (imap-message-flags-set
! 		      (nnimap-range-to-string range)
! 		      (nnimap-mark-to-flag marks nil t)))))))
! 	(gnus-message 7 "Setting marks in %s:%s...done" 
! 		      (nnoo-current-server 'nnimap) group))))
!   nil)
  
  (defun nnimap-split-to-groups (rules)
    ;; tries to match all rules in nnimap-split-rule against content of 
***************
*** 593,599 ****
  			 ;; Don't enter the article into the same group twice.
  			 (not (assoc group to-groups)))
  		(push (if regrepp
! 			  (nnimap-expand-newtext group)
  			group)
  		      to-groups)
  		(or nnimap-split-crosspost
--- 658,664 ----
  			 ;; Don't enter the article into the same group twice.
  			 (not (assoc group to-groups)))
  		(push (if regrepp
! 			  (nnmail-expand-newtext group)
  			group)
  		      to-groups)
  		(or nnimap-split-crosspost
***************
*** 639,686 ****
  	    (nnimap-expunge-close-group)))
  	t))))
  
- (deffoo nnimap-request-type (group &optional article)
-   'mail)
- 
- (deffoo nnimap-request-set-mark (group actions &optional server)
-   (when (nnimap-possibly-change-group group server)
-     (with-current-buffer nnimap-server-buffer
-       (let (action)
- 	(gnus-message 7 "Setting marks in %s:%s..."  
- 		      (nnoo-current-server 'nnimap) group)
- 	(while (setq action (pop actions))
- 	  (let ((range (nth 0 action))
- 		(what  (nth 1 action))
- 		(cmdmarks (nth 2 action))
- 		marks)
- 	    ;; cache flags are pointless on the server
- 	    (setq cmdmarks (delq 'cache cmdmarks))
- 	    ;; flag dormant articles as ticked
- 	    (if (memq 'dormant cmdmarks)
- 		(setq cmdmarks (cons 'tick cmdmarks)))
- 	    ;; remove stuff we are forbidden to store
- 	    (mapcar (lambda (mark)
- 		      (if (imap-message-flag-permanent-p
- 			   (nnimap-mark-to-flag mark))
- 			  (setq marks (cons mark marks))))
- 		    cmdmarks)
- 	    (when (and range marks)
- 	      (cond ((eq what 'del)
- 		     (imap-message-flags-del
- 		      (nnimap-range-to-string range)
- 		      (nnimap-mark-to-flag marks nil t)))
- 		    ((eq what 'add)
- 		     (imap-message-flags-add 
- 		      (nnimap-range-to-string range)
- 		      (nnimap-mark-to-flag marks nil t)))
- 		    ((eq what 'set)
- 		     (imap-message-flags-set
- 		      (nnimap-range-to-string range)
- 		      (nnimap-mark-to-flag marks nil t)))))))
- 	(gnus-message 7 "Setting marks in %s:%s...done" 
- 		      (nnoo-current-server 'nnimap) group))))
-   nil)
- 
  (deffoo nnimap-request-scan (&optional group server)
    (nnimap-split-articles group server))
  
--- 704,709 ----
***************
*** 891,932 ****
  
  ;; legacy functions:
  
- 
- ;;; Interface functions, required backend functions
- 
- ;;; Select GROUP and unless FAST return 211 EXISTS LOWEST HIGHEST GROUP
- ;;; The active info returned goes into the `gnus-active-hashtb'.
- ;;; Don't call this directly, call `gnus-activate-group'.
- ;;; `gnus-activate-group' can call `request-scan' before request-group.
- ;;; Ok, here seems to be the problem.  We return 'group and
- ;;; `gnus-groups-to-gnus-format' seem to not use a prefix "nnimap+yoyo:"
- ;;; when entering something into the active-hashtb but it does when
- ;;; it looks for new news.  Damn.
- (deffoo nnimap-request-group (group &optional server fast)
-   (nnimap-request-update-info-internal
-    group (gnus-get-info (gnus-group-prefixed-name 
- 			 group (gnus-server-to-method
- 				(format "nnimap:%s" server))))
-    server)
-   (if fast
-       (with-current-buffer nntp-server-buffer 
- 	(erase-buffer)
- 	(nnimap-possibly-change-group group server))
-     (gnus-message 7 "Opening nnimap group %s..." group)
-     (when (nnimap-possibly-change-group group server)
-       (with-current-buffer nnimap-server-buffer
- 	(let ((exists (imap-mailbox-get 'exists))
- 	      articles)
- 	  (if (eq 0 exists)
- 	      (setq articles '(0))
- 	    (when (nnimap-ok-p (nnimap-send-command-wait "FETCH 1,* (UID)"))
- 	      (imap-message-map (lambda (uid Uid)
- 				  (push uid articles)) 'UID)))
- 	  (nnheader-insert "211 %d %d %d %s\n" exists
- 			   (max 1 (apply 'min articles))
- 			   (apply 'max articles) group))))
-     (gnus-message 7 "Opening nnimap group %s...done" group)))
- 
  ;;; Returns: GROUP HIGHEST LOWEST [ynmxj=]
  (defun nnimap-request-list-mapper (group)
    (unless (or (member "\\NoSelect" (imap-mailbox-get 'list-flags group))
--- 914,919 ----
***************
*** 948,956 ****
  			      (apply 'min articles))))))
  	t))))
  
- 
- ;;; Interface functions, optional backend functions
- 
  ;; This gets called instead of `nnimap-request-list' when
  ;; `gnus-read-active-file' is 'some instead of t.
  ;; Returns: GROUP HIGHEST LOWEST [ynmxj=] ???
--- 935,940 ----
***************
*** 1118,1124 ****
      (remassoc key alist)))
  
  (defun nnimap-range-to-string (range)
!   (mapconcat 
     (lambda (item)
       (if (consp item)
           (format "%d:%d" 
--- 1102,1108 ----
      (remassoc key alist)))
  
  (defun nnimap-range-to-string (range)
!   (mapconcat
     (lambda (item)
       (if (consp item)
           (format "%d:%d" 
***************
*** 1148,1190 ****
        t
      (nnheader-report 'nnimap (nth 3 status))))
  
- (defun nnimap-possibly-change-group (group &optional server)
-   (when (nnimap-possibly-change-server server)
-     (with-current-buffer nnimap-server-buffer
-       (when group
- 	(let ((groupname (gnus-group-prefixed-name 
- 			  group (gnus-find-method-for-group group))))
- 	  (if (and imap-current-mailbox
- 		   (not (string= group imap-current-mailbox)))
- 	      (nnimap-expunge-close-group))
- 	  (when (imap-mailbox-select group nil 
- 				     (gnus-ephemeral-group-p groupname))
- 	    ;; check/set UIDVALIDITY
- 	    (let ((new-uid (imap-mailbox-get 'uidvalidity))
- 		  (old-uid (gnus-group-get-parameter groupname 'uidvalidity))
- 		  (info (gnus-get-info groupname)))
- 	      (if (not old-uid)
- 		  (gnus-group-add-parameter groupname (cons 'uidvalidity 
- 							    new-uid))
- 		(when (not (equal old-uid new-uid))
- 		  (if (and (not (gnus-info-marks info))
- 			   (not (gnus-info-read info)))
- 		      (gnus-group-set-parameter groupname 'uidvalidity 
- 						new-uid)
- 		    (message "UIDVALIDITY clash in group %s. Old value `%s', new `%s'" group old-uid new-uid)
- 		    (imap-mailbox-unselect))))))))
-       imap-current-mailbox)))
- 
  (when nnimap-debug
    (require 'trace)
    (buffer-disable-undo (get-buffer-create nnimap-debug))
    (mapc (lambda (f) (trace-function-background f nnimap-debug))
          '(
  nnimap-possibly-change-server
  ;nnimap-retrieve-headers-progress
  ;nnimap-retrieve-headers-store-uids
! nnimap-retrieve-headers-get-uids
! nnimap-retrieve-headers-from-cache
  nnimap-retrieve-headers
  nnimap-open-connection
  nnimap-open-server
--- 1132,1149 ----
        t
      (nnheader-report 'nnimap (nth 3 status))))
  
  (when nnimap-debug
    (require 'trace)
    (buffer-disable-undo (get-buffer-create nnimap-debug))
    (mapc (lambda (f) (trace-function-background f nnimap-debug))
          '(
  nnimap-possibly-change-server
+ nnimap-verify-uidvalidity
+ nnimap-possibly-change-group
+ nnimap-replace-whitespace
  ;nnimap-retrieve-headers-progress
  ;nnimap-retrieve-headers-store-uids
! ;nnimap-retrieve-headers-get-uids
  nnimap-retrieve-headers
  nnimap-open-connection
  nnimap-open-server
***************
*** 1197,1214 ****
  nnimap-request-article
  nnimap-request-head
  nnimap-request-body
  nnimap-expunge-close-group
  nnimap-close-group
  nnimap-pattern-to-list-arguments
  nnimap-request-list
  nnimap-request-post
! nnimap-expand-newtext
  nnimap-split-to-groups
  nnimap-split-find-rule
  nnimap-split-find-inbox
  nnimap-split-articles
- nnimap-request-type
- nnimap-request-set-mark
  nnimap-request-scan
  nnimap-request-create-group
  nnimap-time-substract
--- 1156,1173 ----
  nnimap-request-article
  nnimap-request-head
  nnimap-request-body
+ nnimap-request-group
  nnimap-expunge-close-group
  nnimap-close-group
  nnimap-pattern-to-list-arguments
  nnimap-request-list
  nnimap-request-post
! nnimap-request-type
! nnimap-request-set-mark
  nnimap-split-to-groups
  nnimap-split-find-rule
  nnimap-split-find-inbox
  nnimap-split-articles
  nnimap-request-scan
  nnimap-request-create-group
  nnimap-time-substract
***************
*** 1223,1229 ****
  gnus-group-nnimap-edit-acl
  gnus-group-nnimap-edit-acl-done
  nnimap-group-mode-hook
- nnimap-request-group
  nnimap-request-list-mapper
  nnimap-retrieve-groups
  nnimap-request-update-info-internal
--- 1182,1187 ----
***************
*** 1234,1241 ****
  nnimap-update-alist-soft
  nnimap-range-to-string
  nnimap-send-command-wait
! ;nnimap-ok-p
! nnimap-possibly-change-group
            )))
  
  (provide 'nnimap)
--- 1192,1198 ----
  nnimap-update-alist-soft
  nnimap-range-to-string
  nnimap-send-command-wait
! nnimap-ok-p
            )))
  
  (provide 'nnimap)