X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=elmo%2Felmo-msgdb.el;h=7364c5cee4a176616724f02672039be89cff80f7;hb=40f5de1a09510d7a28ecc0bef4fea09b5845511f;hp=bfe4b9f444c6058c0946dfbe6eb86d1d209dc66f;hpb=db0c79dbf84aba8cd087793299d734bdbc381051;p=elisp%2Fwanderlust.git diff --git a/elmo/elmo-msgdb.el b/elmo/elmo-msgdb.el index bfe4b9f..7364c5c 100644 --- a/elmo/elmo-msgdb.el +++ b/elmo/elmo-msgdb.el @@ -36,6 +36,7 @@ (require 'elmo-util) (require 'emu) (require 'std11) +(require 'mime) ;;; MSGDB interface. (defun elmo-load-msgdb (path) @@ -52,12 +53,13 @@ msgdb)) (defsubst elmo-msgdb-get-mark (msgdb number) - "Get mark from MSGDB which corresponds to the message with NUMBER." + "Get mark string from MSGDB which corresponds to the message with NUMBER." (cadr (elmo-get-hash-val (format "#%d" number) (elmo-msgdb-get-mark-hashtb msgdb)))) (defsubst elmo-msgdb-set-mark (msgdb number mark) - "Set MARK of the message with NUMBER in the MSGDB." + "Set MARK of the message with NUMBER in the MSGDB. +if MARK is nil, mark is removed." (elmo-msgdb-set-mark-alist msgdb (elmo-msgdb-mark-alist-set (elmo-msgdb-get-mark-alist msgdb) @@ -158,6 +160,19 @@ content of MSGDB is changed." (message "Sorting...done") (list overview (nth 1 msgdb)(nth 2 msgdb)))) +(defun elmo-msgdb-make-entity (&rest args) + "Make an msgdb entity." + (cons (plist-get args :message-id) + (vector (plist-get args :number) + (plist-get args :references) + (plist-get args :from) + (plist-get args :subject) + (plist-get args :date) + (plist-get args :to) + (plist-get args :cc) + (plist-get args :size) + (plist-get args :extra)))) + ;;; (defsubst elmo-msgdb-append-element (list element) (if list @@ -753,34 +768,43 @@ header separator." seen-list)) (defun elmo-msgdb-get-message-id-from-buffer () - (or (elmo-field-body "message-id") + (let ((msgid (elmo-field-body "message-id"))) + (if msgid + (if (string-match "<\\(.+\\)>$" msgid) + msgid + (concat "<" msgid ">")) ; Invaild message-id. ;; no message-id, so put dummy msgid. - (concat (timezone-make-date-sortable - (elmo-field-body "date")) + (concat "<" (timezone-make-date-sortable + (elmo-field-body "date")) (nth 1 (eword-extract-address-components - (or (elmo-field-body "from") "nobody")))))) + (or (elmo-field-body "from") "nobody"))) ">")))) (defsubst elmo-msgdb-create-overview-from-buffer (number &optional size time) "Create overview entity from current buffer. Header region is supposed to be narrowed." (save-excursion (let ((extras elmo-msgdb-extra-fields) + (default-mime-charset default-mime-charset) message-id references from subject to cc date - extra field-body) + extra field-body charset) (elmo-set-buffer-multibyte default-enable-multibyte-characters) (setq message-id (elmo-msgdb-get-message-id-from-buffer)) + (and (setq charset (cdr (assoc "charset" (mime-read-Content-Type)))) + (setq charset (intern-soft charset)) + (setq default-mime-charset charset)) (setq references (or (elmo-msgdb-get-last-message-id (elmo-field-body "in-reply-to")) (elmo-msgdb-get-last-message-id (elmo-field-body "references")))) - (setq from (elmo-mime-string (elmo-delete-char - ?\" - (or - (elmo-field-body "from") - elmo-no-from)))) - (setq subject (elmo-mime-string (or (elmo-field-body "subject") - elmo-no-subject))) + (setq from (elmo-replace-in-string + (elmo-mime-string (or (elmo-field-body "from") + elmo-no-from)) + "\t" " ") + subject (elmo-replace-in-string + (elmo-mime-string (or (elmo-field-body "subject") + elmo-no-subject)) + "\t" " ")) (setq date (or (elmo-field-body "date") time)) (setq to (mapconcat 'identity (elmo-multiple-field-body "to") ",")) (setq cc (mapconcat 'identity (elmo-multiple-field-body "cc") ",")) @@ -931,6 +955,13 @@ Return the updated INDEX." elmo-msgdb-location-filename dir) alist)) +(put 'elmo-msgdb-do-each-entity 'lisp-indent-function '1) +(def-edebug-spec elmo-msgdb-do-each-entity + ((symbolp form &rest form) &rest form)) +(defmacro elmo-msgdb-do-each-entity (spec &rest form) + `(dolist (,(car spec) (elmo-msgdb-get-overview ,(car (cdr spec)))) + ,@form)) + (require 'product) (product-provide (provide 'elmo-msgdb) (require 'elmo-version))