--- pollen.el.orig	2002-02-03 22:28:37.000000000 +0900
+++ pollen.el	2005-06-20 02:25:50.687094688 +0900
@@ -1,4 +1,4 @@
-;;; pollen.el --- Pollen Report -*- coding: iso-2022-jp -*- 
+;;; pollen.el --- Pollen Report -*- coding: iso-2022-jp -*-
 
 ;; Copyright (C) 1999-2002 Junichiro KITA <kita@a1.mbn.or.jp>
 
@@ -39,16 +39,18 @@
 
 (defvar pollen-message "%s$B$N(B%s$B$N?y2VJ4$O(B%s$B$G$9(B"
   "* Message format.
-First `%s' is replaced with DATE, second `%s' with WHERE, third `%s' with QUANTITY.")
+First `%s' is replaced with DATE, second `%s' with WHERE,
+third `%s' with QUANTITY.")
 (defvar pollen-message-off-season "$B$b$&(B%s$B$K$O?y2VJ4$OHt$s$G$$$^$;$s(B"
   "* Message format for off season.
 First %s is replaced with WHERE")
 
 (defvar pollen-season-start 2)
 (defvar pollen-season-end 4)
-(defvar pollen-url-template "http://www.wni.co.jp/cww/docs/kafun/%s.html")
+(defvar pollen-url-template "http://weathernews.jp/cww/docs/kafun/%s.html")
 (defvar pollen-get-func 'pollen-get)
-(defvar pollen-coding-system (static-if (boundp 'MULE) '*euc-japan* 'euc-japan))
+(defvar pollen-coding-system
+  (static-if (boundp 'MULE) '*euc-japan* 'euc-japan))
 (defvar pollen-fetch-interval (* 60 60 3)
   "* Default life time for cached data.")
 (defvar pollen-cache nil
@@ -58,7 +60,7 @@
 (defvar pollen-region-alist
   '(
     ;; $BElKLF|K\3$B&(B
-    ("$B@D?98)DE7Z(B" . "yoho3110") ("$B@D?98)DE7Z(B" . "yoho3120")
+    ("$B@D?98)DE7Z(B" . "yoho3110") ("$B@D?98)2<KL(B" . "yoho3120")
     ("$B@D?98);0H,>eKL(B" . "yoho3130")
     ("$B=)ED8)1h4_(B" . "yoho3210") ("$B=)ED8)FbN&(B" . "yoho3220")
     ("$B;37A8)B<;3(B" . "yoho3510") ("$B;37A8)CV;r(B" . "yoho3520")
@@ -66,126 +68,122 @@
     ;; $BElKLB@J?MNB&(B
     ("$B4d<j8)FbN&(B" . "yoho3310") ("$B4d<j8)1h4_KLIt(B" . "yoho3320")
     ("$B4d<j8)1h4_FnIt(B" . "yoho3330")
-    ("$B5\>k8)J?Ln(B" . "yoho3410") ("$B5\>k8);31h$$(B" . "yoho3420")
+    ("$B5\>k8)ElIt(B" . "yoho3410") ("$B5\>k8)@>It(B" . "yoho3420")
     ("$BJ!Eg8)CfDL$j(B" . "yoho3610") ("$BJ!Eg8)IMDL$j(B" . "yoho3620")
     ("$BJ!Eg8)2qDE(B" . "yoho3630")
-    ;; $BKLN&(B
-    ("$B?73c8)2<1[(B" . "yoho5410") ("$B?73c8)Cf1[(B" . "yoho5420")
-    ("$B?73c8)>e1[(B" . "yoho5430") ("$B?73c8):42l(B" . "yoho5440")
-    ("$BIY;38)ElIt(B" . "yoho5510") ("$BIY;38)@>It(B" . "yoho5520")
-    ("$B@P@n8)2C2l(B" . "yoho5610") ("$B@P@n8)G=EP(B" . "yoho5620")
-    ("$BJ!0f8)NfKL(B" . "yoho5710") ("$BJ!0f8)NfFn(B" . "yoho5720")
     ;; $B4XEl9C?.(B
+    ("$B0q>k8)KLIt(B" . "yoho4010") ("$B0q>k8)FnIt(B" . "yoho4020")
     ("$BFJLZ8)FnIt(B" . "yoho4110") ("$BFJLZ8)KLIt(B" . "yoho4120")
     ("$B72GO8)FnIt(B" . "yoho4210") ("$B72GO8)KLIt(B" . "yoho4220")
-    ("$B0q>k8)KLIt(B" . "yoho4010") ("$B0q>k8)FnIt(B" . "yoho4010")
     ("$B:k6L8)FnIt(B" . "yoho4310") ("$B:k6L8)KLIt(B" . "yoho4320")
     ("$B:k6L8)CaIc(B" . "yoho4330")
     ("$B@iMU8)KL@>It(B" . "yoho4510") ("$B@iMU8)KLElIt(B" . "yoho4520")
     ("$B@iMU8)FnIt(B" . "yoho4530")
     ("$BEl5~ET(B23$B6h(B" . "yoho4401") ("$BEl5~ETB?K`(B" . "yoho4402")
     ("$B?@F`@n8)ElIt(B" . "yoho4610") ("$B?@F`@n8)@>It(B" . "yoho4620")
+    ("$B;3M|8)Cf@>It(B" . "yoho4910") ("$B;3M|8)ElItIY;N8^8P(B" . "yoho4920")
     ("$BD9Ln8)KLIt(B" . "yoho4810") ("$BD9Ln8)CfIt(B" . "yoho4820")
     ("$BD9Ln8)FnIt(B" . "yoho4830")
-    ("$B;3M|8)Cf@>It(B" . "yoho4910") ("$B;3M|8)ElItIY;N8^8P(B" . "yoho4920")
     ;; $BEl3$(B
     ("$B@E2,8)CfIt(B" . "yoho5010") ("$B@E2,8)0KF&(B" . "yoho5020")
     ("$B@E2,8)ElIt(B" . "yoho5030") ("$B@E2,8)@>It(B" . "yoho5040")
-    ("$B4tIl8)H~G;(B" . "yoho5210") ("$B4tIl8)HtBM(B" . "yoho5210")
     ("$B0&CN8)@>It(B" . "yoho5110") ("$B0&CN8)ElIt(B" . "yoho5120")
+    ("$B4tIl8)H~G;(B" . "yoho5210") ("$B4tIl8)HtBM(B" . "yoho5220")
     ("$B;0=E8)KLCfIt(B" . "yoho5310") ("$B;0=E8)FnIt(B" . "yoho5320")
+    ;; $BKLN&(B
+    ("$B?73c8)2<1[(B" . "yoho5410") ("$B?73c8)Cf1[(B" . "yoho5420")
+    ("$B?73c8)>e1[(B" . "yoho5430") ("$B?73c8):4EO(B" . "yoho5440")
+    ("$BIY;38)ElIt(B" . "yoho5510") ("$BIY;38)@>It(B" . "yoho5520")
+    ("$B@P@n8)2C2l(B" . "yoho5610") ("$B@P@n8)G=EP(B" . "yoho5620")
+    ("$BJ!0f8)NfKL(B" . "yoho5710") ("$BJ!0f8)NfFn(B" . "yoho5720")
     ;; $B6a5&(B
-    ("$B<"2l8)FnIt(B" . "yoho6010") ("$B<"2l8)KLIt(B" . "yoho6010")
+    ("$B<"2l8)FnIt(B" . "yoho6010") ("$B<"2l8)KLIt(B" . "yoho6020")
     ("$B5~ETI\KLIt(B" . "yoho400") ("$B5~ETI\FnIt(B" . "yoho6100")
     ("$BF`NI8)KLIt(B" . "yoho6410") ("$BF`NI8)FnIt(B" . "yoho6420")
-    ("$BBg:eI\A48)(B" . "yoho6200")
+    ("$BBg:eI\A40h(B" . "yoho6200") ("$BBg:eI\(B" . "yoho6200")
     ("$BOB2N;38)KLIt(B" . "yoho6510") ("$BOB2N;38)FnIt(B" . "yoho6520")
-    ("$BJ<8K8)KLIt(B" . "yoho500") ("$BJ<8K8)FnIt(B" . "yoho6300")
+    ("$BJ<8K8)FnIt(B" . "yoho6310") ("$BJ<8K8)KLIt(B" . "yoho6320")
     ;; $B;31"(B
-    ("$BD;<h8)ElIt(B" . "yoho6910") ("$BD;<h8)@>It(B" . "yoho6920")
+    ("$BD;<h8)ElIt(B" . "yoho6910") ("$BD;<h8)Cf!&@>It(B" . "yoho6920")
     ("$BEg:,8)1#4t(B" . "yoho600") ("$BEg:,8)ElIt(B" . "yoho6810")
     ("$BEg:,8)@>It(B" . "yoho6820")
     ;; $B;3M[(B
     ("$B2,;38)FnIt(B" . "yoho6610") ("$B2,;38)KLIt(B" . "yoho6620")
-    ("$B9-Eg8)FnIt(B" . "yoho6710") ("$B9-Eg8)KLIt(B" . "yoho6710")
+    ("$B9-Eg8)FnIt(B" . "yoho6710") ("$B9-Eg8)KLIt(B" . "yoho6720")
     ("$B;38}8)@>It(B" . "yoho8110") ("$B;38}8)CfIt(B" . "yoho8120")
     ("$B;38}8)ElIt(B" . "yoho8130") ("$B;38}8)KLIt(B" . "yoho8140")
     ;; $B;M9q(B
-    ("$B9a@n8)A48)(B" . "yoho7200")
-    ("$BFAEg8)KLIt(B" . "yoho7110") ("$BFAEg8)FnIt(B" . "yoho7120")
     ("$B0&I28)CfM=(B" . "yoho7310") ("$B0&I28)ElM=(B" . "yoho7320")
     ("$B0&I28)FnM=(B" . "yoho7330")
+    ("$B9a@n8)A40h(B" . "yoho7200") ("$B9a@n8)(B" . "yoho7200")
+    ("$BFAEg8)KLIt(B" . "yoho7110") ("$BFAEg8)FnIt(B" . "yoho7120")
     ("$B9bCN8)CfIt(B" . "yoho7410") ("$B9bCN8)ElIt(B" . "yoho7420")
     ("$B9bCN8)@>It(B" . "yoho7430")
     ;; $B6e=#KLIt(B
     ("$BJ!2,8)J!2,(B" . "yoho8210") ("$BJ!2,8)KL6e=#(B" . "yoho8220")
     ("$BJ!2,8)C^K-(B" . "yoho8230") ("$BJ!2,8)C^8e(B" . "yoho8240")
-    ("$BBgJ,8)CfIt(B" . "yoho8310") ("$BBgJ,8)KLIt(B" . "yoho8320")
-    ("$BBgJ,8)@>It(B" . "yoho8330") ("$BBgJ,8)FnIt(B" . "yoho8340")
     ("$B:42l8)FnIt(B" . "yoho8510") ("$B:42l8)KLIt(B" . "yoho8520")
     ("$BD9:j8)FnIt(B" . "yoho8410") ("$BD9:j8)KLIt(B" . "yoho8420")
     ("$BD9:j8)0m4tBPGO(B" . "yoho700") ("$BD9:j8)8^Eg(B" . "yoho800")
     ("$B7'K\8)7'K\(B" . "yoho8610") ("$B7'K\8)0$AI(B" . "yoho8620")
     ("$B7'K\8)E7Ap02KL(B" . "yoho8630") ("$B7'K\8)5eK{(B" . "yoho8640")
+    ("$BBgJ,8)CfIt(B" . "yoho8310") ("$BBgJ,8)KLIt(B" . "yoho8320")
+    ("$BBgJ,8)@>It(B" . "yoho8330") ("$BBgJ,8)FnIt(B" . "yoho8340")
     ;; $B6e=#FnIt(B
     ("$B5\:j8)FnItJ?LnIt(B" . "yoho8710") ("$B5\:j8)KLItJ?LnIt(B" . "yoho8720")
     ("$B5\:j8)FnIt;31h$$(B" . "yoho8730") ("$B5\:j8)KLIt;31h$$(B" . "yoho8740")
-    ("$B</;yEg8);'K`(B" . "yoho8810")
-    ("$B</;yEg8)Bg7((B" . "yoho8820")
-    ("$B</;yEg8)205WEg<o;REg(B" . "yoho900")
-    ("$B</;yEg8)1bH~(B" . "yoho1000")
+    ("$B</;yEg8);'K`(B" . "yoho8810") ("$B</;yEg8)Bg7((B" . "yoho8820")
+    ("$B</;yEg8)<o;REg205WEg(B" . "yoho900") ("$B</;yEg8)1bH~(B" . "yoho1000")
     ))
 
 
-(defsubst pollen-today-p ()
-  (> 11 (string-to-int (format-time-string "%k" (current-time)))))
-
 (defun pollen-get (buf &optional args)
   (let (date quantity from to)
     (save-excursion
       (set-buffer buf)
-      ;; $BM=Js>pJs$@$1$r@Z$j=P$7(B
+      ;; $BM=Js>pJs$@$1$r@Z$j=P$7(B ($B%7!<%:%sKh$K=q$-49$($k(B)
       (goto-char (point-min))
-      (search-forward "yoho_hisan.gif")
-      (forward-line 1)
-      (setq from (point))
-      (search-forward "$B;~H/I=(B")
-      (forward-line -1)
-      (setq to (point))
-      (narrow-to-region from to)
+      (when (search-forward "yaji.gif" nil t)
+	(forward-line 1)
+	(setq from (point))
+	(when (search-forward "<b>$BK^Nc(B</b>" nil t)
+	  (forward-line -1)
+	  (setq to (point))))
+      (if to
+	  (narrow-to-region from to)
+	(error "Pollen: $BM=Js>pJs$r@Z$j=P$;$^$;$s!%(B"))
+      ;; $BF|IU!&2VJ4>pJs$N<hF@(B ($B%7!<%:%sKh$K=q$-49$($k(B)
       (goto-char (point-min))
-
-      ;; $BF|IU$rC5$9(B
-      (re-search-forward "\\([0-9]+/[0-9]+\\)" nil t)
-      (if (re-search-forward "\\([0-9]+/[0-9]+\\)" nil t)
-	  ;; $B$3$&$$$&7A<0$@$C$?$i(B
-	  ;; +-----+--------+
-	  ;; |mm/dd| mm/dd  |
-	  ;; +-----+--------+
-	  ;; |today|tommorow|
-	  ;; +-----+--------+
-	  (progn
-	    (setq date (match-string 1))
-	    (re-search-forward "alt=\"\\(.*\\)\"")
-	    (or (pollen-today-p)
-		(re-search-forward "alt=\"\\(.*\\)\""))) ; $B:#F|$NJ,$OMW$i$s$N$h(B
-	;; $B$G$J$1$l$P$3$&$$$&7A<0$N$O$:$J$N$h(B
-	;; +-----+
-	;; |mm/dd|
-	;; +-----+
-	;; |today|
-	;; +-----+
-	(setq date (match-string 1))
-	(re-search-forward "alt=\"\\(.*\\)\""))
-      (setq quantity (match-string 1))
-      (list date quantity))))
+      (re-search-forward "alt=\"\\(.*\\)\"" nil t)
+      (if (re-search-forward "alt=\"\\(.*\\)\"" nil t)
+	  (if (equal "---" (match-string 1))
+	      (progn
+		(forward-line -3)
+		(if (re-search-backward "\\([1-6]+/[1-3]?[0-9]\\)" nil t)
+		    (setq date (match-string 1)))
+		(if (re-search-forward "alt=\"\\(.*\\)\"" nil t)
+		    (setq quantity (match-string 1))))
+	    (progn
+	      (if (re-search-backward "\\([1-6]+/[1-3]?[0-9]\\)" nil t)
+		  (setq date (match-string 1)))
+	      (if (re-search-forward "alt=\"\\(.*\\)\"" nil t)
+		  (setq quantity (match-string 1)))))
+	(progn
+	  (if (re-search-backward "\\([1-6]+/[1-3]?[0-9]\\)" nil t)
+	      (setq date (match-string 1)))
+	  (if (re-search-forward "alt=\"\\(.*\\)\"" nil t)
+	      (setq quantity (match-string 1)))))
+      (if (and date quantity)
+	  (list date quantity)
+	(error "Pollen: $BF|IU!&2VJ4>pJs$r8+IU$1$i$l$^$;$s!%(B")))))
 
 (defsubst pollen-current-second ()
   (string-to-int (format-time-string "%s" (current-time))))
 
 (defun pollen-set-cache (where date quantity)
   (setq pollen-cache
-	(put-alist where (list (pollen-current-second) date quantity) pollen-cache)))
+	(put-alist where
+		   (list (pollen-current-second) date quantity) pollen-cache)))
 
 (defun pollen-get-cache (where)
   (let (current cache ret)
@@ -197,8 +195,10 @@
 	  (setq ret (cddr cache))))
     ret))
 
-(defsubst pollen-compose (where date quantity)
-  (format pollen-message date where quantity))
+(if (fboundp 'pollen-compose)
+    nil
+  (defun pollen-compose (where date quantity)
+    (format pollen-message date where quantity)))
 
 (defsubst pollen-off-season-p ()
   (let ((month (string-to-int (format-time-string "%m" (current-time)))))
@@ -217,8 +217,10 @@
 If OFFLINE is nil, don't fetch pollen report from WEB, only use cache."
   (interactive (if (or current-prefix-arg
 		       (null pollen-where))
-		   (list (read-from-minibuffer "Where: "
-					       pollen-where))))
+		   (list
+		    (setq pollen-where
+			  (completing-read "Where: "
+					   pollen-region-alist nil t)))))
   (setq where (or where pollen-where))
   (let (parsed-where url ret ret-data)
     (setq parsed-where (assoc where pollen-region-alist))
@@ -246,24 +248,31 @@
     (narrow-to-region
      (goto-char (point-min))
      (goto-char (if (re-search-forward
-                     (format "^$\\|^%s$"
-                             (regexp-quote mail-header-separator))
-                     nil t)
-                    (match-beginning 0)
-                  (point-max))))))
+		     (format "^$\\|^%s$"
+			     (regexp-quote mail-header-separator))
+		     nil t)
+		    (match-beginning 0)
+		  (point-max))))))
 
 (defun pollen-insert-header (&optional where offline)
   "Insert X-Pollen: header.
 If WHERE is nil, the default value `pollen-where' is used instead.
 If OFFLINE is nil, don't fetch pollen report from WEB, only use cache."
-  (interactive)
-  (let ((pollen (pollen-from-http where offline)))
-    (if pollen
-	(save-excursion
-	  (save-restriction
-	    (pollen-narrow-to-header)
-	    (goto-char (point-max))
-	    (insert "X-Pollen: " pollen "\n"))))))
+  (interactive (if (or current-prefix-arg
+		       (null pollen-where))
+		   (list
+		    (setq pollen-where
+			  (completing-read "Where: "
+					   pollen-region-alist nil t)))))
+  (setq where (or where pollen-where))
+  (let (current-prefix-arg)
+    (let ((pollen (pollen-from-http where offline)))
+      (if pollen
+	  (save-excursion
+	    (save-restriction
+	      (pollen-narrow-to-header)
+	      (goto-char (point-max))
+	      (insert "X-Pollen: " pollen "\n")))))))
 
 
 
@@ -286,7 +295,7 @@
 	    (setq buf (generate-new-buffer "*HTTP Fetch*")))
 	    (setq connection
 		  (as-binary-process
-		   (open-network-stream "*Fetch from HTTP*" 
+		   (open-network-stream "*Fetch from HTTP*"
 					buf
 					server
 					port)))
@@ -322,7 +331,7 @@
   (interactive)
   (let ((product-info (product-string-1 "Pollen" t)))
     (if (interactive-p)
-        (message "%s" product-info)
+	(message "%s" product-info)
       product-info)))
 
 (provide 'pollen)
