(elmo-number-set-append-list): Ditto.
(elmo-number-set-append): Ditto.
* elmo-msgdb.el (elmo-msgdb-killed-message-p):
Use `elmo-number-set-member'.
(elmo-living-messages): Ditto.
(elmo-msgdb-set-as-killed): Use `elmo-number-set-append'.
(elmo-msgdb-append-to-killed-list): Use `elmo-number-set-append-list'.
* elmo-imap4.el (elmo-imap4-folder-exists-p): Rewrite.
(elmo-imap4-add-to-cont-list): Abolished.
(elmo-imap4-make-number-set-list): Use `elmo-number-set-append'
instead of elmo-imap4-add-to-cont-list.
* elmo2.el (toplevel): Removed autoload setting for `elmo-imap4-get-connection'.
2000-10-04 Yuuichi Teranishi <teranisi@gohome.org>
+ * elmo-util.el (elmo-number-set-member): New function.
+ (elmo-number-set-append-list): Ditto.
+ (elmo-number-set-append): Ditto.
+
+ * elmo-msgdb.el (elmo-msgdb-killed-message-p):
+ Use `elmo-number-set-member'.
+ (elmo-living-messages): Ditto.
+ (elmo-msgdb-set-as-killed): Use `elmo-number-set-append'.
+ (elmo-msgdb-append-to-killed-list): Use `elmo-number-set-append-list'.
+
+ * elmo-imap4.el (elmo-imap4-folder-exists-p): Rewrite.
+ (elmo-imap4-add-to-cont-list): Abolished.
+ (elmo-imap4-make-number-set-list): Use `elmo-number-set-append'
+ instead of elmo-imap4-add-to-cont-list.
+
* elmo2.el (elmo-msgdb-search): Moved from elmo-msgdb.el.
+ (toplevel): Removed autoload setting for `elmo-imap4-get-connection'.
* elmo-msgdb.el (elmo-msgdb-search): Moved to elmo2.el.
result)))
(defun elmo-imap4-folder-exists-p (spec)
- (let ((session (elmo-imap4-get-session spec))
- response)
- (setq response
- (elmo-imap4-read-response
+ (let ((session (elmo-imap4-get-session spec)))
+ (if (string=
+ (elmo-imap4-session-current-mailbox-internal session)
+ (elmo-imap4-spec-mailbox spec))
+ t
+ (condition-case nil
+ (elmo-imap4-session-select-mailbox
session
- (elmo-imap4-send-command
- session
- (list "status " (elmo-imap4-mailbox (elmo-imap4-spec-mailbox spec))
- " (messages)"))))
- (when (elmo-imap4-response-bye-p response)
- (signal 'elmo-imap4-bye-error
- (list (elmo-imap4-response-error-text response))))
- (elmo-imap4-response-ok-p response)))
+ (elmo-imap4-spec-mailbox spec)
+ 'force)
+ (error nil)))))
(defun elmo-imap4-folder-creatable-p (spec)
t)
(if (bufferp obj)
(or (bobp) (forward-char -1)))))))
-(defun elmo-imap4-add-to-cont-list (cont-list msg)
- (let ((elist cont-list)
- (ret-val cont-list)
- entity found)
- (while (and elist (not found))
- (setq entity (car elist))
- (cond
- ((and (consp entity)
- (eq (+ 1 (cdr entity)) msg))
- (setcdr entity msg)
- (setq found t))
- ((and (integerp entity)
- (eq (+ 1 entity) msg))
- (setcar elist (cons entity msg))
- (setq found t))
- ((or (and (integerp entity) (eq entity msg))
- (and (consp entity)
- (<= (car entity) msg)
- (<= msg (cdr entity)))) ; included
- (setq found t))); noop
- (setq elist (cdr elist)))
- (if (not found)
- (setq ret-val (append cont-list (list msg))))
- ret-val))
-
(defun elmo-imap4-make-number-set-list (msg-list &optional chop-length)
"Make RFC2060's message set specifier from MSG-LIST.
Returns a list of (NUMBER . SET-STRING).
(while (and (not (null msg-list))
(< count chop-length))
(setq cont-list
- (elmo-imap4-add-to-cont-list
+ (elmo-number-set-append
cont-list (car msg-list)))
(incf count)
(setq msg-list (cdr msg-list)))
killed-list))
(defun elmo-msgdb-killed-message-p (killed-list msg)
- (memq msg killed-list))
+ (elmo-number-set-member msg killed-list))
(defun elmo-msgdb-set-as-killed (killed-list msg)
- (elmo-msgdb-append-element killed-list msg))
+ elmo-number-set-append killed-list msg)
(defun elmo-msgdb-append-to-killed-list (folder msgs)
(let ((dir (elmo-msgdb-expand-path folder)))
(elmo-msgdb-killed-list-save
dir
- (nconc (elmo-msgdb-killed-list-load dir)
- msgs))))
+ (elmo-number-set-append-list
+ (elmo-msgdb-killed-list-load dir)
+ msgs))))
(defun elmo-living-messages (messages killed-list)
(if killed-list
(delq nil
(mapcar (lambda (number)
- (unless (memq number killed-list) number))
+ (unless (elmo-number-set-member number killed-list)
+ number))
messages))
messages))
(throw 'loop a))
(setq alist (cdr alist))))))
+;;; Number set defined by OKAZAKI Tetsurou <okazaki@be.to>
+;;
+;; number ::= [0-9]+
+;; beg ::= number
+;; end ::= number
+;; number-range ::= "(" beg " . " end ")" ;; cons cell
+;; number-set-elem ::= number / number-range
+;; number-set ::= "(" *number-set-elem ")" ;; list
+
+(defun elmo-number-set-member (number number-set)
+ "Returns non-nil if NUMBER is an element of NUMBER-SET.
+The value is actuall the tail of SET-LIST whose car contains NUMBER."
+ (or (memq number number-set)
+ (let (found)
+ (while (and number-set (not found))
+ (if (and (consp (car number-set))
+ (and (<= (car (car number-set)) number)
+ (<= number (cdr (car number-set)))))
+ (setq found t)
+ (setq number-set (cdr number-set))))
+ number-set)))
+
+(defun elmo-number-set-append-list (number-set list)
+ "Append LIST of numbers to the NUMBER-SET.
+NUMBER-SET is altered."
+ (let ((appended number-set))
+ (while list
+ (setq appended (elmo-number-set-append appended (car list)))
+ (setq list (cdr list)))
+ appended))
+
+(defun elmo-number-set-append (number-set number)
+ "Append NUMBER to the NUMBER-SET.
+NUMBER-SET is altered."
+ (let ((number-set-1 number-set)
+ found elem)
+ (while (and number-set (not found))
+ (setq elem (car number-set))
+ (cond
+ ((and (consp elem)
+ (eq (+ 1 (cdr elem)) number))
+ (setcdr elem number)
+ (setq found t))
+ ((and (integerp elem)
+ (eq (+ 1 elem) number))
+ (setcar number-set (cons elem number))
+ (setq found t))
+ ((or (and (integerp elem) (eq elem number))
+ (and (consp elem)
+ (<= (car elem) number)
+ (<= number (cdr elem))))
+ (setq found t)))
+ (setq number-set (cdr number-set)))
+ (if (not found)
+ (setq number-set-1 (nconc number-set-1 (list number))))
+ number-set-1))
+
(provide 'elmo-util)
;;; elmo-util.el ends here
(elmo-folder-number-get-spec fld number)))
;; autoloads
-(autoload 'elmo-imap4-get-connection "elmo-imap4")
(autoload 'elmo-nntp-make-groups-hashtb "elmo-nntp")
(autoload 'elmo-nntp-post "elmo-nntp")
(autoload 'elmo-localdir-max-of-folder "elmo-localdir")