* elmo-archive.el (elmo-archive-get-archive-name): Fixed
[elisp/wanderlust.git] / wl / wl-refile.el
index ccecc93..8155e93 100644 (file)
@@ -1,6 +1,6 @@
 ;;; wl-refile.el -- Refile modules for Wanderlust.
 
-;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
 ;; Keywords: mail, net news
@@ -31,8 +31,6 @@
 
 (require 'wl-vars)
 (require 'wl-util)
-(require 'product)
-(product-provide (provide 'wl-refile) (require 'wl-version))
 
 (defvar wl-refile-alist nil)
 (defvar wl-refile-alist-file-name "refile-alist")
@@ -45,7 +43,7 @@
 (defvar wl-refile-alist-max-length 1000)
 
 (defun wl-refile-alist-setup ()
-  (let ((flist wl-refile-guess-func-list))
+  (let ((flist wl-refile-guess-functions))
     (while flist
       (cond
        ((eq (car flist) 'wl-refile-guess-by-history)
          (setq key from))
       (if (or wl-refile-msgid-alist
              (memq 'wl-refile-guess-by-msgid
-                   wl-refile-guess-func-list))
+                   wl-refile-guess-functions))
          (wl-refile-msgid-learn entity dst))
       (if (or wl-refile-subject-alist
              (memq 'wl-refile-guess-by-subject
-                   wl-refile-guess-func-list))
+                   wl-refile-guess-functions))
          (wl-refile-subject-learn entity dst)))
     (when key
       (if (setq hit (assoc key wl-refile-alist))
 ;;
 ;; refile guess
 ;;
-(defvar wl-refile-guess-func-list
+(defvar wl-refile-guess-functions
   '(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.")
 
+(defvar wl-refile-guess-func-list wl-refile-guess-functions)
+(make-obsolete-variable 'wl-refile-guess-func-list 'wl-refile-guess-functions)
+
 (defun wl-refile-guess (entity)
-  (let ((flist wl-refile-guess-func-list) guess)
+  (let ((flist wl-refile-guess-functions) guess)
     (while flist
       (if (setq guess (funcall (car flist) entity))
          (setq flist nil)
     guess))
 
 (defun wl-refile-evaluate-rule (rule entity)
-  "Returns folder string if RULE is matched to ENTITY.
+  "Return folder string if RULE is matched to ENTITY.
 If RULE does not match ENTITY, returns nil."
   (let ((case-fold-search t)
        fields guess pairs value)
@@ -186,7 +187,7 @@ If RULE does not match ENTITY, returns nil."
                 (string-match
                  (car (car pairs))
                  value)
-                (setq guess (wl-refile-expand-newtext
+                (setq guess (wl-expand-newtext
                              (wl-refile-evaluate-rule (cdr (car pairs))
                                                       entity)
                              value)))
@@ -207,39 +208,6 @@ If RULE does not match ENTITY, returns nil."
                 entity)
       (elmo-msgdb-overview-entity-get-extra-field entity field))))
 
-(defun wl-refile-expand-newtext (newtext original)
-  (let ((len (length newtext))
-       (pos 0)
-       c expanded beg N did-expand)
-    (while (< pos len)
-      (setq beg pos)
-      (while (and (< pos len)
-                 (not (= (aref newtext pos) ?\\)))
-       (setq pos (1+ pos)))
-      (unless (= beg pos)
-       (push (substring newtext beg pos) expanded))
-      (when (< pos len)
-       ;; We hit a \; expand it.
-       (setq did-expand t
-             pos (1+ pos)
-             c (aref newtext pos))
-       (if (not (or (= c ?\&)
-                    (and (>= c ?1)
-                         (<= c ?9))))
-           ;; \ followed by some character we don't expand.
-           (push (char-to-string c) expanded)
-         ;; \& or \N
-         (if (= c ?\&)
-             (setq N 0)
-           (setq N (- c ?0)))
-         (when (match-beginning N)
-           (push (substring original (match-beginning N) (match-end N))
-                 expanded))))
-      (setq pos (1+ pos)))
-    (if did-expand
-       (apply (function concat) (nreverse expanded))
-      newtext)))
-
 (defun wl-refile-guess-by-rule (entity)
   (let ((rules wl-refile-rule-alist)
        guess)
@@ -293,4 +261,7 @@ If RULE does not match ENTITY, returns nil."
               (elmo-msgdb-overview-entity-get-subject entity))
              wl-refile-subject-alist)))
 
+(require 'product)
+(product-provide (provide 'wl-refile) (require 'wl-version))
+
 ;;; wl-refile.el ends here