* WL-MK (wl-news-lang): New variable.
authorokada <okada>
Thu, 19 Dec 2002 17:50:27 +0000 (17:50 +0000)
committerokada <okada>
Thu, 19 Dec 2002 17:50:27 +0000 (17:50 +0000)
(wl-news-news-file): Merge `wl-news-news-file'
and `wl-news-news-file-ja'.
(wl-news-search-regexp): New variable.
(wl-news-news-file): New function.
(wl-news-parse-news): Merge `wl-news-parse-news'
and `wl-news-parse-news-ja'.
(wl-news-parse-news-subr): New function.

* wl-news.el.in (wl-news-check): Fix for `wl-news-lang'.
(wl-news-append-news): New function.
(wl-news-send-news): New function.

ChangeLog
WL-MK
wl/ChangeLog
wl/wl-news.el.in

index 5fac93b..305c470 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2002-12-20  Kenichi OKADA  <okada@opaopa.org>
 
+       * WL-MK (wl-news-lang): New variable.
+       (wl-news-news-file): Merge `wl-news-news-file'
+       and `wl-news-news-file-ja'.
+       (wl-news-search-regexp): New variable.
+       (wl-news-news-file): New function.
+       (wl-news-parse-news): Merge `wl-news-parse-news'
+       and `wl-news-parse-news-ja'.
+       (wl-news-parse-news-subr): New function.
+
+2002-12-20  Kenichi OKADA  <okada@opaopa.org>
+
        * WL-CFG (wl-news-lang): New variable.
 
 2002-12-20  Kenichi OKADA  <okada@opaopa.org>
diff --git a/WL-MK b/WL-MK
index 501ab4d..521e87d 100644 (file)
--- a/WL-MK
+++ b/WL-MK
   "The language of info file (\"ja\" or \"en\").")
 
 ;;; NEWS
-(defconst wl-news-news-file "NEWS")
-(defconst wl-news-news-file-ja "NEWS.ja")
+(defvar wl-news-lang '("ja" "en")
+  "The language of news file (\"ja\" or \"en\").")
+(defconst wl-news-news-file '(("en" "NEWS")
+                             ("ja" "NEWS.ja")))
+(defconst wl-news-search-regexp
+  '(("en" "^\\* Changes in \\([0-9.]*\\) from")
+    ("ja" "^\\* [0-9.]* \e$B$+$i\e(B \\([0-9.]*\\) \e$B$X$NJQ99E@\e(B")))
 (defconst wl-news-filename "wl-news.el")
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; wl-news stuff
 
+(defun wl-news-news-file (lang)
+  (cadr (assoc lang wl-news-news-file)))
+
+(defun wl-news-check-newer (out-filename news-lang)
+  (let ((lang news-lang)
+       ret)
+    (while (car lang)
+      (if (file-newer-than-file-p
+          (wl-news-news-file (car lang)) out-filename)
+         (setq ret t))
+      (setq lang (cdr lang)))
+    ret))
+
 (defun make-wl-news ()
   (let ((in-filename
         (expand-file-name (concat wl-news-filename ".in") WLDIR))
        (out-filename
-        (expand-file-name wl-news-filename WLDIR)))
+        (expand-file-name wl-news-filename WLDIR))
+       (wl-news-lang (if (listp wl-news-lang)
+                         wl-news-lang
+                       (list wl-news-lang))))
     (if (or (file-newer-than-file-p in-filename out-filename)
-           (file-newer-than-file-p wl-news-news-file out-filename)
-           (file-newer-than-file-p wl-news-news-file-ja out-filename))
+           (wl-news-check-newer out-filename wl-news-lang))
        (with-temp-buffer
          (save-excursion
            (insert-file-contents in-filename)
            (unless (re-search-forward "^;;; -\\*- news-list -\\*-" nil t)
              (error "Invalid wl-news.el.in"))
            (forward-line 2)
+           (insert "(defvar wl-news-lang '")
+           (prin1 wl-news-lang (current-buffer))
+           (insert ")\n")
            (insert "(defconst wl-news-news-alist\n  '")
-           (prin1 (wl-news-parse-news) (current-buffer))
-           (insert ")\n\n")
-           (insert "(defconst wl-news-news-ja-alist\n  '")
-           (prin1 (wl-news-parse-news-ja) (current-buffer))
+           (prin1 (wl-news-parse-news wl-news-lang) (current-buffer))
            (insert ")\n")
            (write-region (point-min) (point-max) out-filename))))))
 
-(defun wl-news-parse-news ()
-  (let (news-list)
-    (with-temp-buffer
-      (insert-file-contents wl-news-news-file)
-      (while (re-search-forward "^\\* Changes in \\([0-9.]*\\) from" nil t)
-       (let ((beg (match-beginning 0))
-             (version-tmp (split-string (match-string 1) "\\."))
-              version news-string end)
-         (while version-tmp
-           (setq version (append version (list (string-to-int (car version-tmp)))))
-           (setq version-tmp (cdr version-tmp)))
-         (re-search-forward "^\\(\\* \\|\f\\)" nil t)
-         (goto-char (- (match-beginning 0) 1))
-         (setq end (point))
-         (setq news-string (buffer-substring beg end))
-         (setq news-list
-               (append news-list
-                       (list (cons version news-string)))))))
-    news-list))
-
-(defun wl-news-parse-news-ja ()
+(defun wl-news-parse-news (lang)
   (let (news-list)
-    (with-temp-buffer
-      (insert-file-contents wl-news-news-file-ja)
-      (while (re-search-forward "^\\* [0-9.]* \e$B$+$i\e(B \\([0-9.]*\\) \e$B$X$NJQ99E@\e(B" nil t)
-       (let ((beg (match-beginning 0))
-             (version-tmp (split-string (match-string 1) "\\."))
-              version news-string end)
-         (while version-tmp
-           (setq version (append version (list (string-to-int (car version-tmp)))))
-           (setq version-tmp (cdr version-tmp)))
-         (re-search-forward "^\\(\\* \\|\f\\)" nil t)
-         (goto-char (- (match-beginning 0) 1))
-         (setq end (point))
-         (setq news-string (buffer-substring beg end))
-         (setq news-list
-               (append news-list
-                       (list (cons version news-string)))))))
+  (while (car lang)
+    (setq news-list (cons
+                       (cons (car lang) (wl-news-parse-news-subr (car lang)))
+                       news-list))
+    (setq lang (cdr lang)))
+  news-list))
+
+(defun wl-news-parse-news-subr (lang)
+  (let ((filename (wl-news-news-file lang))
+       (reg (cadr (assoc lang wl-news-search-regexp)))
+       news-list)
+    (if (and filename reg)
+       (with-temp-buffer
+         (insert-file-contents filename)
+         (while (re-search-forward reg nil t)
+           (let ((beg (match-beginning 0))
+                 (version-tmp (split-string (match-string 1) "\\."))
+                 version news-string end)
+             (while version-tmp
+               (setq version (append version (list (string-to-int (car version-tmp)))))
+               (setq version-tmp (cdr version-tmp)))
+             (re-search-forward "^\\(\\* \\|\f\\)" nil t)
+             (goto-char (- (match-beginning 0) 1))
+             (setq end (point))
+             (setq news-string (buffer-substring beg end))
+             (setq news-list
+                   (append news-list
+                           (list (cons version news-string))))))))
     news-list))
 
 
-
 \f
 ;;; ToDo
 ;;; * MORE refine code (^_^;
index 46f756a..f4647f4 100644 (file)
@@ -1,5 +1,11 @@
 2002-12-20  Kenichi OKADA  <okada@opaopa.org>
 
+       * wl-news.el.in (wl-news-check): Fix for `wl-news-lang'.
+       (wl-news-append-news): New function.
+       (wl-news-send-news): New function.
+
+2002-12-20  Kenichi OKADA  <okada@opaopa.org>
+
        * Version number is increased to 2.11.1.
 
 2002-12-19  Kenichi OKADA  <okada@opaopa.org>
