From: teranisi Date: Wed, 4 Oct 2000 07:08:07 +0000 (+0000) Subject: * elmo-util.el (elmo-number-set-member): New function. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b2440ad65c48de6922cd501a22998cd1e79629e;p=elisp%2Fwanderlust.git * 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 (toplevel): Removed autoload setting for `elmo-imap4-get-connection'. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 30541cf..c8ff3c0 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,6 +1,22 @@ 2000-10-04 Yuuichi Teranishi + * 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. diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index 7d38d16..b595711 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -567,19 +567,17 @@ BUFFER must be a single-byte buffer." 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) @@ -900,31 +898,6 @@ BUFFER must be a single-byte buffer." (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). @@ -942,7 +915,7 @@ If CHOP-LENGTH is not specified, message set is not chopped." (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))) diff --git a/elmo/elmo-msgdb.el b/elmo/elmo-msgdb.el index f75c98f..7284a0e 100644 --- a/elmo/elmo-msgdb.el +++ b/elmo/elmo-msgdb.el @@ -630,23 +630,25 @@ content of MSGDB is changed." 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)) diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index 56f95b1..6df50f4 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -1606,6 +1606,63 @@ But if optional argument AUTO is non-nil, DEFAULT is returned." (throw 'loop a)) (setq alist (cdr alist)))))) +;;; Number set defined by OKAZAKI Tetsurou +;; +;; 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 diff --git a/elmo/elmo2.el b/elmo/elmo2.el index 0c66741..8359d23 100644 --- a/elmo/elmo2.el +++ b/elmo/elmo2.el @@ -1073,7 +1073,6 @@ Currently works on IMAP4 folder only." (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")