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

Re: A little help from my friends



Nathan Williams <nwilliams@primeon.com> writes:

>         Yes. I hope to have something soon.

        Here's Revision 0 of a patch to fix up the names. This solves
my immediate needs by translating spaces to dashes and vice versa; I
don't have any imap mailboxes with dashes in the name to deal with
yet. I took the strategy of changing the names as close to the wire
interface as possible; this leads to slightly more instances of the
code, but a better set of chokepoints that mailbox names always pass
through was not apparant to me. 
        
        I also just made the change for
imap-mailbox-{select,status,list,lsub}. Changing the rest of
imap-mailbox-* to do the same thing will be very straightforward;
replace 'mailbox' in imap-send-command-wait with (imap-encode-string
(imap-uncleanup-mailbox-name mailbox)). I found it curious that only
one routine already did (imap-encode-string mailbox). 

        - Nathan

*** /tmp/nnimap-0.118/imap.el	Mon Jun 14 12:15:32 1999
--- imap.el	Wed Jun 16 13:49:42 1999
***************
*** 136,141 ****
--- 136,158 ----
  ;; o Sleep.
  ;;
  
+ 
+ ; Map from imap mailbox names to names gnus can cope with
+ (defun imap-cleanup-mailbox-name (name) (with-temp-buffer
+ 					  (insert name)
+ 					  (goto-char (point-min))
+ 					  (replace-string " " "-")
+ 					  (buffer-substring (point-min) 
+ 							    (point-max))))
+ ; Map back
+ (defun imap-uncleanup-mailbox-name (name) (with-temp-buffer
+ 					    (insert name)
+ 					    (goto-char (point-min))
+ 					    (replace-string "-" " ")
+ 					    (buffer-substring (point-min) 
+ 							      (point-max))))
+ 
+ 
  ;;; Code:
  
  (eval-and-compile
***************
*** 706,712 ****
  	  (setq imap-mailbox-data (make-vector imap-mailbox-prime 0)))
  	(setq imap-current-mailbox mailbox)
  	(if (imap-ok-p (imap-send-command-wait
! 			(concat (if examine "EXAMINE" "SELECT") " " mailbox)))
  	    (progn
  	      (setq imap-message-data (make-vector imap-message-prime 0)
  		    imap-state (if examine 'examine 'selected))
--- 723,731 ----
  	  (setq imap-mailbox-data (make-vector imap-mailbox-prime 0)))
  	(setq imap-current-mailbox mailbox)
  	(if (imap-ok-p (imap-send-command-wait
! 			(concat (if examine "EXAMINE" "SELECT") " " 
! 				(imap-encode-string 
! 				 (imap-uncleanup-mailbox-name mailbox)))))
  	    (progn
  	      (setq imap-message-data (make-vector imap-message-prime 0)
  		    imap-state (if examine 'examine 'selected))
***************
*** 782,788 ****
      (setq imap-mailbox-data (make-vector imap-mailbox-prime 0))
      (when (imap-ok-p (imap-send-command-wait 
  		      (concat "LSUB \"" reference "\" \"*\"")))
!       (imap-mailbox-map 'identity))))
  
  (defun imap-mailbox-list (&optional buffer root have-delimiter reference)
    "List all mailboxes that starts with ROOT in BUFFER. If
--- 801,807 ----
      (setq imap-mailbox-data (make-vector imap-mailbox-prime 0))
      (when (imap-ok-p (imap-send-command-wait 
  		      (concat "LSUB \"" reference "\" \"*\"")))
!       (imap-mailbox-map 'imap-cleanup-mailbox-name))))
  
  (defun imap-mailbox-list (&optional buffer root have-delimiter reference)
    "List all mailboxes that starts with ROOT in BUFFER. If
***************
*** 802,808 ****
  		    (when (and root (not have-delimiter))
  		      (imap-mailbox-get 'delimiter root))
  		    "%\"")))
!       (imap-mailbox-map 'identity))))
  
  (defun imap-mailbox-subscribe (mailbox &optional buffer)
    "Send the SUBSCRIBE command on the mailbox to server in
--- 821,827 ----
  		    (when (and root (not have-delimiter))
  		      (imap-mailbox-get 'delimiter root))
  		    "%\"")))
!       (imap-mailbox-map 'imap-cleanup-mailbox-name))))
  
  (defun imap-mailbox-subscribe (mailbox &optional buffer)
    "Send the SUBSCRIBE command on the mailbox to server in
***************
*** 825,831 ****
    (with-current-buffer (or buffer (current-buffer))
      (when (imap-ok-p 
  	   (imap-send-command-wait (list "STATUS "
! 					 (imap-encode-string mailbox)
  					 " "
  					 (format "%s"
  						 (if (listp items)
--- 844,851 ----
    (with-current-buffer (or buffer (current-buffer))
      (when (imap-ok-p 
  	   (imap-send-command-wait (list "STATUS "
! 					 (imap-encode-string 
! 					  (imap-uncleanup-mailbox-name mailbox))
  					 " "
  					 (format "%s"
  						 (if (listp items)