[Mew-dist 09289] mew-refile-guess-by-alist2

Kyotaro HORIGUCHI kyota at example.com
1999年 6月 9日 (水) 18:33:26 JST


堀口です. 1.94B32 @ Meadow1.04a1 ですが, 時折 
mew-refile-guess-by-alist2 でエラーになります.

 (args-out-of-range 4 4) 

 という感じですが, これは (match-beginning n) で regexp が内部で
持っているリストの要素数よりも大きな値を指定するとなってしまうよ
うです. このリストの大きさがどう決まるかは知りませんが, 9より小さ
くなることがあるのは確かなようです.

 そこでマッチの数より大きなインデックス(?)を指定せずに済むように
たとえば以下のように修正してもらいたいのですがどうでしょうか.

--
堀口恭太郎


-------------- next part --------------
--- mew-refile.el.org	Wed Jun 09 18:16:32 1999
+++ mew-refile.el	Wed Jun 09 18:26:48 1999
@@ -182,21 +182,23 @@
 
 (defun mew-refile-guess-by-alist2 (regexp field string)
-  (let ((p 1) match-list matches b e)
+  (let (match-strings match-list)
     (string-match regexp field)
-    (setq matches (cddr (match-data)))
-    (while (car matches)
-      (setq match-list
+    (setq match-list (cddr (match-data)))
+    (while (car match-list)
+      (setq match-strings
 	    (cons (substring field
-			     (car matches) (cadr matches)
-			     match-list)))
-      (setq matches (cddr matches)))
-    (setq  p 1)
-    (while (<= p 9)
-      (if (string-match (concat "\\\\" (int-to-string p)) string)
-	  (setq string
-		(concat (substring string 0 (match-beginning 0))
-			(nth (- 9 p) match-list)
-			(substring string (match-end 0))))
-	(setq p (1+ p))))
+			     (car match-list) (cadr match-list))
+		  match-strings))
+      (setq match-list (cddr match-list)))
+    (while (string-match "\\\\\\([1-9]\\)" string)
+	(setq string
+	      (concat (substring string 0 (match-beginning 0))
+		      (nth (- (length match-strings)
+			      (string-to-int 
+			       (substring string
+					  (match-beginning 1)
+					  (match-end 1))))
+			   match-strings)
+		      (substring string (match-end 0)))))
     string))


Mew-dist メーリングリストの案内