From 2dcfb29e6c0b26c6c87d1288287378acb82a2af5 Mon Sep 17 00:00:00 2001 From: okada Date: Thu, 19 Dec 2002 17:50:27 +0000 Subject: [PATCH] * 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. * 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 | 11 ++++++ WL-MK | 105 ++++++++++++++++++++++++++++++------------------------ wl/ChangeLog | 6 ++++ wl/wl-news.el.in | 68 +++++++++++++++++++---------------- 4 files changed, 112 insertions(+), 78 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5fac93b..305c470 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2002-12-20 Kenichi OKADA + * 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 + * WL-CFG (wl-news-lang): New variable. 2002-12-20 Kenichi OKADA diff --git a/WL-MK b/WL-MK index 501ab4d..521e87d 100644 --- a/WL-MK +++ b/WL-MK @@ -32,8 +32,13 @@ "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.]* から \\([0-9.]*\\) への変更点"))) (defconst wl-news-filename "wl-news.el") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -443,14 +448,29 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 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) @@ -458,56 +478,47 @@ (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 "^\\(\\* \\| \\)" 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.]* から \\([0-9.]*\\) への変更点" 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 "^\\(\\* \\| \\)" 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 "^\\(\\* \\| \\)" 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)) - ;;; ToDo ;;; * MORE refine code (^_^; diff --git a/wl/ChangeLog b/wl/ChangeLog index 46f756a..f4647f4 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,5 +1,11 @@ 2002-12-20 Kenichi OKADA + * 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 + * Version number is increased to 2.11.1. 2002-12-19 Kenichi OKADA diff --git a/wl/wl-news.el.in b/wl/wl-news.el.in index 075d497..80f459d 100644 --- a/wl/wl-news.el.in +++ b/wl/wl-news.el.in @@ -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)))) @@ -91,36 +93,40 @@ (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 ") + (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)) -- 1.7.10.4