From: teranisi Date: Fri, 30 Jun 2000 01:12:03 +0000 (+0000) Subject: 2000-06-27 MAKINO Takashi X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=49dd0a3d25f950a3001e487f050f4d2164c33669;p=elisp%2Fwanderlust.git 2000-06-27 MAKINO Takashi * wl-refile.el (wl-refile-subject-alist): New variable. (wl-refile-subject-alist-file-name): Ditto. (wl-refile-alist-setup): Rewrite. (wl-refile-alist-save): Use `elmo-object-save'. (wl-refile-learn): Check `wl-refile-guess-func-list'. (wl-refile-guess-by-subject): New function. (wl-refile-guess-func-list): Added it. --- diff --git a/wl/ChangeLog b/wl/ChangeLog index 9284d16..b8c0994 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,13 @@ +2000-06-27 MAKINO Takashi + + * wl-refile.el (wl-refile-subject-alist): New variable. + (wl-refile-subject-alist-file-name): Ditto. + (wl-refile-alist-setup): Rewrite. + (wl-refile-alist-save): Use `elmo-object-save'. + (wl-refile-learn): Check `wl-refile-guess-func-list'. + (wl-refile-guess-by-subject): New function. + (wl-refile-guess-func-list): Added it. + 2000-06-29 Katsumi Yamaoka * wl-demo.el (wl-demo-with-temp-file-buffer): New macro. diff --git a/wl/wl-refile.el b/wl/wl-refile.el index 614c697..bc426ab 100644 --- a/wl/wl-refile.el +++ b/wl/wl-refile.el @@ -4,7 +4,7 @@ ;; Author: Yuuichi Teranishi ;; Keywords: mail, net news -;; Time-stamp: <00/04/05 01:20:16 teranisi> +;; Time-stamp: <00/06/30 09:51:03 teranisi> ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen). @@ -40,35 +40,48 @@ ;; should be renamed to "refile-from-alist" (defvar wl-refile-msgid-alist nil) (defvar wl-refile-msgid-alist-file-name "refile-msgid-alist") +(defvar wl-refile-subject-alist nil) +(defvar wl-refile-subject-alist-file-name "refile-subject-alist") (defvar wl-refile-alist-max-length 1000) (defun wl-refile-alist-setup () - (setq wl-refile-alist - (elmo-object-load - (expand-file-name wl-refile-alist-file-name - elmo-msgdb-dir))) - (setq wl-refile-msgid-alist - (elmo-object-load - (expand-file-name wl-refile-msgid-alist-file-name - elmo-msgdb-dir)))) + (let ((flist wl-refile-guess-func-list)) + (while flist + (cond + ((eq (car flist) 'wl-refile-guess-by-history) + (setq wl-refile-alist + (elmo-object-load + (expand-file-name wl-refile-alist-file-name + elmo-msgdb-dir) elmo-mime-charset))) + ((eq (car flist) 'wl-refile-guess-by-msgid) + (setq wl-refile-msgid-alist + (elmo-object-load + (expand-file-name wl-refile-msgid-alist-file-name + elmo-msgdb-dir) elmo-mime-charset))) + ((eq (car flist) 'wl-refile-guess-by-subject) + (setq wl-refile-subject-alist + (elmo-object-load + (expand-file-name wl-refile-subject-alist-file-name + elmo-msgdb-dir) elmo-mime-charset)))) + (setq flist (cdr flist))))) + +(defun wl-refile-alist-save () + (if wl-refile-alist + (wl-refile-alist-save-file + wl-refile-alist-file-name wl-refile-alist)) + (if wl-refile-msgid-alist + (wl-refile-alist-save-file + wl-refile-msgid-alist-file-name wl-refile-msgid-alist)) + (if wl-refile-subject-alist + (wl-refile-alist-save-file + wl-refile-subject-alist-file-name wl-refile-subject-alist))) -(defun wl-refile-alist-save (file-name alist) - (save-excursion - (let ((filename (expand-file-name file-name - elmo-msgdb-dir)) - (tmp-buffer (get-buffer-create " *wl-refile-alist-tmp*"))) - (set-buffer tmp-buffer) - (erase-buffer) - (if (> (length alist) wl-refile-alist-max-length) - (setcdr (nthcdr (1- wl-refile-alist-max-length) alist) nil)) - (prin1 alist tmp-buffer) - (princ "\n" tmp-buffer) - (if (file-writable-p filename) - (write-region (point-min) (point-max) - filename nil 'no-msg) - (message (format "%s is not writable." filename))) - (kill-buffer tmp-buffer)))) +(defun wl-refile-alist-save-file (file-name alist) + (if (> (length alist) wl-refile-alist-max-length) + (setcdr (nthcdr (1- wl-refile-alist-max-length) alist) nil)) + (elmo-object-save (expand-file-name file-name elmo-msgdb-dir) + alist elmo-mime-charset)) (defun wl-refile-learn (entity dst) (let (tocc-list from key hit ml) @@ -98,7 +111,15 @@ entity))))) (setq key from))) (if (not ml) - (wl-refile-msgid-learn entity dst)) + (progn + (if (or wl-refile-msgid-alist + (member 'wl-refile-guess-by-msgid + wl-refile-guess-func-list)) + (wl-refile-msgid-learn entity dst)) + (if (or wl-refile-subject-alist + (member 'wl-refile-guess-by-subject + wl-refile-guess-func-list)) + (wl-refile-subject-learn entity dst)))) (if key (if (setq hit (assoc key wl-refile-alist)) (setcdr hit dst) @@ -115,12 +136,24 @@ (setq wl-refile-msgid-alist (cons (cons key dst) wl-refile-msgid-alist)))))) +(defun wl-refile-subject-learn (entity dst) + (let ((subject (wl-summary-subject-filter-func-internal + (elmo-msgdb-overview-entity-get-subject entity))) + hit) + (setq dst (elmo-string dst)) + (if (and subject (not (string= subject ""))) + (if (setq hit (assoc subject wl-refile-subject-alist)) + (setcdr hit dst) + (setq wl-refile-subject-alist (cons (cons subject dst) + wl-refile-subject-alist)))))) + ;; ;; refile guess ;; (defvar wl-refile-guess-func-list '(wl-refile-guess-by-rule wl-refile-guess-by-msgid + wl-refile-guess-by-subject wl-refile-guess-by-history) "*Functions in this list are used for guessing refile destination folder.") @@ -258,4 +291,9 @@ If RULE does not match ENTITY, returns nil." (cdr (assoc (elmo-msgdb-overview-entity-get-references entity) wl-refile-msgid-alist))) +(defun wl-refile-guess-by-subject (entity) + (cdr (assoc (wl-summary-subject-filter-func-internal + (elmo-msgdb-overview-entity-get-subject entity)) + wl-refile-subject-alist))) + ;;; wl-refile.el ends here diff --git a/wl/wl.el b/wl/wl.el index 1aa9c20..33fd1e8 100644 --- a/wl/wl.el +++ b/wl/wl.el @@ -628,10 +628,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (unless keep-summary (kill-buffer x)))) summaries)))) - (wl-refile-alist-save - wl-refile-alist-file-name wl-refile-alist) - (wl-refile-alist-save - wl-refile-msgid-alist-file-name wl-refile-msgid-alist) + (wl-refile-alist-save) (wl-folder-info-save) (and (featurep 'wl-fldmgr) (wl-fldmgr-exit)) (wl-crosspost-alist-save)