From: ueno Date: Tue, 4 Apr 2000 14:11:13 +0000 (+0000) Subject: * wl-refile.el X-Git-Tag: wl-1_1_1~64 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=9845991cd5b969508545c43fa5029735591cc3fb;p=elisp%2Fwanderlust.git * wl-refile.el (wl-refile-expand-newtext): New function imported from Gnus. (wl-refile-evaluate-rule): Use it. --- diff --git a/wl/wl-refile.el b/wl/wl-refile.el index b144b14..d4413b9 100644 --- a/wl/wl-refile.el +++ b/wl/wl-refile.el @@ -155,8 +155,9 @@ If RULE does not match ENTITY, returns nil." (if (and (string-match (car (car pairs)) value) - (setq guess (wl-refile-evaluate-rule (cdr (car pairs)) - entity))) + (setq guess (wl-refile-expand-newtext + (wl-refile-evaluate-rule (cdr (car pairs)) + entity)))) (setq pairs nil) (setq pairs (cdr pairs)))) guess) @@ -174,6 +175,39 @@ If RULE does not match ENTITY, returns nil." entity) (elmo-msgdb-overview-entity-get-extra-field entity field)))) +(defun wl-refile-expand-newtext (newtext) + (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 (buffer-substring (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)