index 075d497..80f459d 100644 (file)
@@ -37,6 +37,7 @@
 (require 'wl-address)
 (require 'wl-draft)
 (require 'wl-folder)
+(require 'wl-mime)
 
 (defvar wl-news-version-file-name "previous-version")
 (defvar wl-news-default-previous-version '(2 0 0))
@@ -46,7 +47,8 @@
        (current-version (product-version (product-find 'wl-version))))
     (if (and (< 0 (product-version-compare
                   current-version previous-version))
-            (wl-news-append-news-to-folder previous-version))
+            wl-news-lang
+            (wl-news-send-news previous-version))
        (wl-news-previous-version-save current-version))))
 
 
        (message "%s is not writable." filename))
       (kill-buffer tmp-buffer))))
 
-(defun wl-news-append-news-to-folder (previous-version)
-  (let ((news-list wl-news-news-alist)
-       (news-list-ja wl-news-news-ja-alist))
-    (with-temp-buffer
-      (insert "Subject: Wanderlust NEWS\n"
-             "From: \"WL Release 'Bot\"\n"
-             "To: " (wl-address-header-extract-address wl-from) "\n"
-             "Date: " (wl-make-date-string) "\n"
-             "Message-ID: " (funcall wl-message-id-function) "\n"
-             "Content-Type: multipart/mixed;\n\tboundary=Multipart\n\n"
-             "--Multipart\n"
-             "Content-Type: text/plain\n\n")
-      (while (< 0
-               (product-version-compare
-                (car (car news-list))
-                previous-version))
-       (insert (cdr (car news-list)) "\n\n")
-       (setq news-list (cdr news-list)))
-      (insert "--Multipart\n")
-      (insert "Content-Type: text/plain; charset=ISO-2022-JP\n\n")
-      (while (< 0
-               (product-version-compare
-                (car (car news-list-ja))
-                previous-version))
-       (insert (cdr (car news-list-ja)) "\n\n")
-       (setq news-list-ja (cdr news-list-ja)))
-      (encode-coding-region (point-min) (point-max) 'iso-2022-7bit)
-      (if (elmo-folder-writable-p (wl-folder-get-elmo-folder wl-draft-folder))
-         (elmo-folder-append-buffer
-          (wl-folder-get-elmo-folder wl-default-folder) t)))))
+(defun wl-news-append-news (lang previous-version)
+  (let* ((news-list (cdr (assoc lang wl-news-news-alist))))
+    (mime-edit-insert-tag "text" "plain" "" "")
+    (while (< 0
+             (product-version-compare
+              (car (car news-list))
+              previous-version))
+      (insert (cdr (car news-list)) "\n\n")
+      (setq news-list (cdr news-list)))))
+
+(defun wl-news-send-news (previous-version)
+  (let ((lang (if (listp wl-news-lang)
+                 wl-news-lang
+               (list wl-news-lang))))
+    (save-window-excursion
+      (wl-draft-create-buffer)
+      (wl-draft-create-contents
+          (list (cons 'From "WL Release 'Bot <wl@lists.airs.net>")
+                (cons 'To (wl-draft-eword-encode-address-list wl-from) )
+                (cons 'Subject "Wanderlust NEWS")
+                (cons 'User-Agent wl-generate-mailer-string-function)
+                (cons 'Organization wl-organization)
+                (and wl-auto-insert-x-face
+                     (file-exists-p wl-x-face-file)
+                     'wl-draft-insert-x-face-field-here)))
+      (wl-draft-insert-mail-header-separator)
+      (wl-draft-prepare-edit)
+      (goto-char (point-max))
+      (while (car lang)
+       (wl-news-append-news
+        (car lang) previous-version)
+       (setq lang (cdr lang)))
+      (let (wl-interactive-send)
+       (wl-draft-send 'kill-when-done)))))
 
 (require 'product)
 (product-provide (provide 'wl-news) (require 'wl-version))