* WL-MK (make-wl-news): New function.
authorokada <okada>
Thu, 19 Dec 2002 15:26:22 +0000 (15:26 +0000)
committerokada <okada>
Thu, 19 Dec 2002 15:26:22 +0000 (15:26 +0000)
(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
Makefile
WL-ELS
WL-MK
wl/ChangeLog
wl/wl-news.el.in [new file with mode: 0644]
wl/wl.el

index 990d0f9..81ce08f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-12-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * 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  <teranisi@gohome.org>
 
        * 2.10.0 - "Venus"
index 68e7a7a..bea06b5 100644 (file)
--- 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 (file)
--- 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 (file)
--- a/WL-MK
+++ b/WL-MK
 (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")
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 \f
 (require 'cl)
 
 (defun compile-wl-package ()
   (config-wl-package)
+  (make-wl-news)
   (mapcar
    '(lambda (x)
       (compile-elisp-modules (cdr x) (car x)))
   (wl-texinfo-install))
 
 \f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; 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 "^\\(\\* \\|\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 ()
+  (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)))))))
+    news-list))
+
+
+
+\f
 ;;; ToDo
 ;;; * MORE refine code (^_^;
 
index 7bb6f90..c14812b 100644 (file)
@@ -1,5 +1,9 @@
 2002-12-19  Kenichi OKADA  <okada@opaopa.org>
 
+       * wl-news.el.el : New file.
+
+2002-12-19  Kenichi OKADA  <okada@opaopa.org>
+
        * 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 (file)
index 0000000..075d497
--- /dev/null
@@ -0,0 +1,128 @@
+;;; wl-news.el --- Create notification from NEWS(.ja) for Wanderlust.
+
+;; Copyright (C) 2002 Yoichi NAKAYAMA <yoichi@eken.phys.nagoya-u.ac.jp>
+;; Copyright (C) 2002 Kenichi OKADA <okada@opaopa.org>
+
+;; Author: Yoichi NAKAYAMA <yoichi@eken.phys.nagoya-u.ac.jp>
+;;     Kenichi OKADA <okada@opaopa.org>
+;; 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
index d2194c4..ea1807b 100644 (file)
--- 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