From caeb243df67cd93b1dea69d782c3f1705cbb65ff Mon Sep 17 00:00:00 2001 From: okada Date: Thu, 19 Dec 2002 15:26:22 +0000 Subject: [PATCH] * WL-MK (make-wl-news): New function. (wl-news-parse-news): New function. (wl-news-parse-news-ja): New function. (compile-wl-package): Do `make-wl-news'. (wl-news-news-file): New variable. (wl-news-news-file-ja): New variable. (wl-news-filename: New variable. * wl-news.el.el : New file. --- ChangeLog | 10 +++++ Makefile | 2 +- WL-ELS | 2 +- WL-MK | 75 ++++++++++++++++++++++++++++++++ wl/ChangeLog | 4 ++ wl/wl-news.el.in | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ wl/wl.el | 2 + 7 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 wl/wl-news.el.in diff --git a/ChangeLog b/ChangeLog index 990d0f9..81ce08f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-12-20 Kenichi OKADA + + * WL-MK (make-wl-news): New function. + (wl-news-parse-news): New function. + (wl-news-parse-news-ja): New function. + (compile-wl-package): Do `make-wl-news'. + (wl-news-news-file): New variable. + (wl-news-news-file-ja): New variable. + (wl-news-filename: New variable. + 2002-12-11 Yuuichi Teranishi * 2.10.0 - "Venus" diff --git a/Makefile b/Makefile index 68e7a7a..bea06b5 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ uninstall-elc: $(EMACS) $(FLAGS) -l WL-MK -f uninstall-wl-package $(LISPDIR) $(PIXMAPDIR) clean-elc: - rm -f wl/*.elc wl/*~ wl/auto-autoloads.el wl/custom-load.el elmo/*.elc utils/*.elc utils/hmac/lisp/*.elc + rm -f wl/*.elc wl/*~ wl/auto-autoloads.el wl/custom-load.el wl/wl-news.el elmo/*.elc utils/*.elc utils/hmac/lisp/*.elc package: $(XEMACS) $(FLAGS) -l WL-MK -f compile-wl-package-xmas $(PACKAGEDIR) $(PIXMAPDIR) diff --git a/WL-ELS b/WL-ELS index 4a0d9ca..6d68da0 100644 --- a/WL-ELS +++ b/WL-ELS @@ -10,7 +10,7 @@ wl wl-folder wl-summary wl-message wl-vars wl-draft wl-util wl-version wl-address wl-addrmgr wl-highlight wl-demo wl-refile wl-thread - wl-fldmgr wl-expire wl-template wl-score wl-acap + wl-fldmgr wl-expire wl-template wl-score wl-acap wl-news )) (defconst ELMO-MODULES '( diff --git a/WL-MK b/WL-MK index c42e4f3..501ab4d 100644 --- a/WL-MK +++ b/WL-MK @@ -31,6 +31,11 @@ (defvar wl-info-lang '("ja" "en") "The language of info file (\"ja\" or \"en\").") +;;; NEWS +(defconst wl-news-news-file "NEWS") +(defconst wl-news-news-file-ja "NEWS.ja") +(defconst wl-news-filename "wl-news.el") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'cl) @@ -221,6 +226,7 @@ (defun compile-wl-package () (config-wl-package) + (make-wl-news) (mapcar '(lambda (x) (compile-elisp-modules (cdr x) (car x))) @@ -434,6 +440,75 @@ (wl-texinfo-install)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; wl-news stuff + +(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))) + (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)) + (with-temp-buffer + (save-excursion + (insert-file-contents in-filename) + (goto-char (point-min)) + (unless (re-search-forward "^;;; -\\*- news-list -\\*-" nil t) + (error "Invalid wl-news.el.in")) + (forward-line 2) + (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)) + (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 () + (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))))))) + news-list)) + + + + ;;; ToDo ;;; * MORE refine code (^_^; diff --git a/wl/ChangeLog b/wl/ChangeLog index 7bb6f90..c14812b 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,5 +1,9 @@ 2002-12-19 Kenichi OKADA + * wl-news.el.el : New file. + +2002-12-19 Kenichi OKADA + * wl-vars.el (wl-draft-reply-with-argument-list): Change default value. (wl-draft-reply-without-argument-list): Ditto. diff --git a/wl/wl-news.el.in b/wl/wl-news.el.in new file mode 100644 index 0000000..075d497 --- /dev/null +++ b/wl/wl-news.el.in @@ -0,0 +1,128 @@ +;;; wl-news.el --- Create notification from NEWS(.ja) for Wanderlust. + +;; Copyright (C) 2002 Yoichi NAKAYAMA +;; Copyright (C) 2002 Kenichi OKADA + +;; Author: Yoichi NAKAYAMA +;; Kenichi OKADA +;; Keywords: mail, net news + +;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen). + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. +;; + +;;; Commentary: +;; + +;;; Code: +;; + +(require 'elmo) +(require 'wl-vars) +(require 'wl-util) +(require 'wl-address) +(require 'wl-draft) +(require 'wl-folder) + +(defvar wl-news-version-file-name "previous-version") +(defvar wl-news-default-previous-version '(2 0 0)) + +(defun wl-news-check () + (let ((previous-version (wl-news-previous-version-load)) + (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-previous-version-save current-version)))) + + +;;; -*- news-list -*- + + +;;; -*- news-list-end -*- + +(defun wl-news-previous-version-load () + (save-excursion + (let ((filename (expand-file-name + wl-news-version-file-name + elmo-msgdb-directory)) + (tmp-buffer (get-buffer-create " *wl-news-version-tmp*")) + insert-file-contents-pre-hook + insert-file-contents-post-hook + ret-val) + (if (not (file-readable-p filename)) + wl-news-default-previous-version + (set-buffer tmp-buffer) + (insert-file-contents filename) + (setq ret-val + (condition-case nil + (read (current-buffer)) + (error nil nil))) + (kill-buffer tmp-buffer) + ret-val)))) + +(defun wl-news-previous-version-save (version) + (save-excursion + (let ((filename (expand-file-name + wl-news-version-file-name + elmo-msgdb-directory)) + (tmp-buffer (get-buffer-create " *wl-news-version-tmp*"))) + (set-buffer tmp-buffer) + (erase-buffer) + (prin1 version tmp-buffer) + (princ "\n" tmp-buffer) + (if (file-writable-p filename) + (write-region (point-min) (point-max) + filename nil 'no-msg) + (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))))) + +(require 'product) +(product-provide (provide 'wl-news) (require 'wl-version)) + +;;; wl-news.el ends here diff --git a/wl/wl.el b/wl/wl.el index d2194c4..ea1807b 100644 --- a/wl/wl.el +++ b/wl/wl.el @@ -58,6 +58,7 @@ (require 'wl-summary) (require 'wl-thread) (require 'wl-address) +(require 'wl-news) (wl-draft-mode-setup) (require 'wl-draft) @@ -696,6 +697,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (symbol-value 'wl-summary-subject-filter-function)) (setq elmo-no-from wl-summary-no-from-message) (setq elmo-no-subject wl-summary-no-subject-message) + (wl-news-check) (setq wl-init t) ;; This hook may contain the functions `wl-plugged-init-icons' and ;; `wl-biff-init-icons' for reasons of system internal to accord -- 1.7.10.4