git.fiddlerwoaroof.com
Browse code

Trim trailing whitespaces in imap.lisp

Orivej Desh authored on 10/02/2012 10:14:39
Showing 1 changed files
... ...
@@ -26,7 +26,7 @@
26 26
 ;;
27 27
 ;; This code is free software; you can redistribute it and/or
28 28
 ;; modify it under the terms of the version 2.1 of
29
-;; the GNU Lesser General Public License as published by 
29
+;; the GNU Lesser General Public License as published by
30 30
 ;; the Free Software Foundation, as clarified by the AllegroServe
31 31
 ;; prequel found in license-allegroserve.txt.
32 32
 ;;
... ...
@@ -45,12 +45,12 @@
45 45
 
46 46
 (defpackage :net.post-office
47 47
   (:use :lisp :excl)
48
-  (:export 
48
+  (:export
49 49
    #:address-name
50 50
    #:address-additional
51 51
    #:address-mailbox
52 52
    #:address-host
53
-   
53
+
54 54
    #:alter-flags
55 55
    #:close-connection
56 56
    #:close-mailbox
... ...
@@ -58,7 +58,7 @@
58 58
    #:create-mailbox
59 59
    #:delete-letter
60 60
    #:delete-mailbox
61
-   
61
+
62 62
    #:envelope-date
63 63
    #:envelope-subject
64 64
    #:envelope-from
... ...
@@ -69,7 +69,7 @@
69 69
    #:envelope-bcc
70 70
    #:envelope-in-reply-to
71 71
    #:envelope-message-id
72
-   
72
+
73 73
    #:expunge-mailbox
74 74
    #:fetch-field
75 75
    #:fetch-letter
... ...
@@ -98,17 +98,17 @@
98 98
    #:parse-mail-header
99 99
    #:top-lines	; pop only
100 100
    #:unique-id  ; pop only
101
-   
101
+
102 102
    #:po-condition
103 103
    #:po-condition-identifier
104 104
    #:po-condition-server-string
105 105
    #:po-error
106
-   
106
+
107 107
    #:rename-mailbox
108 108
    #:reset-mailbox
109 109
    #:search-mailbox
110 110
    #:select-mailbox
111
-   
111
+
112 112
    )
113 113
   )
114 114
 
... ...
@@ -133,24 +133,24 @@
133 133
 (defclass post-office ()
134 134
   ((socket :initarg :socket
135 135
 	   :accessor post-office-socket)
136
-   
136
+
137 137
    (host :initarg :host
138 138
 	 :accessor  post-office-host
139 139
 	 :initform nil)
140 140
    (user  :initarg :user
141 141
 	  :accessor post-office-user
142 142
 	  :initform nil)
143
-   
143
+
144 144
    (state :accessor post-office-state
145 145
 	  :initarg :state
146 146
 	  :initform :unconnected)
147
-   
148
-   (timeout 
147
+
148
+   (timeout
149 149
     ;; time to wait for network activity for actions that should
150 150
     ;; happen very quickly when things are operating normally
151 151
     :initarg :timeout
152 152
     :initform 60
153
-    :accessor timeout) 
153
+    :accessor timeout)
154 154
   ))
155 155
 
156 156
 (defclass imap-mailbox (post-office)
... ...
@@ -158,47 +158,47 @@
158 158
     :accessor mailbox-name
159 159
     :initform nil)
160 160
 
161
-   (separator 
161
+   (separator
162 162
     ;; string that separates mailbox names in the hierarchy
163 163
     :accessor mailbox-separator
164 164
     :initform "")
165
-   
165
+
166 166
    ;;; these slots hold information about the currently selected mailbox:
167
-   
167
+
168 168
     (message-count  ; how many in the mailbox
169 169
     :accessor mailbox-message-count
170 170
     :initform 0)
171
-   
171
+
172 172
    (recent-messages ; how many messages since we last checked
173 173
     :accessor mailbox-recent-messages
174 174
     :initform 0)
175
-   
175
+
176 176
    (uidvalidity  ; used to denote messages uniquely
177
-    :accessor mailbox-uidvalidity 
177
+    :accessor mailbox-uidvalidity
178 178
     :initform 0)
179
-   
180
-   (uidnext 
179
+
180
+   (uidnext
181 181
     :accessor mailbox-uidnext ;; predicted next uid
182 182
     :initform 0)
183
-   
183
+
184 184
    (flags	; list of flags that can be stored in a message
185
-    :accessor mailbox-flags 
185
+    :accessor mailbox-flags
186 186
     :initform nil)
187
-   
187
+
188 188
    (permanent-flags  ; list of flags that be stored permanently
189 189
     :accessor mailbox-permanent-flags
190 190
     :initform nil)
191
-   
191
+
192 192
    (first-unseen   ; number of the first unseen message
193 193
     :accessor first-unseen
194 194
     :initform 0)
195
-   
195
+
196 196
    ;;; end list of values for the currently selected mailbox
197
-   
197
+
198 198
    ;;; state information for fetch-letter-sequence
199
-   (fetch-letter-offset 
199
+   (fetch-letter-offset
200 200
     :accessor fetch-letter-offset)
201
-   (fetch-letter-number 
201
+   (fetch-letter-number
202 202
     :accessor fetch-letter-number)
203 203
    (fetch-letter-uid
204 204
     :accessor fetch-letter-uid)
... ...
@@ -212,10 +212,10 @@
212 212
   ((message-count  ; how many in the mailbox
213 213
     :accessor mailbox-message-count
214 214
     :initform 0)
215
-   (fetch-letter-state 
215
+   (fetch-letter-state
216 216
     :accessor state
217 217
     :initform :invalid)))
218
-    
218
+
219 219
 
220 220
 
221 221
 
... ...
@@ -245,7 +245,7 @@
245 245
   name     ;; often the person's full name
246 246
   additional
247 247
   mailbox  ;; the login name
248
-  host	   ;; the name of the machine 
248
+  host	   ;; the name of the machine
249 249
   )
250 250
 
251 251
 
... ...
@@ -260,11 +260,11 @@
260 260
 ; All our conditions are po-condition or po-error (which is a subclass of
261 261
 ; po-condition).
262 262
 ;
263
-; A condition will have a server-string value if it as initiated by 
263
+; A condition will have a server-string value if it as initiated by
264 264
 ; something returned by the server.
265
-; A condition will have a format-control value if we want to display 
266
-; something we generated in response to 
267
-; 
265
+; A condition will have a format-control value if we want to display
266
+; something we generated in response to
267
+;
268 268
 ;
269 269
 ;
270 270
 ;; identifiers used in conditions/errors
... ...
@@ -273,7 +273,7 @@
273 273
 ;	the server responded with 'no' followed by an explanation.
274 274
 ;	this mean that something unusual happend and doesn't necessarily
275 275
 ;	mean that the command has completely failed (but it might).
276
-;	
276
+;
277 277
 ; :unknown-ok   condition
278 278
 ;	the server responded with an 'ok' followed by something
279 279
 ;	we don't recognize.  It's probably safe to ignore this.
... ...
@@ -306,13 +306,13 @@
306 306
 (define-condition po-condition ()
307 307
   ;; used to notify user of things that shouldn't necessarily stop
308 308
   ;; program flow
309
-  ((identifier 
309
+  ((identifier
310 310
     ;; keyword identifying the error (or :unknown)
311
-    :reader po-condition-identifier	
311
+    :reader po-condition-identifier
312 312
     :initform :unknown
313 313
     :initarg :identifier
314 314
     )
315
-   (server-string 
315
+   (server-string
316 316
     ;; message from the imap server
317 317
     :reader po-condition-server-string
318 318
     :initform ""
... ...
@@ -321,7 +321,7 @@
321 321
   (:report
322 322
    (lambda (con stream)
323 323
      (with-slots (identifier server-string) con
324
-       ;; a condition either has a server-string or it has a 
324
+       ;; a condition either has a server-string or it has a
325 325
        ;; format-control string
326 326
        (format stream "Post Office condition: ~s~%" identifier)
327 327
        (if* (and (slot-boundp con 'excl::format-control)
... ...
@@ -333,10 +333,10 @@
333 333
 	  then (format stream
334 334
 		       "~&Message from server: ~s"
335 335
 		       (string-left-trim " " server-string)))))))
336
-	       
337
-    
338 336
 
339
-(define-condition po-error (po-condition error) 
337
+
338
+
339
+(define-condition po-error (po-condition error)
340 340
   ;; used to denote things that should stop program flow
341 341
   ())
342 342
 
... ...
@@ -344,7 +344,7 @@
344 344
 
345 345
 ;; aignalling the conditions
346 346
 
347
-(defun po-condition (identifier &key server-string format-control 
347
+(defun po-condition (identifier &key server-string format-control
348 348
 			  format-arguments)
349 349
   (signal (make-instance 'po-condition
350 350
 	    :identifier identifier
... ...
@@ -352,7 +352,7 @@
352 352
 	    :format-control format-control
353 353
 	    :format-arguments format-arguments
354 354
 	    )))
355
-	    
355
+
356 356
 (defun po-error (identifier &key server-string
357 357
 		      format-control format-arguments)
358 358
   (error (make-instance 'po-error
... ...
@@ -361,7 +361,7 @@
361 361
 	    :format-control format-control
362 362
 	    :format-arguments format-arguments)))
363 363
 
364
-			   
364
+
365 365
 
366 366
 ;----------------------------------------------
367 367
 
... ...
@@ -396,11 +396,11 @@
396 396
 				     :remote-port port))
397 397
       (when ssl
398 398
 	(setq sock (apply #'socket:make-ssl-client-stream sock ssl-args)))
399
-      
399
+
400 400
       (values sock starttls))) )
401 401
 
402
-(defun make-imap-connection (host &key (port 143) 
403
-				       user 
402
+(defun make-imap-connection (host &key (port 143)
403
+				       user
404 404
 				       password
405 405
 				       (timeout 30))
406 406
   (multiple-value-bind (sock starttls)
... ...
@@ -412,14 +412,14 @@
412 412
 		  :host   host
413 413
 		  :timeout timeout
414 414
 		  :state :unauthorized)))
415
-    
415
+
416 416
     (multiple-value-bind (tag cmd count extra comment)
417 417
 	(get-and-parse-from-imap-server imap)
418 418
       (declare (ignorable cmd count extra))
419 419
       (if* (not (eq :untagged tag))
420 420
 	 then  (po-error :error-response
421 421
 			 :server-string comment)))
422
-      
422
+
423 423
     ; check for starttls negotiation
424 424
     (when starttls
425 425
       (let (capabilities)
... ...
@@ -444,32 +444,32 @@
444 444
 					   (post-office-socket mb) :method :tlsv1)))))))
445 445
 
446 446
     ; now login
447
-    (send-command-get-results imap 
447
+    (send-command-get-results imap
448 448
 			      (format nil "login ~a ~a" user password)
449 449
 			      #'handle-untagged-response
450 450
 			      #'(lambda (mb command count extra comment)
451 451
 				  (check-for-success mb command count extra
452 452
 						     comment
453 453
 						     "login")))
454
-    
454
+
455 455
     ; find the separator character
456 456
     (let ((res (mailbox-list imap)))
457
-      ;; 
457
+      ;;
458 458
       (let ((sep (cadr  (car res))))
459 459
 	(if* sep
460 460
 	   then (setf (mailbox-separator imap) sep))))
461
-    
462
-				    
463
-				    
461
+
462
+
463
+
464 464
     imap)))
465 465
 
466 466
 
467 467
 (defmethod close-connection ((mb imap-mailbox))
468
-  
468
+
469 469
   (let ((sock (post-office-socket mb)))
470 470
     (if* sock
471 471
        then (ignore-errors
472
-	     (send-command-get-results 
472
+	     (send-command-get-results
473 473
 	      mb
474 474
 	      "logout"
475 475
 	      ; don't want to get confused by untagged
... ...
@@ -490,7 +490,7 @@
490 490
   (let ((sock (post-office-socket pb)))
491 491
     (if* sock
492 492
        then (ignore-errors
493
-	     (send-pop-command-get-results 
493
+	     (send-pop-command-get-results
494 494
 	      pb
495 495
 	      "QUIT")))
496 496
     (setf (post-office-socket pb) nil)
... ...
@@ -512,36 +512,36 @@
512 512
 		:host   host
513 513
 		:timeout timeout
514 514
 		:state :unauthorized)))
515
-    
515
+
516 516
     (multiple-value-bind (result)
517 517
 	(get-and-parse-from-pop-server pop)
518 518
       (if* (not (eq :ok result))
519 519
 	 then  (po-error :error-response
520 520
 			 :format-control
521 521
 			 "unexpected line from server after connect")))
522
-      
522
+
523 523
     ; check for starttls negotiation
524 524
     (when starttls
525 525
       (let ((capabilities (send-pop-command-get-results pop "capa" t)))
526 526
 	(when (and capabilities (match-re "STLS" capabilities :case-fold t
527 527
 					  :return nil))
528
-	  (send-pop-command-get-results pop "STLS")		   
529
-	  (setf (post-office-socket pop) (socket:make-ssl-client-stream 
528
+	  (send-pop-command-get-results pop "STLS")
529
+	  (setf (post-office-socket pop) (socket:make-ssl-client-stream
530 530
 					  (post-office-socket pop) :method :tlsv1)))))
531
-    
531
+
532 532
     ; now login
533 533
     (send-pop-command-get-results pop (format nil "user ~a" user))
534 534
     (send-pop-command-get-results pop (format nil "pass ~a" password))
535 535
 
536 536
     (let ((res (send-pop-command-get-results pop "stat")))
537 537
       (setf (mailbox-message-count pop) (car res)))
538
-    
539
-    			    
540
-				    
538
+
539
+
540
+
541 541
     pop)))
542
-			    
543 542
 
544
-(defmethod send-command-get-results ((mb imap-mailbox) 
543
+
544
+(defmethod send-command-get-results ((mb imap-mailbox)
545 545
 				     command untagged-handler tagged-handler)
546 546
   ;; send a command and retrieve results until we get the tagged
547 547
   ;; response for the command we sent
... ...
@@ -550,7 +550,7 @@
550 550
     (format (post-office-socket mb)
551 551
 	    "~a ~a~a" tag command *crlf*)
552 552
     (force-output (post-office-socket mb))
553
-    
553
+
554 554
     (if* *debug-imap*
555 555
        then (format t
556 556
 		    "~a ~a~a" tag command *crlf*)
... ...
@@ -564,7 +564,7 @@
564 564
 	   then (funcall tagged-handler mb cmd count extra comment)
565 565
 		(return)
566 566
 	   else (po-error :error-response
567
-			  :format-control "received tag ~s out of order" 
567
+			  :format-control "received tag ~s out of order"
568 568
 			  :format-arguments (list got-tag)
569 569
 			  :server-string comment))))))
570 570
 
... ...
@@ -577,7 +577,7 @@
577 577
 	    (pop *cur-imap-tags*))))
578 578
 
579 579
 (defun handle-untagged-response (mb command count extra comment)
580
-  ;; default function to handle untagged responses, which are 
580
+  ;; default function to handle untagged responses, which are
581 581
   ;; really just returning general state information about
582 582
   ;; the mailbox
583 583
   (case command
... ...
@@ -599,11 +599,11 @@
599 599
 	      elseif (equalp (car extra) "uidnext")
600 600
 		then (setf (mailbox-uidnext mb) (cadr extra))
601 601
 	      elseif (equalp (car extra) "permanentflags")
602
-		then (setf (mailbox-permanent-flags mb) 
602
+		then (setf (mailbox-permanent-flags mb)
603 603
 		       (kwd-intern-possible-list (cadr extra)))
604 604
 		else (po-condition :unknown-ok :server-string comment))))
605 605
     (t (po-condition :unknown-untagged :server-string comment)))
606
-	     
606
+
607 607
   )
608 608
 
609 609
 
... ...
@@ -617,7 +617,7 @@
617 617
 	(sock (post-office-socket mb))
618 618
 	ch
619 619
 	stop)
620
-    (macrolet ((add-to-buffer () 
620
+    (macrolet ((add-to-buffer ()
621 621
 		 `(progn
622 622
 		    (setf (schar buffer outpos) ch)
623 623
 		    (incf outpos))))
... ...
@@ -631,17 +631,17 @@
631 631
 		    (1 (if* (eq ch #\.)	; at beginning of line
632 632
 			  then (setf (state mb) 2)
633 633
 			elseif (eq ch #\linefeed)
634
-			  then 
634
+			  then
635 635
 			       (add-to-buffer) ; state stays at 1
636
-			  else 
636
+			  else
637 637
 			       (setf (state mb) 3)
638 638
 			       (add-to-buffer)))
639 639
 		    (2			; seen first dot
640 640
 		     (if* (eq ch #\linefeed)
641 641
 			then		; end of results
642 642
 			     (setf (state mb) 4)
643
-			     (return) 
644
-			else 
643
+			     (return)
644
+			else
645 645
 			     (setf (state mb) 3)
646 646
 			     (add-to-buffer))) ; normal reading
647 647
 		    (3			; middle of line
... ...
@@ -674,15 +674,15 @@
674 674
 	 (end-extended-results-sequence ,mb)))))
675 675
 
676 676
 
677
-  
677
+
678 678
 
679 679
 (defun send-pop-command-get-results (pop command &optional extrap)
680 680
   (declare (optimize (speed 3) (safety 1)))
681 681
   ;; send the given command to the pop server
682 682
   ;; if extrap is true and if the response is +ok, then data
683
-  ;;  will follow the command (up to and excluding the first line consisting 
683
+  ;;  will follow the command (up to and excluding the first line consisting
684 684
   ;;  of just a period)
685
-  ;; 
685
+  ;;
686 686
   ;; if the pop server returns an error code we signal a lisp error.
687 687
   ;; otherwise
688 688
   ;; return
... ...
@@ -691,7 +691,7 @@
691 691
   ;;
692 692
   (format (post-office-socket pop) "~a~a" command *crlf*)
693 693
   (force-output (post-office-socket pop))
694
-  
694
+
695 695
   (if* *debug-imap*
696 696
      then (format t "~a~a" command *crlf*)
697 697
 	  (force-output t))
... ...
@@ -705,10 +705,10 @@
705 705
     (if* extrap
706 706
        then ;; get the rest of the data
707 707
 	    ;; many but not all pop servers return the size of the data
708
-	    ;; after the +ok, so we use that to initially size the 
708
+	    ;; after the +ok, so we use that to initially size the
709 709
 	    ;; retreival buffer.
710 710
 	    (let* ((buf (get-line-buffer (+ (if* (fixnump (car parsed))
711
-					       then (car parsed) 
711
+					       then (car parsed)
712 712
 					       else 2048 ; reasonable size
713 713
 						    )
714 714
 					    50)))
... ...
@@ -733,12 +733,12 @@
733 733
 	      (prog1 (subseq buf 0 pos)
734 734
 		(free-line-buffer buf)))
735 735
        else parsed)))
736
-  
736
+
737 737
 
738 738
 
739 739
 
740 740
 (defun convert-flags-plist (plist)
741
-  ;; scan the plist looking for "flags" indicators and 
741
+  ;; scan the plist looking for "flags" indicators and
742 742
   ;; turn value into a list of symbols rather than strings
743 743
   (do ((xx plist (cddr xx)))
744 744
       ((null xx) plist)
... ...
@@ -754,9 +754,9 @@
754 754
 			    #'(lambda (mb command count extra comment)
755 755
 				(declare (ignore mb count extra))
756 756
 				(if* (not (eq command :ok))
757
-				   then (po-error 
757
+				   then (po-error
758 758
 					 :problem
759
-					 :format-control 
759
+					 :format-control
760 760
 					 "imap mailbox select failed"
761 761
 					 :server-string comment))))
762 762
   (setf (mailbox-name mb) name)
... ...
@@ -773,8 +773,8 @@
773 773
 
774 774
 (defmethod fetch-letter ((pb pop-mailbox) number &key uid)
775 775
   (declare (ignore uid))
776
-  (send-pop-command-get-results pb 
777
-				(format nil "RETR ~d" number) 
776
+  (send-pop-command-get-results pb
777
+				(format nil "RETR ~d" number)
778 778
 				t ; extra stuff
779 779
 				))
780 780
 
... ...
@@ -790,28 +790,28 @@
790 790
   (send-pop-command-get-results mb (format nil "RETR ~d" number))
791 791
   (begin-extended-results-sequence mb))
792 792
 
793
-(defmethod fetch-letter-sequence ((mb imap-mailbox) buffer 
793
+(defmethod fetch-letter-sequence ((mb imap-mailbox) buffer
794 794
 				  &key (start 0) (end (length buffer)))
795 795
   (let* ((num (fetch-letter-number mb))
796 796
 	 (offset (fetch-letter-offset mb))
797 797
 	 (uid (fetch-letter-uid mb))
798 798
 	 (buflen (- end start))
799
-	 (data (fetch-field num (format nil "body[]<~d>" offset) 
800
-			    (fetch-parts mb num 
799
+	 (data (fetch-field num (format nil "body[]<~d>" offset)
800
+			    (fetch-parts mb num
801 801
 					 (format nil "body[]<~d.~d>" offset buflen)
802 802
 					 :uid uid)
803 803
 			    :uid uid))
804 804
 	 (datalen (length data)))
805 805
 
806 806
     (setf (subseq buffer start end) data)
807
-    
807
+
808 808
     (if* (and (> buflen 0) (= datalen 0))
809 809
        then (setf (fetch-letter-finished mb) t))
810
-    
810
+
811 811
     (setf (fetch-letter-offset mb) (+ offset buflen))
812
-    
812
+
813 813
     (+ start datalen)))
814
-		       
814
+
815 815
 
816 816
 (defmethod fetch-letter-sequence ((mb pop-mailbox) buffer &key (start 0) (end (length buffer)))
817 817
   (get-extended-results-sequence mb buffer :start start :end end))
... ...
@@ -837,10 +837,10 @@
837 837
 	     ,@body)
838 838
 	 ;; cleanup
839 839
 	 (end-fetch-letter-sequence ,mb)))))
840
-	    
840
+
841 841
 (defmethod fetch-parts ((mb imap-mailbox) number parts &key uid)
842 842
   (let (res)
843
-    (send-command-get-results 
843
+    (send-command-get-results
844 844
      mb
845 845
      (format nil "~afetch ~a ~a"
846 846
 	     (if* uid then "uid " else "")
... ...
@@ -860,9 +860,9 @@
860 860
 			   :server-string comment))))
861 861
     res))
862 862
 
863
-		      
863
+
864 864
 (defun fetch-field (letter-number field-name info &key uid)
865
-  ;; given the information from a fetch-letter, return the 
865
+  ;; given the information from a fetch-letter, return the
866 866
   ;; particular field for the particular letter
867 867
   ;;
868 868
   ;; info is as returned by fetch
... ...
@@ -883,34 +883,34 @@
883 883
 			   else (return))))
884 884
 	 else ; just a message sequence number
885 885
 	      (setq use-this (eql letter-number (car item))))
886
-    
886
+
887 887
       (if* use-this
888 888
 	 then (do ((xx (cadr item) (cddr xx)))
889 889
 		  ((null xx))
890 890
 		(if* (equalp field-name (car xx))
891 891
 		   then (return-from fetch-field (cadr xx))))))))
892 892
 
893
-	 
893
+
894 894
 
895 895
 (defun internalize-flags (stuff)
896
-  ;; given a plist like object, look for items labelled "flags" and 
896
+  ;; given a plist like object, look for items labelled "flags" and
897 897
   ;; convert the contents to internal flags objects
898 898
   (do ((xx stuff (cddr xx)))
899 899
       ((null xx))
900 900
     (if* (equalp (car xx) "flags")
901
-       then ; we can end up with sublists of forms if we 
901
+       then ; we can end up with sublists of forms if we
902 902
 	    ; do add-flags with a list of flags.  this seems like
903 903
 	    ; a bug in the imap server.. but we have to deal with it
904 904
 	      (setf (cadr xx) (kwd-intern-possible-list (cadr xx)))
905 905
 	      (return)))
906
-  
906
+
907 907
   stuff)
908 908
 
909
-					
909
+
910 910
 
911 911
 
912 912
 (defmethod delete-letter ((mb imap-mailbox) messages &key (expunge t) uid)
913
-  ;; delete all the mesasges and do the expunge to make 
913
+  ;; delete all the mesasges and do the expunge to make
914 914
   ;; it permanent if expunge is true
915 915
   (alter-flags mb messages :add-flags :\\deleted :uid uid)
916 916
   (if* expunge then (expunge-mailbox mb)))
... ...
@@ -919,16 +919,16 @@
919 919
   ;; delete all the messages.   We can't expunge without quitting so
920 920
   ;; we don't expunge
921 921
   (declare (ignore expunge uid))
922
-  
923
-  (if* (or (numberp messages) 
922
+
923
+  (if* (or (numberp messages)
924 924
 	   (and (consp messages) (eq :seq (car messages))))
925 925
      then (setq messages (list messages)))
926
-  
926
+
927 927
   (if* (not (consp messages))
928 928
      then (po-error :syntax-error
929 929
 		    :format-control "expect a mesage number or list of messages, not ~s"
930 930
 		 :format-arguments (list messages)))
931
-  
931
+
932 932
   (dolist (message messages)
933 933
     (if* (numberp message)
934 934
        then (send-pop-command-get-results pb
... ...
@@ -940,12 +940,12 @@
940 940
 	      (send-pop-command-get-results pb
941 941
 					    (format nil "DELE ~d" start)))
942 942
        else (po-error :syntax-error
943
-		      :format-control "bad message number ~s" 
943
+		      :format-control "bad message number ~s"
944 944
 		      :format-arguments (list message)))))
945
-	    
946
-	    
947
-			    
948
-					
945
+
946
+
947
+
948
+
949 949
 
950 950
 (defmethod noop ((mb imap-mailbox))
951 951
   ;; just poke the server... keeping it awake and checking for
... ...
@@ -969,15 +969,15 @@
969 969
 
970 970
 (defmethod unique-id ((pb pop-mailbox) &optional message)
971 971
   ;; if message is given, return the unique id of that
972
-  ;; message, 
972
+  ;; message,
973 973
   ;; if message is not given then return a list of lists:
974 974
   ;;  (message  unique-id)
975 975
   ;; for all messages not marked as deleted
976 976
   ;;
977 977
   (if* message
978 978
      then (let ((res (send-pop-command-get-results pb
979
-						   (format nil 
980
-							   "UIDL ~d" 
979
+						   (format nil
980
+							   "UIDL ~d"
981 981
 							   message))))
982 982
 	    (cadr res))
983 983
      else ; get all of them
... ...
@@ -987,26 +987,26 @@
987 987
 		 mnum
988 988
 		 mid
989 989
 		 (next 0))
990
-		      
991
-		
990
+
991
+
992 992
 	    (let ((coll))
993 993
 	      (loop
994
-		(multiple-value-setq (kind mnum next) 
994
+		(multiple-value-setq (kind mnum next)
995 995
 		  (get-next-token res next end))
996
-		
996
+
997 997
 		(if* (eq :eof kind) then (return))
998
-		
998
+
999 999
 		(if* (not (eq :number kind))
1000 1000
 		   then ; hmm. bogus
1001 1001
 			(po-error :unexpected
1002 1002
 				  :format-control "uidl returned illegal message number in ~s"
1003 1003
 				  :format-arguments (list res)))
1004
-		
1004
+
1005 1005
 		; now get message id
1006
-		
1006
+
1007 1007
 		(multiple-value-setq (kind mid next)
1008 1008
 		    (get-next-token res next end))
1009
-		
1009
+
1010 1010
 		(if* (eq :number kind)
1011 1011
 		   then ; looked like a number to the tokenizer,
1012 1012
 			; make it a string to be consistent
... ...
@@ -1016,43 +1016,43 @@
1016 1016
 			(po-error :unexpected
1017 1017
 				  :format-control "uidl returned illegal message id in ~s"
1018 1018
 				  :format-arguments (list res)))
1019
-		
1019
+
1020 1020
 		(push (list mnum mid) coll))
1021
-	      
1021
+
1022 1022
 	      (nreverse coll)))))
1023 1023
 
1024 1024
 (defmethod top-lines ((pb pop-mailbox) message lines)
1025 1025
   ;; return the header and the given number of top lines of the message
1026
-  
1026
+
1027 1027
   (let ((res (send-pop-command-get-results pb
1028
-					   (format nil 
1028
+					   (format nil
1029 1029
 						   "TOP ~d ~d"
1030 1030
 						   message
1031 1031
 						   lines)
1032 1032
 					   t ; extra
1033 1033
 					   )))
1034 1034
     res))
1035
-			     
1036
-			
1035
+
1036
+
1037 1037
 
1038 1038
 
1039 1039
 (defmethod reset-mailbox ((pb pop-mailbox))
1040 1040
   ;; undo's deletes
1041 1041
   (send-pop-command-get-results pb "RSET")
1042 1042
   )
1043
-						   
1043
+
1044 1044
 
1045 1045
 
1046 1046
 (defun check-for-success (mb command count extra comment command-string )
1047 1047
   (declare (ignore mb count extra))
1048 1048
   (if* (not (eq command :ok))
1049 1049
      then (po-error :error-response
1050
-		    :format-control "imap ~a failed" 
1050
+		    :format-control "imap ~a failed"
1051 1051
 		    :format-arguments (list command-string)
1052 1052
 		    :server-string comment)))
1053 1053
 
1054
-  
1055
-			    
1054
+
1055
+
1056 1056
 
1057 1057
 
1058 1058
 (defmethod mailbox-list ((mb imap-mailbox) &key (reference "") (pattern ""))
... ...
@@ -1067,17 +1067,17 @@
1067 1067
 					   mb command count extra
1068 1068
 					   comment)))
1069 1069
 			      #'(lambda (mb command count extra comment)
1070
-				  (check-for-success 
1071
-				   mb command count extra 
1070
+				  (check-for-success
1071
+				   mb command count extra
1072 1072
 				   comment "list")))
1073
-    
1073
+
1074 1074
     ;; the car of each list is a set of keywords, make that so
1075 1075
     (dolist (rr res)
1076 1076
       (setf (car rr) (mapcar #'kwd-intern (car rr))))
1077
-    
1077
+
1078 1078
     res
1079
-				
1080
-  
1079
+
1080
+
1081 1081
     ))
1082 1082
 
1083 1083
 
... ...
@@ -1088,8 +1088,8 @@
1088 1088
 			    (format nil "create ~s" mailbox-name)
1089 1089
 			    #'handle-untagged-response
1090 1090
 			    #'(lambda (mb command count extra comment)
1091
-				  (check-for-success 
1092
-				   mb command count extra 
1091
+				  (check-for-success
1092
+				   mb command count extra
1093 1093
 				   comment "create")))
1094 1094
   t)
1095 1095
 
... ...
@@ -1101,28 +1101,28 @@
1101 1101
 			    (format nil "delete ~s" mailbox-name)
1102 1102
 			    #'handle-untagged-response
1103 1103
 			    #'(lambda (mb command count extra comment)
1104
-				  (check-for-success 
1105
-				   mb command count extra 
1104
+				  (check-for-success
1105
+				   mb command count extra
1106 1106
 				   comment "delete"))))
1107 1107
 
1108 1108
 (defmethod rename-mailbox ((mb imap-mailbox) old-mailbox-name new-mailbox-name)
1109 1109
   ;; create a mailbox name of the given name.
1110 1110
   ;; use mailbox-separator if you want to create a hierarchy
1111 1111
   (send-command-get-results mb
1112
-			    (format nil "rename ~s ~s" 
1112
+			    (format nil "rename ~s ~s"
1113 1113
 				    old-mailbox-name
1114 1114
 				    new-mailbox-name)
1115 1115
 			    #'handle-untagged-response
1116 1116
 			    #'(lambda (mb command count extra comment)
1117
-				  (check-for-success 
1118
-				   mb command count extra 
1117
+				  (check-for-success
1118
+				   mb command count extra
1119 1119
 				   comment
1120 1120
 				   "rename"))))
1121 1121
 
1122 1122
 
1123 1123
 
1124 1124
 (defmethod alter-flags ((mb imap-mailbox)
1125
-			messages &key (flags nil flags-p) 
1125
+			messages &key (flags nil flags-p)
1126 1126
 				      add-flags remove-flags
1127 1127
 				      silent uid)
1128 1128
   ;;
... ...
@@ -1136,15 +1136,15 @@
1136 1136
      elseif remove-flags
1137 1137
        then (setq cmd "-flags" val remove-flags)
1138 1138
        else (return-from alter-flags nil))
1139
-    
1139
+
1140 1140
     (if* (atom val) then (setq val (list val)))
1141
-    
1141
+
1142 1142
     (send-command-get-results mb
1143 1143
 			      (format nil "~astore ~a ~a~a ~a"
1144 1144
 				      (if* uid then "uid " else "")
1145 1145
 				      (message-set-string messages)
1146 1146
 				      cmd
1147
-				      (if* silent 
1147
+				      (if* silent
1148 1148
 					 then ".silent"
1149 1149
 					 else "")
1150 1150
 				      (if* val
... ...
@@ -1152,17 +1152,17 @@
1152 1152
 					 else "()"))
1153 1153
 			      #'(lambda (mb command count extra comment)
1154 1154
 				  (if* (eq command :fetch)
1155
-				     then (push (list count 
1155
+				     then (push (list count
1156 1156
 						      (convert-flags-plist
1157 1157
 						       extra))
1158 1158
 						res)
1159 1159
 				     else (handle-untagged-response
1160 1160
 					   mb command count extra
1161 1161
 					   comment)))
1162
-			      
1162
+
1163 1163
 			      #'(lambda (mb command count extra comment)
1164
-				  (check-for-success 
1165
-				   mb command count extra 
1164
+				  (check-for-success
1165
+				   mb command count extra
1166 1166
 				   comment "store")))
1167 1167
     res))
1168 1168
 
... ...
@@ -1170,7 +1170,7 @@
1170 1170
 (defun message-set-string (messages)
1171 1171
   ;; return a string that describes the messages which may be a
1172 1172
   ;; single number or a sequence of numbers
1173
-  
1173
+
1174 1174
   (if* (atom messages)
1175 1175
      then (format nil "~a" messages)
1176 1176
      else (if* (and (consp messages)
... ...
@@ -1186,16 +1186,16 @@
1186 1186
 			 then (format str
1187 1187
 				      "~a:~a" (cadr msg) (caddr msg))
1188 1188
 			 else (po-error :syntax-error
1189
-					:format-control "bad message list ~s" 
1189
+					:format-control "bad message list ~s"
1190 1190
 					:format-arguments (list msg)))
1191 1191
 		      (setq precomma t))
1192 1192
 		    (get-output-stream-string str)))))
1193
-				   
1194
-				   
1195
-				   
1196
-			      
1197
-					      
1198
-     
1193
+
1194
+
1195
+
1196
+
1197
+
1198
+
1199 1199
 (defmethod expunge-mailbox ((mb imap-mailbox))
1200 1200
   ;; remove messages marked as deleted
1201 1201
   (let (res)
... ...
@@ -1209,25 +1209,25 @@
1209 1209
 					   mb command count extra
1210 1210
 					   comment)))
1211 1211
 			      #'(lambda (mb command count extra comment)
1212
-				  (check-for-success 
1213
-				   mb command count extra 
1212
+				  (check-for-success
1213
+				   mb command count extra
1214 1214
 				   comment "expunge")))
1215 1215
     (nreverse res)))
1216
-    
1217
-    
1218
-	    
1216
+
1217
+
1218
+
1219 1219
 (defmethod close-mailbox ((mb imap-mailbox))
1220 1220
   ;; remove messages marked as deleted
1221 1221
   (send-command-get-results mb
1222 1222
 			    "close"
1223 1223
 			    #'handle-untagged-response
1224
-			      
1224
+
1225 1225
 			    #'(lambda (mb command count extra comment)
1226
-				(check-for-success 
1227
-				 mb command count extra 
1226
+				(check-for-success
1227
+				 mb command count extra
1228 1228
 				 comment "close")))
1229 1229
   t)
1230
-  
1230
+
1231 1231
 
1232 1232
 
1233 1233
 (defmethod copy-to-mailbox ((mb imap-mailbox) message-list destination
... ...
@@ -1239,8 +1239,8 @@
1239 1239
 				    destination)
1240 1240
 			    #'handle-untagged-response
1241 1241
 			    #'(lambda (mb command count extra comment)
1242
-				(check-for-success 
1243
-				 mb command count extra 
1242
+				(check-for-success
1243
+				 mb command count extra
1244 1244
 				 comment "copy")))
1245 1245
   t)
1246 1246
 
... ...
@@ -1250,7 +1250,7 @@
1250 1250
 (defmethod search-mailbox ((mb imap-mailbox) search-expression &key uid)
1251 1251
   (let (res)
1252 1252
     (send-command-get-results mb
1253
-			      (format nil "~asearch ~a" 
1253
+			      (format nil "~asearch ~a"
1254 1254
 				      (if* uid then "uid " else "")
1255 1255
 				      (build-search-string search-expression))
1256 1256
 			      #'(lambda (mb command count extra comment)
... ...
@@ -1260,12 +1260,12 @@
1260 1260
 					   mb command count extra
1261 1261
 					   comment)))
1262 1262
 			      #'(lambda (mb command count extra comment)
1263
-				  (check-for-success 
1264
-				   mb command count extra 
1263
+				  (check-for-success
1264
+				   mb command count extra
1265 1265
 				   comment "search")))
1266 1266
     res))
1267
-    
1268
-		       
1267
+
1268
+
1269 1269
 (defmacro defsearchop (name &rest operands)
1270 1270
   (if* (null operands)
1271 1271
      then `(setf (get ',name 'imap-search-no-args) t)
... ...
@@ -1323,12 +1323,12 @@
1323 1323
   ;;
1324 1324
   (labels ((and-ify (srch str)
1325 1325
 	     (let ((spaceout nil))
1326
-	       (dolist (xx srch) 
1326
+	       (dolist (xx srch)
1327 1327
 		 (if* spaceout then (format str " "))
1328 1328
 		 (bss-int xx str)
1329 1329
 		 (setq spaceout t))))
1330 1330
 	   (or-ify (srch str)
1331
-	     ; only binary or allowed in imap but we support n-ary 
1331
+	     ; only binary or allowed in imap but we support n-ary
1332 1332
 	     ; or in this interface
1333 1333
 	     (if* (null (cdr srch))
1334 1334
 		then (bss-int (car srch) str)
... ...
@@ -1352,12 +1352,12 @@
1352 1352
 		 ((null xsrch))
1353 1353
 	       (if* (integerp val)
1354 1354
 		  then (format str "~s" val)
1355
-		elseif (and (consp val) 
1355
+		elseif (and (consp val)
1356 1356
 			    (eq :seq (car val))
1357 1357
 			    (eq 3 (length val)))
1358 1358
 		  then (format str "~s:~s" (cadr val) (caddr val))
1359 1359
 		  else (po-error :syntax-error
1360
-				 :format-control "illegal set format ~s" 
1360
+				 :format-control "illegal set format ~s"
1361 1361
 				 :format-arguments (list val)))
1362 1362
 	       (if* (cdr xsrch) then (format str ","))))
1363 1363
 	   (arg-process (str args arginfo)
... ...
@@ -1372,7 +1372,7 @@
1372 1372
 		  ; print it as a string
1373 1373
 		  (format str " \"~a\"" (car x-args)))
1374 1374
 		 (:date
1375
-		  
1375
+
1376 1376
 		  (if* (integerp val)
1377 1377
 		     then (setq val (universal-time-to-rfc822-date
1378 1378
 				     val))
... ...
@@ -1383,34 +1383,34 @@
1383 1383
 		  ;; val is now a string
1384 1384
 		  (format str " ~s" val))
1385 1385
 		 (:number
1386
-		  
1386
+
1387 1387
 		  (if* (not (integerp val))
1388 1388
 		     then (po-error :syntax-error
1389
-				    :format-control "illegal value for number in search ~s" 
1389
+				    :format-control "illegal value for number in search ~s"
1390 1390
 				    :format-arguments (list val)))
1391 1391
 		  (format str " ~s" val))
1392 1392
 		 (:flag
1393
-		  
1393
+
1394 1394
 		  ;; should be a symbol in the kwd package
1395 1395
 		  (setq val (string val))
1396 1396
 		  (format str " ~s" val))
1397 1397
 		 (:messageset
1398
-		  (if* (numberp val) 
1398
+		  (if* (numberp val)
1399 1399
 		     then (format str " ~s" val)
1400 1400
 		   elseif (consp val)
1401 1401
 		     then (set-ify val str)
1402 1402
 		     else (po-error :syntax-error
1403
-				    :format-control "illegal message set ~s" 
1403
+				    :format-control "illegal message set ~s"
1404 1404
 				    :format-arguments (list val))))
1405
-		  
1405
+
1406 1406
 		 ))))
1407
-    
1407
+
1408 1408
     (if* (symbolp search)
1409 1409
        then (if* (get search 'imap-search-no-args)
1410 1410
 	       then (format str "~a"  (string-upcase
1411 1411
 				       (string search)))
1412 1412
 	       else (po-error :syntax-error
1413
-			      :format-control "illegal search word: ~s" 
1413
+			      :format-control "illegal search word: ~s"
1414 1414
 			      :format-arguments (list search)))
1415 1415
      elseif (consp search)
1416 1416
        then (case (car search)
... ...
@@ -1425,46 +1425,46 @@
1425 1425
 		      then (bss-int (cadr search) str)
1426 1426
 		      else (or-ify (cdr search)  str)))
1427 1427
 	      (not (if* (not (eql (length search) 2))
1428
-		      then (po-error :syntax-error 
1429
-				     :format-control "not takes one argument: ~s" 
1428
+		      then (po-error :syntax-error
1429
+				     :format-control "not takes one argument: ~s"
1430 1430
 				     :format-arguments (list search)))
1431 1431
 		   (format str "not (" )
1432 1432
 		   (bss-int (cadr search) str)
1433 1433
 		   (format str ")"))
1434 1434
 	      (:seq
1435 1435
 	       (set-ify (list search) str))
1436
-	      (t (let (arginfo) 
1436
+	      (t (let (arginfo)
1437 1437
 		   (if* (and (symbolp (car search))
1438 1438
 			     (setq arginfo (get (car search)
1439 1439
 						'imap-search-args)))
1440
-		      then 
1440
+		      then
1441 1441
 			   (format str "~a" (string-upcase
1442 1442
 					     (string (car search))))
1443 1443
 			   (if* (not (equal (length (cdr search))
1444 1444
 					    (length arginfo)))
1445
-			      then (po-error :syntax-error 
1446
-					     :format-control "wrong number of arguments to ~s" 
1445
+			      then (po-error :syntax-error
1446
+					     :format-control "wrong number of arguments to ~s"
1447 1447
 					     :format-arguments search))
1448
-			   
1448
+
1449 1449
 			   (arg-process str (cdr search) arginfo)
1450
-			   
1450
+
1451 1451
 		    elseif (integerp (car search))
1452 1452
 		      then (set-ify search str)
1453
-		      else (po-error :syntax-error 
1454
-				     :format-control "Illegal form ~s in search string" 
1453
+		      else (po-error :syntax-error
1454
+				     :format-control "Illegal form ~s in search string"
1455 1455
 				     :format-arguments (list search))))))
1456 1456
      elseif (integerp search)
1457 1457
        then ;  a message number
1458 1458
 	    (format str "~s" search)
1459 1459
        else (po-error :syntax-error
1460
-		      :format-control "Illegal form ~s in search string" 
1460
+		      :format-control "Illegal form ~s in search string"
1461 1461
 		      :format-arguments (list search)))))
1462 1462
 
1463 1463
 
1464 1464
 
1465 1465
 
1466 1466
 
1467
-(defun parse-mail-header (text)  
1467
+(defun parse-mail-header (text)
1468 1468
   ;; given the partial text of a mail message that includes
1469 1469
   ;; at least the header part, return an assoc list of
1470 1470
   ;; (header . content)  items
... ...
@@ -1482,24 +1482,24 @@
1482 1482
 	       ;; :start - beginning of header value, header and
1483 1483
 	       ;;	         value set
1484 1484
 	       ;; :continue - continuation of previous header line
1485
-	     
1486
-		       
1485
+
1486
+
1487 1487
 	       (let ((state 1)
1488 1488
 		     beginv  ; charpos beginning value
1489 1489
 		     beginh  ; charpos beginning header
1490 1490
 		     ch
1491 1491
 		     )
1492 1492
 		 (tagbody again
1493
-		   
1493
+
1494 1494
 		   (return-from next-header-line
1495
-		     
1495
+
1496 1496
 		     (loop  ; for each character
1497
-		       
1497
+
1498 1498
 		       (if* (>= next end)
1499 1499
 			  then (return :eof))
1500
-		 
1500
+
1501 1501
 		       (setq ch (char text next))
1502
-		       (if* (eq ch #\return) 
1502
+		       (if* (eq ch #\return)
1503 1503
 			  thenret  ; ignore return, (handle following linefeed)
1504 1504
 			  else (case state
1505 1505
 				 (1 ; no characters seen
... ...
@@ -1543,7 +1543,7 @@
1543 1543
 				 (4 ; looking for the end of the value
1544 1544
 				  (if* (eq ch #\linefeed)
1545 1545
 				     then (setq value
1546
-					    (subseq text beginv 
1546
+					    (subseq text beginv
1547 1547
 						    (if* (eq #\return
1548 1548
 							     (char text
1549 1549
 								   (1- next)))
... ...
@@ -1554,9 +1554,9 @@
1554 1554
 						     then :start
1555 1555
 						     else :continue))))))
1556 1556
 		       (incf next)))))))
1557
-					 
1558
-	       
1559
-    
1557
+
1558
+
1559
+
1560 1560
       (loop ; for each header line
1561 1561
 	(setq header nil)
1562 1562
 	(if* (eq :eof (setq kind (next-header-line)))
... ...
@@ -1568,7 +1568,7 @@
1568 1568
 	      then ; append to previous one
1569 1569
 		   (setf (cdr (car headers))
1570 1570
 		     (concatenate 'string (cdr (car headers))
1571
-				  " " 
1571
+				  " "
1572 1572
 				  value)))))))
1573 1573
     (values headers
1574 1574
 	    (subseq text next end))))
... ...
@@ -1581,7 +1581,7 @@
1581 1581
   ;; a pop server
1582 1582
   ;;
1583 1583
   (let ((headers (parse-mail-header text)))
1584
-  
1584
+
1585 1585
     (make-envelope
1586 1586
      :date     (cdr (assoc "date" headers :test #'equalp))
1587 1587
      :subject  (cdr (assoc "subject" headers :test #'equalp))
... ...
@@ -1595,27 +1595,27 @@
1595 1595
      :message-id (cdr (assoc "message-id" headers :test #'equalp))
1596 1596
      )))
1597 1597
 
1598
-		  
1599
-	      
1600
-				 
1601
-	      
1602 1598
 
1603 1599
 
1604 1600
 
1605 1601
 
1606
-    
1602
+
1603
+
1604
+
1605
+
1606
+
1607 1607
 (defmethod get-and-parse-from-imap-server ((mb imap-mailbox))
1608 1608
   ;; read the next line and parse it
1609 1609
   ;;
1610 1610
   ;;
1611 1611
   (multiple-value-bind (line count)
1612 1612
       (get-line-from-server mb)
1613
-    (if* *debug-imap* 
1613
+    (if* *debug-imap*
1614 1614
        then (format t "from server: ")
1615 1615
 	    (dotimes (i count)(write-char (schar line i)))
1616 1616
 	    (terpri)
1617 1617
 	    (force-output))
1618
-    
1618
+
1619 1619
     (parse-imap-response line count)
1620 1620
     ))
1621 1621
 
... ...
@@ -1625,22 +1625,22 @@
1625 1625
   ;; read the next line from the pop server
1626 1626
   ;;
1627 1627
   ;; return 3 values:
1628
-  ;;   :ok or :error 
1628
+  ;;   :ok or :error
1629 1629
   ;;   a list of rest of the tokens on the line
1630 1630
   ;;   the whole line after the +ok or -err
1631 1631
 
1632 1632
   (multiple-value-bind (line count)
1633 1633
       (get-line-from-server mb)
1634
-    
1635
-    (if* *debug-imap* 
1634
+
1635
+    (if* *debug-imap*
1636 1636
        then (format t "from server: " count)
1637 1637
 	    (dotimes (i count)(write-char (schar line i)))
1638 1638
 	    (terpri))
1639
-    
1639
+
1640 1640
     (parse-pop-response line count)))
1641 1641
 
1642
-  
1643
-  
1642
+
1643
+
1644 1644
 ;; Parse and return the data from each line
1645 1645
 ;; values returned
1646 1646
 ;;  tag -- either a string or the symbol :untagged
... ...
@@ -1648,7 +1648,7 @@
1648 1648
 ;;  count -- a number which preceeded the command, or nil if
1649 1649
 ;;	     there wasn't a command
1650 1650
 ;;  bracketted - a list of objects found in []'s after the command
1651
-;;            or in ()'s after the command  or sometimes just 
1651
+;;            or in ()'s after the command  or sometimes just
1652 1652
 ;;	      out in the open after the command (like the search)
1653 1653
 ;;  comment  -- the whole of the part after the command
1654 1654
 ;;
... ...
@@ -1656,25 +1656,25 @@
1656 1656
   (let (kind value next
1657 1657
 	tag count command extra-data
1658 1658
 	comment)
1659
-    
1659
+
1660 1660
     ;; get tag
1661 1661
     (multiple-value-setq (kind value next)
1662 1662
       (get-next-token line 0 end))
1663
-    
1663
+
1664 1664
     (case kind
1665 1665
       (:string (setq tag (if* (equal value "*")
1666 1666
 			    then :untagged
1667 1667
 			    else value)))
1668 1668
       (t (po-error :unexpected
1669
-		   :format-control "Illegal tag on response: ~s" 
1669
+		   :format-control "Illegal tag on response: ~s"
1670 1670
 		   :format-arguments (list (subseq line 0 count))
1671 1671
 		   :server-string (subseq line 0 end)
1672 1672
 		   )))
1673
-      
1673
+
1674 1674
     ;; get command
1675 1675
     (multiple-value-setq (kind value next)
1676 1676
       (get-next-token line next end))
1677
-      
1677
+
1678 1678
     (tagbody again
1679 1679
       (case kind
1680 1680
 	(:number (setq count value)
... ...
@@ -1682,18 +1682,18 @@
1682 1682
 		   (get-next-token line next end))
1683 1683
 		 (go again))
1684 1684
 	(:string (setq command (kwd-intern value)))
1685
-	(t (po-error :unexpected 
1686
-		     :format-control "Illegal command on response: ~s" 
1685
+	(t (po-error :unexpected
1686
+		     :format-control "Illegal command on response: ~s"
1687 1687
 		     :format-arguments (list (subseq line 0 count))
1688 1688
 		     :server-string (subseq line 0 end)))))
1689 1689
 
1690 1690
     (setq comment (subseq line next end))
1691
-    
1691
+
1692 1692
     ;; now the part after the command... this gets tricky
1693 1693
     (loop
1694 1694
       (multiple-value-setq (kind value next)
1695 1695
 	(get-next-token line next end))
1696
-      
1696
+
1697 1697
       (case kind
1698 1698
 	((:lbracket :lparen)
1699 1699
 	 (multiple-value-setq (kind value next)
... ...
@@ -1705,7 +1705,7 @@
1705 1705
 	((:number :string :nil) (push value extra-data))
1706 1706
 	(t  ; should never happen
1707 1707
 	 (return)))
1708
-      
1708
+
1709 1709
       (if* (not (member command '(:list :search) :test #'eq))
1710 1710
 	 then ; only one item returned
1711 1711
 	      (setq extra-data (car extra-data))
... ...
@@ -1713,10 +1713,10 @@
1713 1713
 
1714 1714
     (if* (member command '(:list :search) :test #'eq)
1715 1715
        then (setq extra-data (nreverse extra-data)))
1716
-    
1717
-      
1716
+
1717
+
1718 1718
     (values tag command count extra-data comment)))
1719
-      
1719
+
1720 1720
 
1721 1721
 
1722 1722
 (defun get-next-sexpr (line start end)
... ...
@@ -1725,14 +1725,14 @@
1725 1725
   ;;   kind -- :sexpr  or :rparen or :rbracket
1726 1726
   ;;   value - the sexpr value
1727 1727
   ;;   next  - next charpos to scan
1728
-  ;;  
1728
+  ;;
1729 1729
   (let ( kind value next)
1730 1730
     (multiple-value-setq (kind value next) (get-next-token line start end))
1731
-    
1731
+
1732 1732
     (case kind
1733 1733
       ((:string :number :nil)
1734 1734
        (values :sexpr value next))
1735
-      (:eof (po-error :syntax-error 
1735
+      (:eof (po-error :syntax-error
1736 1736
 		      :format-control "eof inside sexpr"))
1737 1737
       ((:lbracket :lparen)
1738 1738
        (let (res)
... ...
@@ -1741,7 +1741,7 @@
1741 1741
 	     (get-next-sexpr line next end))
1742 1742
 	   (case kind
1743 1743
 	     (:sexpr (push value res))
1744
-	     ((:rparen :rbracket) 
1744
+	     ((:rparen :rbracket)
1745 1745
 	      (return (values :sexpr (nreverse res) next)))
1746 1746
 	     (t (po-error :syntax-error
1747 1747
 			  :format-control "bad sexpression"))))))
... ...
@@ -1753,7 +1753,7 @@
1753 1753
 
1754 1754
 (defun parse-pop-response (line end)
1755 1755
   ;; return 3 values:
1756
-  ;;   :ok or :error 
1756
+  ;;   :ok or :error
1757 1757
   ;;   a list of rest of the tokens on the line, the tokens
1758 1758
   ;;	 being either strings or integers
1759 1759
   ;;   the whole line after the +ok or -err
... ...
@@ -1761,59 +1761,59 @@
1761 1761
   (let (res lineres result)
1762 1762
     (multiple-value-bind (kind value next)
1763 1763
 	(get-next-token line 0 end)
1764
-    
1764
+
1765 1765
       (case kind
1766
-	(:string (setq result (if* (equal "+OK" value) 
1766
+	(:string (setq result (if* (equal "+OK" value)
1767 1767
 				 then :ok
1768 1768
 				 else :error)))
1769 1769
 	(t (po-error :unexpected
1770
-		     :format-control "bad response from server" 
1770
+		     :format-control "bad response from server"
1771 1771
 		     :server-string (subseq line 0 end))))
1772
-    
1772
+
1773 1773
       (setq lineres (subseq line next end))
1774 1774
 
1775 1775
       (loop
1776 1776
 	(multiple-value-setq (kind value next)
1777 1777
 	  (get-next-token line next end))
1778
-	
1778
+
1779 1779
 	(case kind
1780 1780
 	  (:eof (return))
1781 1781
 	  ((:string :number) (push value res))))
1782
-      
1782
+
1783 1783
       (values result (nreverse res) lineres))))
1784
-    
1785
-	
1786
-    
1787
-    
1788
-    
1789
-    
1790
-      
1791
-      
1792
-			 
1793
-    
1784
+
1785
+
1786
+
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794 1794
 (defparameter *char-to-kind*
1795 1795
     (let ((arr (make-array 256 :initial-element nil)))
1796
-      
1796
+
1797 1797
       (do ((i #.(char-code #\0) (1+ i)))
1798 1798
 	  ((> i #.(char-code #\9)))
1799 1799
 	(setf (aref arr i) :number))
1800
-      
1800
+
1801 1801
       (setf (aref arr #.(char-code #\space)) :space)
1802 1802
       (setf (aref arr #.(char-code #\tab)) :space)
1803 1803
       (setf (aref arr #.(char-code #\return)) :space)
1804 1804
       (setf (aref arr #.(char-code #\linefeed)) :space)
1805
-      
1805
+
1806 1806
       (setf (aref arr #.(char-code #\[)) :lbracket)
1807 1807
       (setf (aref arr #.(char-code #\])) :rbracket)
1808 1808
       (setf (aref arr #.(char-code #\()) :lparen)
1809 1809
       (setf (aref arr #.(char-code #\))) :rparen)
1810 1810
       (setf (aref arr #.(char-code #\")) :dquote)
1811
-      
1811
+
1812 1812
       (setf (aref arr #.(char-code #\^b)) :big-string) ; our own invention
1813
-      
1813
+
1814 1814
       arr))
1815
-	
1816
-      
1815
+
1816
+
1817 1817
 (defun get-next-token (line start end)
1818 1818
   ;; scan past whitespace for the next token
1819 1819
   ;; return three values:
... ...
@@ -1823,17 +1823,17 @@
1823 1823
   ;;  next:   the character pos to start scanning for the next token
1824 1824
   ;;
1825 1825
   (let (ch chkind colstart (count 0) (state :looking)
1826
-	collector right-bracket-is-normal) 
1827
-    (loop 
1826
+	collector right-bracket-is-normal)
1827
+    (loop
1828 1828
       ; pick up the next character
1829 1829
       (if* (>= start end)
1830 1830
 	 then (if* (eq state :looking)
1831 1831
 		 then (return (values :eof nil start))
1832 1832
 		 else (setq ch #\space))
1833 1833
 	 else (setq ch (schar line start)))
1834
-      
1834
+
1835 1835
       (setq chkind (aref *char-to-kind* (char-code ch)))
1836
-      
1836
+
1837 1837
       (case state
1838 1838
 	(:looking
1839 1839
 	 (case chkind
... ...
@@ -1844,9 +1844,9 @@
1844 1844
 	   ((:lbracket :lparen :rbracket :rparen)
1845 1845
 	    (return (values chkind nil (1+ start))))
1846 1846
 	   (:dquote
1847
-	    (setq collector (make-array 10 
1847
+	    (setq collector (make-array 10
1848 1848
 					:element-type 'character
1849
-					:adjustable t 
1849
+					:adjustable t
1850 1850
 					:fill-pointer 0))
1851 1851
 	    (setq state :qstring))
1852 1852
 	   (:big-string
... ...
@@ -1856,11 +1856,11 @@
1856 1856
 	      (setq state :literal))))
1857 1857
 	(:number
1858 1858
 	 (case chkind
1859
-	   ((:space :lbracket :lparen :rbracket :rparen 
1859
+	   ((:space :lbracket :lparen :rbracket :rparen
1860 1860
 	     :dquote) ; end of number
1861 1861
 	    (return (values :number count  start)))
1862 1862
 	   (:number ; more number
1863
-	    (setq count (+ (* count 10) 
1863
+	    (setq count (+ (* count 10)
1864 1864
 			   (- (char-code ch) #.(char-code #\0)))))
1865 1865
 	   (t ; turn into an literal
1866 1866
 	    (setq state :literal))))
... ...
@@ -1875,7 +1875,7 @@
1875 1875
 			 then (return (values :nil
1876 1876
 					      nil
1877 1877
 					      start))
1878
-			 else (return (values :string 
1878
+			 else (return (values :string
1879 1879
 					      seq
1880 1880
 					      start))))))
1881 1881
 	   (t (if* (eq chkind :lbracket)
... ...
@@ -1898,7 +1898,7 @@
1898 1898
 					:format-control "eof in string returned"))
1899 1899
 		      (setq ch (schar line start)))
1900 1900
 	      (vector-push-extend ch collector)
1901
-	      
1901
+
1902 1902
 	      (if* (>= start end)
1903 1903
 		 then ; we overran the end of the input
1904 1904
 		      (po-error :unexpected
... ...
@@ -1909,17 +1909,17 @@
1909 1909
 	 (case chkind
1910 1910
 	   (:big-string
1911 1911
 	    ;; end of string
1912
-	    (return (values :string 
1912
+	    (return (values :string
1913 1913
 			    (subseq line colstart start)
1914 1914
 			    (1+ start))))
1915 1915
 	   (t nil)))
1916
-	
1917
-		      
1916
+
1917
+
1918 1918
 	)
1919
-      
1919
+
1920 1920
       (incf start))))
1921
-	    
1922
-	    
1921
+
1922
+
1923 1923
 
1924 1924
 ;  this used to be exported from the excl package
1925 1925
 #+(version>= 6 0)
... ...
@@ -1932,7 +1932,7 @@
1932 1932
      then (kwd-intern form)
1933 1933
      else (mapcar #'kwd-intern-possible-list form)))
1934 1934
 
1935
-      
1935
+
1936 1936
 (defun kwd-intern (string)
1937 1937
   ;; convert the string to the current preferred case
1938 1938
   ;; and then intern
... ...
@@ -1941,36 +1941,36 @@
1941 1941
 	      :case-insensitive-lower) (string-downcase string))
1942 1942
 	    (t (string-upcase string)))
1943 1943
 	  *keyword-package*))
1944
-      
1945
-      
1946
-      
1947
-    
1948
-      
1949
-      
1950
-	
1951
-      
1952
-    
1953
-
1954
-  
1955
-    
1956
-    
1957
-  
1944
+
1945
+
1946
+
1947
+
1948
+
1949
+
1950
+
1951
+
1952
+
1953
+
1954
+
1955
+
1956
+
1957
+
1958 1958
 ;; low level i/o to server
1959 1959
 
1960 1960
 (defun get-line-from-server (mailbox)
1961 1961
   ;; Return two values:  a buffer and a character count.
1962 1962
   ;; The character count includes up to but excluding the cr lf that
1963 1963
   ;;  was read from the socket.
1964
-  ;; 
1964
+  ;;
1965 1965
   (let* ((buff (get-line-buffer 0))
1966 1966
 	 (len  (length buff))
1967 1967
 	 (i 0)
1968 1968
 	 (p (post-office-socket mailbox))
1969 1969
 	 (ch nil)
1970
-	 (whole-count) 
1970
+	 (whole-count)
1971 1971
 	 )
1972 1972
 
1973
-    (handler-case 
1973
+    (handler-case
1974 1974
 	(flet ((grow-buffer (size)
1975 1975
 		 (let ((newbuff (get-line-buffer size)))
1976 1976
 		   (dotimes (j i)
... ...
@@ -1978,16 +1978,16 @@
1978 1978
 		   (free-line-buffer buff)
1979 1979
 		   (setq buff newbuff)
1980 1980
 		   (setq len (length buff)))))
1981
-	     
1981
+
1982 1982
 	  ;; increase the buffer to at least size
1983 1983
 	  ;; this is somewhat complex to ensure that we aren't doing
1984
-	  ;; buffer allocation within the with-timeout form, since 
1985
-	  ;; that could trigger a gc which could then cause the 
1984
+	  ;; buffer allocation within the with-timeout form, since
1985
+	  ;; that could trigger a gc which could then cause the
1986 1986
 	  ;; with-timeout form to expire.
1987 1987
 	  (loop
1988
-      
1988
+
1989 1989
 	    (if* whole-count
1990
-	       then ; we should now read in this may bytes and 
1990
+	       then ; we should now read in this may bytes and
1991 1991
 		    ; append it to this buffer
1992 1992
 		    (multiple-value-bind (ans this-count)
1993 1993
 			(get-block-of-data-from-server mailbox whole-count)
... ...
@@ -1995,7 +1995,7 @@
1995 1995
 		      (if* (> (+ i whole-count 5) len)
1996 1996
 			 then  ; grow the initial buffer
1997 1997
 			      (grow-buffer (+ i whole-count 100)))
1998
-		
1998
+
1999 1999
 		      (dotimes (ind this-count)
2000 2000
 			(setf (schar buff i) (schar ans ind))
2001 2001
 			(incf i))
... ...
@@ -2010,7 +2010,7 @@
2010 2010
 		    (setf (schar buff i) ch)
2011 2011
 		    (incf i))
2012 2012
 
2013
-	    
2013
+
2014 2014
 	    (block timeout
2015 2015
 	      (mp:with-timeout ((timeout mailbox)
2016 2016
 				(po-error :timeout
... ...
@@ -2035,7 +2035,7 @@
2035 2035
 					    (mult 1))
2036 2036
 					(loop
2037 2037
 					  (decf ind)
2038
-					  (if* (< ind 0) 
2038
+					  (if* (< ind 0)
2039 2039
 					     then ; no of the form {nnn}
2040 2040
 						  (return-from count-check))
2041 2041
 					  (setf ch (schar buff ind))
... ...
@@ -2049,7 +2049,7 @@
2049 2049
 						      (char-code ch)
2050 2050
 						      #.(char-code #\9))
2051 2051
 					     then ; is a digit
2052
-						  (setq count 
2052
+						  (setq count
2053 2053
 						    (+ count
2054 2054
 						       (* mult
2055 2055
 							  (- (char-code ch)
... ...
@@ -2057,8 +2057,8 @@
2057 2057
 						  (setq mult (* 10 mult))
2058 2058
 					     else ; invalid form, get out
2059 2059
 						  (return-from count-check)))))))
2060
-					
2061
-		  
2060
+
2061
+
2062 2062
 			  (return-from get-line-from-server
2063 2063
 			    (values buff i))
2064 2064
 		     else ; save character
... ...
@@ -2078,7 +2078,7 @@
2078 2078
 
2079 2079
 (defun get-block-of-data-from-server  (mb count &key save-returns)
2080 2080
   ;; read count bytes from the server returning it in a line buffer object
2081
-  ;; return as a second value the number of characters saved 
2081
+  ;; return as a second value the number of characters saved
2082 2082
   ;; (we drop #\return's so that lines are separated by a #\newline
2083 2083
   ;; like lisp likes).
2084 2084
   ;;
... ...
@@ -2088,16 +2088,16 @@
2088 2088
     (mp:with-timeout ((timeout mb)
2089 2089
 		      (po-error :timeout
2090 2090
 				:format-control "imap server timed out"))
2091
-      
2091
+
2092 2092
       (dotimes (i count)
2093 2093
 	(if* (eq #\return (setf (schar buff ind) (read-char p)))
2094 2094
 	   then (if* save-returns then (incf ind)) ; drop #\returns
2095 2095
 	   else (incf ind)))
2096
-	
2097
-      
2096
+
2097
+
2098 2098
       (values buff ind))))
2099
-      
2100
-    
2099
+
2100
+
2101 2101
 ;;-- reusable line buffers
2102 2102
 
2103 2103
 (defvar *line-buffers* nil)
... ...
@@ -2117,7 +2117,7 @@
2117 2117
 (defun get-line-buffer (size)
2118 2118
   ;; get a buffer of at least size bytes
2119 2119
   (setq size (min size (1- array-total-size-limit)))
2120
-  (let ((found 
2120
+  (let ((found
2121 2121
 	 (with-locked-line-buffers
2122 2122
 	   (dolist (buff *line-buffers*)
2123 2123
 	     (if* (>= (length buff) size)
... ...
@@ -2137,7 +2137,7 @@
2137 2137
     (declare (fixnum i))
2138 2138
     (setf (schar new i) (schar old i))))
2139 2139
 
2140
-  
2140
+
2141 2141
 
2142 2142
   ;;;;;;;
2143 2143
 
... ...
@@ -2158,8 +2158,8 @@
2158 2158
 	     month
2159 2159
 	     )
2160 2160
 	    year)))
2161
-  
2162
-			  
2161
+
2162
+
2163 2163
 
2164 2164
 
2165 2165
 ;; utility
... ...
@@ -2178,5 +2178,3 @@
2178 2178
 	 (progn
2179 2179
 	   ,@body)
2180 2180
        (close-connection ,mb))))
2181
-
2182
-