* wl-folder.el (wl-folder-guess-mailing-list-by-refile-rule): Fix.
[elisp/wanderlust.git] / wl / wl-version.el
index 0258f4b..40019e2 100644 (file)
@@ -1,8 +1,10 @@
 ;;; wl-version.el -- Version information for Wanderlust.
 
-;; Copyright 2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 2000-2001 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 2000-2001 TAKAHASHI Kaoru <kaoru@kaisei.org>
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
+;;     TAKAHASHI Kaoru <kaoru@kaisei.org>
 ;; Keywords: mail, net news
 
 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
 
 ;;; Commentary:
 ;;
+;; Put the following lines to each file of Wanderlust package.
+;;
+;; (require 'product)
+;; (product-provide (provide FEATURE) (require 'wl-version))
 
 ;;; Code:
 ;;
 (require 'product)
-(provide 'wl-version)                  ; have to declare in the top.
+(require 'elmo-version)                        ; product-version-as-string
+(eval-when-compile
+  (require 'elmo-util))                        ; elmo-match-string
+(provide 'wl-version)                  ; before product-provide
 
+;; product-define in the first place
 (product-provide 'wl-version
   (product-define
    "Wanderlust" nil
    (eval-when-compile
-     (require 'elmo-version)
      (product-version (product-find 'elmo-version))) ; equals to ELMO version.
-   "Roam"))
-
-;; set version-string
-(if (fboundp 'product-version-as-string)
-    (product-version-as-string 'wl-version)
-  (product-string-1 'wl-version))      ; APEL 10.2 or earlier.
-
-;; require wl-util after product-provide.
-(eval-when-compile (require 'wl-util)) ; wl-match-string
+   "Smooth Criminal"))
 
-(defun wl-version (&optional with-codename)
-  "Return Wanderlust version.
-If WITH-CODENAME add codename."
-  (product-string-1 'wl-version with-codename))
+(defconst wl-version-status "alpha"
+  "Wanderlust verstion status.  For override default rule.
+If nil, use default rule.")
 
-(defun wl-version-show (&optional arg)
-  "Print Wanderlust version.
-If ARG insert string at point."
-  (interactive "P")
-  (if arg
-      (insert (message "%s" (wl-version t)))
-    (message "%s" (wl-version t))))
-
-(defvar wl-version-status-alist
-  '(((eq (% (nth 1 (product-version (product-find 'wl-version))) 2) 0)
-     . "stable")
-    (t . "beta"))
-  "An alist to define the version status.")
+\f
+;; set version-string
+(product-version-as-string 'wl-version)
+
+;; Don't support insert string at-point (C-u M-x wl-version).
+;; For bug report, use `wl-generate-user-agent-string-1' instead.
+;; When non-interactive, use `product-string-1' instead.
+(defun wl-version ()
+  "Print Wanderlust version."
+  (interactive)
+  (let ((product-info (product-string-1 'wl-version t)))
+    (if (interactive-p)
+       (message "%s" product-info)
+      product-info)))
 
 (defun wl-version-status ()
-  "Return version status (\"stable\" or \"beta\")."
-  (let ((salist wl-version-status-alist)
-       status)
-    (while salist
-      (when (eval (car (car salist)))
-       (setq status (cdr (car salist)))
-       (setq salist nil))
-      (setq salist (cdr salist)))
-    status))
+  "Return version status string."
+  (or wl-version-status
+      (if (zerop (% (nth 1 (product-version (product-find 'wl-version))) 2))
+         "stable"
+       "beta")))
 
-;; compile warning
+;; avoid compile warnings
 (defvar mule-version)
 (defvar nemacs-version)
 (defvar emacs-beta-version)
@@ -88,43 +85,40 @@ If ARG insert string at point."
 (defvar mime-editor/codename)
 
 (defun wl-generate-user-agent-string ()
-  "A candidate of `wl-generate-mailer-string-func'.
+  "A candidate of `wl-generate-mailer-string-function'.
 Insert User-Agent field instead of X-Mailer field."
   (concat "User-Agent: "
          (wl-generate-user-agent-string-1
+          ;; for backward compatibility
           (or (and (boundp 'mime-edit-insert-user-agent-field)
-                   mime-edit-insert-user-agent-field)
+                   mime-edit-insert-user-agent-field) ; SEMI
               (and (boundp 'mime-editor/version)
-                   mime-editor/version)))))
+                   mime-editor/version))))) ; verbose User-Agent when tm
 
 (defun wl-generate-user-agent-string-1 (&optional verbose)
   "Return User-Agent field value.
 If VERBOSE return with SEMI, FLIM and APEL version."
   (cond
-   ;; non-verbose
+   ;; Don't use `product-string-verbose' for short User-Agent field value.
    ((not verbose)
-    ;; Don't use product-string-verbose for short User-Agent field value.
     (concat (product-string-1 'wl-version t) " "
            (wl-extended-emacs-version3 "/" t)))
-   ;; SEMI
+   ;; SEMI (verbose)
    ((and (boundp 'mime-edit-user-agent-value) mime-edit-user-agent-value)
     (concat (product-string-verbose 'wl-version) " "
            mime-edit-user-agent-value))
-   ;; tm
+   ;; tm (verbose)
    ((and (boundp 'mime-editor/version) mime-editor/version)
     (concat (product-string-verbose 'wl-version) " "
            "tm/" mime-editor/version
-           (if (and (boundp 'mime-editor/codename)
-                    mime-editor/codename)
-               (concat " (" mime-editor/codename ")"))
-           (if (and (boundp 'mime-library-product)
-                    mime-library-product)
-               (concat " " (aref mime-library-product 0)
-                       "/"
-                       (mapconcat 'int-to-string
-                                  (aref mime-library-product 1)
-                                  ".")
-                       " (" (aref mime-library-product 2) ")"))
+           (when (and (boundp 'mime-editor/codename) mime-editor/codename)
+             (concat " (" mime-editor/codename ")"))
+           (when (and (boundp 'mime-library-product) mime-library-product)
+             (concat " " (aref mime-library-product 0)
+                     "/" (mapconcat 'int-to-string
+                                    (aref mime-library-product 1)
+                                    ".")
+                     " (" (aref mime-library-product 2) ")"))
            (condition-case nil
                (progn
                  (require 'apel-ver)
@@ -141,34 +135,32 @@ If VERBOSE return with SEMI, FLIM and APEL version."
 If WITH-CODENAME add XEmacs codename."
   (cond
    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
-    (concat "Emacs " (wl-match-string 1 emacs-version)
-           (and (boundp 'mule-version)(concat "/Mule " mule-version))))
+    (concat "Emacs " (elmo-match-string 1 emacs-version)
+           (when (boundp 'mule-version) (concat "/Mule " mule-version))))
    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
                  emacs-version)
-    (concat (wl-match-string 1 emacs-version)
+    (concat (elmo-match-string 1 emacs-version)
            (format " %d.%d" emacs-major-version emacs-minor-version)
-           (if (and (boundp 'emacs-beta-version)
-                    emacs-beta-version)
-               (format "b%d" emacs-beta-version))
-           (if with-codename
-               (if (boundp 'xemacs-codename)
-                   (concat " - \"" xemacs-codename "\"")))))
+           (when (and (boundp 'emacs-beta-version) emacs-beta-version)
+             (format "b%d" emacs-beta-version))
+           (when (and with-codename
+                      (boundp 'xemacs-codename) xemacs-codename)
+             (concat " - \"" xemacs-codename "\""))))
    (t emacs-version)))
 
 (defun wl-extended-emacs-version2 (&optional delimiter with-codename)
   "Stringified Emacs version.
 Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
   (cond
-   ((and (boundp 'mule-version)
-        mule-version
+   ((and (boundp 'mule-version) mule-version
         (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
     (format "Mule%s%s@%d.%d%s"
            (or delimiter " ")
-           (wl-match-string 1 mule-version)
+           (elmo-match-string 1 mule-version)
            emacs-major-version
            emacs-minor-version
            (if with-codename
-               (wl-match-string 2 mule-version)
+               (elmo-match-string 2 mule-version)
              "")))
    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
     (if (boundp 'nemacs-version)
@@ -179,36 +171,33 @@ Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
                           (match-beginning 1)
                           (match-end 1)))
       (concat "Emacs" (or delimiter " ")
-             (wl-match-string 1 emacs-version))))
+             (elmo-match-string 1 emacs-version))))
    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
                  emacs-version)
-    (concat (wl-match-string 1 emacs-version)
+    (concat (elmo-match-string 1 emacs-version)
            (or delimiter " ")
            (format "%d.%d" emacs-major-version emacs-minor-version)
-           (if (and (boundp 'emacs-beta-version)
-                    emacs-beta-version)
-               (format "b%d" emacs-beta-version))
-           (if (and with-codename
-                    (boundp 'xemacs-codename)
-                    xemacs-codename)
-               (format " (%s)" xemacs-codename))))
+           (when (and (boundp 'emacs-beta-version) emacs-beta-version)
+             (format "b%d" emacs-beta-version))
+           (when (and with-codename
+                      (boundp 'xemacs-codename) xemacs-codename)
+             (format " (%s)" xemacs-codename))))
    (t emacs-version)))
 
 (defun wl-extended-emacs-version3 (&optional delimiter with-codename)
   "Stringified Emacs version.
-Separate DELIMITER (default it \" \").  If WITH-CODENAME add XEmacs codename."
+Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
   (cond
-   ((and (boundp 'mule-version)
-        mule-version
+   ((and (boundp 'mule-version) mule-version
         (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
     (format "Emacs%s%d.%d Mule%s%s%s"
            (or delimiter " ")
            emacs-major-version
            emacs-minor-version
            (or delimiter " ")
-           (wl-match-string 1 mule-version)
+           (elmo-match-string 1 mule-version)
            (if with-codename
-               (wl-match-string 2 mule-version)
+               (elmo-match-string 2 mule-version)
              "")))
    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
     (if (boundp 'nemacs-version)
@@ -217,7 +206,7 @@ Separate DELIMITER (default it \" \").  If WITH-CODENAME add XEmacs codename."
                                       ("3.2.3" . " (YUMENO-AWAYUKI)"))))
          (format "Emacs%s%s Nemacs%s%s%s"
                  (or delimiter " ")
-                 (wl-match-string 1 emacs-version)
+                 (elmo-match-string 1 emacs-version)
                  (or delimiter " ")
                  nemacs-version
                  (or (and with-codename
@@ -225,19 +214,17 @@ Separate DELIMITER (default it \" \").  If WITH-CODENAME add XEmacs codename."
                                       nemacs-codename-assoc)))
                      "")))
       (concat "Emacs" (or delimiter " ")
-             (wl-match-string 1 emacs-version))))
+             (elmo-match-string 1 emacs-version))))
    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
                  emacs-version)
-    (concat (wl-match-string 1 emacs-version)
+    (concat (elmo-match-string 1 emacs-version)
            (or delimiter " ")
            (format "%d.%d" emacs-major-version emacs-minor-version)
-           (if (and (boundp 'emacs-beta-version)
-                    emacs-beta-version)
-               (format "b%d" emacs-beta-version))
-           (if (and with-codename
-                    (boundp 'xemacs-codename)
-                    xemacs-codename)
-               (format " (%s)" xemacs-codename))))
+           (when (and (boundp 'emacs-beta-version) emacs-beta-version)
+             (format "b%d" emacs-beta-version))
+           (when (and with-codename
+                      (boundp 'xemacs-codename) xemacs-codename)
+             (format " (%s)" xemacs-codename))))
    (t emacs-version)))