This commit was manufactured by cvs2svn to create branch 'wl-2_8'.
[elisp/wanderlust.git] / wl / wl-version.el
1 ;;; wl-version.el --- Version information for Wanderlust.
2
3 ;; Copyright (C) 2000-2001 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 2000-2001 TAKAHASHI Kaoru <kaoru@kaisei.org>
5
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;;      TAKAHASHI Kaoru <kaoru@kaisei.org>
8 ;; Keywords: mail, net news
9
10 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
11
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
16 ;;
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ;; GNU General Public License for more details.
21 ;;
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26 ;;
27
28 ;;; Commentary:
29 ;;
30 ;; Put the following lines to each file of Wanderlust package.
31 ;;
32 ;; (require 'product)
33 ;; (product-provide (provide FEATURE) (require 'wl-version))
34
35 ;;; Code:
36 ;;
37 (require 'product)
38 (require 'elmo-version)                 ; product-version-as-string
39 (eval-when-compile
40   (require 'elmo-util))                 ; elmo-match-string
41 (provide 'wl-version)                   ; before product-provide
42
43 ;; product-define in the first place
44 (product-provide 'wl-version
45   (product-define
46    "Wanderlust" nil
47    (eval-when-compile
48      (product-version (product-find 'elmo-version))) ; equals to ELMO version.
49    "Something-pre2"))
50
51 (defconst wl-version-status nil
52   "Wanderlust verstion status.  For override default rule.
53 If nil, use default rule.")
54
55 \f
56 ;; set version-string
57 (product-version-as-string 'wl-version)
58
59 (defun wl-version ()
60   "Print Wanderlust version.
61 Don't support insert string at-point (C-u M-x wl-version).
62 For bug report, use `wl-generate-user-agent-string-1' instead.
63 When non-interactive, use `product-string-1' instead."
64   (interactive)
65   (let ((product-info (product-string-1 'wl-version t)))
66     (if (interactive-p)
67         (message "%s" product-info)
68       product-info)))
69
70 (defun wl-version-status ()
71   "Return version status string.
72 If variable `wl-version-status' is non-nil, override default rule."
73   (or wl-version-status
74       (if (zerop (% (nth 1 (product-version (product-find 'wl-version))) 2))
75           "stable"
76         "beta")))
77
78 ;; avoid compile warnings
79 (defvar mule-version)
80 (defvar emacs-beta-version)
81 (defvar xemacs-codename)
82 (defvar mime-edit-insert-user-agent-field)
83 (defvar mime-edit-user-agent-value)
84 (defvar mime-editor/version)
85 (defvar mime-editor/codename)
86
87 (defun wl-generate-user-agent-string ()
88   "A candidate of `wl-generate-mailer-string-function'.
89 Insert User-Agent field instead of X-Mailer field."
90   (concat "User-Agent: "
91           (wl-generate-user-agent-string-1
92            ;; for backward compatibility
93            (and (boundp 'mime-edit-insert-user-agent-field)
94                 mime-edit-insert-user-agent-field))))
95
96 (defun wl-generate-user-agent-string-1 (&optional verbose)
97   "Return User-Agent field value.
98 If VERBOSE return with SEMI, FLIM and APEL version."
99   (cond
100    ;; Don't use `product-string-verbose' for short User-Agent field value.
101    ((not verbose)
102     (concat (product-string-1 'wl-version t) " "
103             (wl-extended-emacs-version3 "/" t)))
104    ;; SEMI (verbose)
105    ((and (boundp 'mime-edit-user-agent-value) mime-edit-user-agent-value)
106     (concat (product-string-verbose 'wl-version) " "
107             mime-edit-user-agent-value))
108    ;; error case
109    (t
110     (product-string-1 'wl-version nil))))
111
112 ;; from gnus
113 (defun wl-extended-emacs-version (&optional with-codename)
114   "Stringified Emacs version.
115 If WITH-CODENAME add XEmacs codename."
116   (cond
117    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
118     (concat "Emacs " (elmo-match-string 1 emacs-version)
119             (when (boundp 'mule-version) (concat "/Mule " mule-version))))
120    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
121                   emacs-version)
122     (concat (elmo-match-string 1 emacs-version)
123             (format " %d.%d" emacs-major-version emacs-minor-version)
124             (when (and (boundp 'emacs-beta-version) emacs-beta-version)
125               (format "b%d" emacs-beta-version))
126             (when (and with-codename
127                        (boundp 'xemacs-codename) xemacs-codename)
128               (concat " - \"" xemacs-codename "\""))))
129    (t emacs-version)))
130
131 (defun wl-extended-emacs-version2 (&optional delimiter with-codename)
132   "Stringified Emacs version.
133 Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
134   (cond
135    ((and (boundp 'mule-version) mule-version
136          (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
137     (format "Mule%s%s@%d.%d%s"
138             (or delimiter " ")
139             (elmo-match-string 1 mule-version)
140             emacs-major-version
141             emacs-minor-version
142             (if with-codename
143                 (elmo-match-string 2 mule-version)
144               "")))
145    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
146     (concat "Emacs" (or delimiter " ")
147             (elmo-match-string 1 emacs-version)))
148    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
149                   emacs-version)
150     (concat (elmo-match-string 1 emacs-version)
151             (or delimiter " ")
152             (format "%d.%d" emacs-major-version emacs-minor-version)
153             (when (and (boundp 'emacs-beta-version) emacs-beta-version)
154               (format "b%d" emacs-beta-version))
155             (when (and with-codename
156                        (boundp 'xemacs-codename) xemacs-codename)
157               (format " (%s)" xemacs-codename))))
158    (t emacs-version)))
159
160 (defun wl-extended-emacs-version3 (&optional delimiter with-codename)
161   "Stringified Emacs version.
162 Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
163   (cond
164    ((and (boundp 'mule-version) mule-version
165          (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
166     (format "Emacs%s%d.%d Mule%s%s%s"
167             (or delimiter " ")
168             emacs-major-version
169             emacs-minor-version
170             (or delimiter " ")
171             (elmo-match-string 1 mule-version)
172             (if with-codename
173                 (elmo-match-string 2 mule-version)
174               "")))
175    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
176     (concat "Emacs" (or delimiter " ")
177             (elmo-match-string 1 emacs-version)))
178    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
179                   emacs-version)
180     (concat (elmo-match-string 1 emacs-version)
181             (or delimiter " ")
182             (format "%d.%d" emacs-major-version emacs-minor-version)
183             (when (and (boundp 'emacs-beta-version) emacs-beta-version)
184               (format "b%d" emacs-beta-version))
185             (when (and with-codename
186                        (boundp 'xemacs-codename) xemacs-codename)
187               (format " (%s)" xemacs-codename))))
188    (t emacs-version)))
189
190
191 ;; for backward compatibility
192 (defconst wl-appname (product-name (product-find 'wl-version)))
193 (make-obsolete-variable
194  'wl-appname
195  "use (product-name (product-find 'wl-version)) insteaed.")
196
197 (defconst wl-version (product-version-string (product-find 'wl-version)))
198 (make-obsolete-variable
199  'wl-version
200  "use (product-version-string (product-find 'wl-version)) instead.")
201
202 (defconst wl-codename (product-code-name (product-find 'wl-version)))
203 (make-obsolete-variable
204  'wl-codename
205  "use (product-code-name (product-find 'wl-version)) instead.")
206
207 ;;; wl-version.el ends here