* wl-version.el (wl-version): Changed codename to "Rio-pre2".
[elisp/wanderlust.git] / wl / wl-version.el
1 ;;; wl-version.el -- Version information for Wanderlust.
2
3 ;; Copyright (C) 2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 2000 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
31 ;;; Code:
32 ;;
33 (require 'product)
34 (require 'elmo-version)                 ; product-version-as-string
35 (provide 'wl-version)                   ; before product-provide
36
37 ;; product-define in the first place
38 (product-provide 'wl-version
39   (product-define
40    "Wanderlust" nil
41    (eval-when-compile
42      (product-version (product-find 'elmo-version))) ; equals to ELMO version.
43    "Rio-pre2"))
44
45 ;; set version-string
46 (product-version-as-string 'wl-version)
47
48 ;; require wl-util after product-provide.
49 (eval-when-compile (require 'wl-util))  ; wl-match-string
50
51 (defun wl-version (&optional with-codename)
52   "Return Wanderlust version.
53 If WITH-CODENAME add codename."
54   (product-string-1 'wl-version with-codename))
55
56 (defun wl-version-show (&optional arg)
57   "Print Wanderlust version.
58 If ARG insert string at point."
59   (interactive "P")
60   (if arg
61       (insert (message "%s" (wl-version t)))
62     (message "%s" (wl-version t))))
63
64 (defvar wl-version-status-alist
65   '(((eq (% (nth 1 (product-version (product-find 'wl-version))) 2) 0)
66      . "stable")
67     (t . "beta"))
68   "An alist to define the version status.")
69
70 (defun wl-version-status ()
71   "Return version status (\"stable\" or \"beta\")."
72   (let ((salist wl-version-status-alist)
73         status)
74     (while salist
75       (when (eval (car (car salist)))
76         (setq status (cdr (car salist)))
77         (setq salist nil))
78       (setq salist (cdr salist)))
79     status))
80
81 ;; compile warning
82 (defvar mule-version)
83 (defvar nemacs-version)
84 (defvar emacs-beta-version)
85 (defvar xemacs-codename)
86 (defvar mime-edit-insert-user-agent-field)
87 (defvar mime-edit-user-agent-value)
88 (defvar mime-editor/version)
89 (defvar mime-editor/codename)
90
91 (defun wl-generate-user-agent-string ()
92   "A candidate of `wl-generate-mailer-string-func'.
93 Insert User-Agent field instead of X-Mailer field."
94   (concat "User-Agent: "
95           (wl-generate-user-agent-string-1
96            (or (and (boundp 'mime-edit-insert-user-agent-field)
97                     mime-edit-insert-user-agent-field)
98                (and (boundp 'mime-editor/version)
99                     mime-editor/version)))))
100
101 (defun wl-generate-user-agent-string-1 (&optional verbose)
102   "Return User-Agent field value.
103 If VERBOSE return with SEMI, FLIM and APEL version."
104   (if (not verbose)
105       ;; Don't use product-string-verbose for short User-Agent field value.
106       (concat (product-string-1 'wl-version t) " "
107               (wl-extended-emacs-version3 "/" t))
108     ;; verbose
109     (cond
110      ;; SEMI
111      ((and (boundp 'mime-edit-user-agent-value) mime-edit-user-agent-value)
112       (concat (product-string-verbose 'wl-version) " "
113               mime-edit-user-agent-value))
114      ;; tm
115      ((and (boundp 'mime-editor/version) mime-editor/version)
116       (concat (product-string-verbose 'wl-version) " "
117               "tm/" mime-editor/version
118               (if (and (boundp 'mime-editor/codename)
119                        mime-editor/codename)
120                   (concat " (" mime-editor/codename ")"))
121               (if (and (boundp 'mime-library-product)
122                        mime-library-product)
123                   (concat " " (aref mime-library-product 0)
124                           "/"
125                           (mapconcat 'int-to-string
126                                      (aref mime-library-product 1)
127                                      ".")
128                           " (" (aref mime-library-product 2) ")"))
129               (condition-case nil
130                   (progn
131                     (require 'apel-ver)
132                     (concat " " (apel-version)))
133                 (file-error nil))
134               " " (wl-extended-emacs-version3 "/" t)))
135      ;; error case
136      (t
137       (product-string-1 'wl-version nil)))))
138
139 ;; from gnus
140 (defun wl-extended-emacs-version (&optional with-codename)
141   "Stringified Emacs version.
142 If WITH-CODENAME add XEmacs codename."
143   (cond
144    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
145     (concat "Emacs " (wl-match-string 1 emacs-version)
146             (and (boundp 'mule-version)(concat "/Mule " mule-version))))
147    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
148                   emacs-version)
149     (concat (wl-match-string 1 emacs-version)
150             (format " %d.%d" emacs-major-version emacs-minor-version)
151             (if (and (boundp 'emacs-beta-version)
152                      emacs-beta-version)
153                 (format "b%d" emacs-beta-version))
154             (if with-codename
155                 (if (boundp 'xemacs-codename)
156                     (concat " - \"" xemacs-codename "\"")))))
157    (t emacs-version)))
158
159 (defun wl-extended-emacs-version2 (&optional delimiter with-codename)
160   "Stringified Emacs version.
161 Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
162   (cond
163    ((and (boundp 'mule-version)
164          mule-version
165          (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
166     (format "Mule%s%s@%d.%d%s"
167             (or delimiter " ")
168             (wl-match-string 1 mule-version)
169             emacs-major-version
170             emacs-minor-version
171             (if with-codename
172                 (wl-match-string 2 mule-version)
173               "")))
174    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
175     (if (boundp 'nemacs-version)
176         (concat "Nemacs" (or delimiter " ")
177                 nemacs-version
178                 "@"
179                 (substring emacs-version
180                            (match-beginning 1)
181                            (match-end 1)))
182       (concat "Emacs" (or delimiter " ")
183               (wl-match-string 1 emacs-version))))
184    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
185                   emacs-version)
186     (concat (wl-match-string 1 emacs-version)
187             (or delimiter " ")
188             (format "%d.%d" emacs-major-version emacs-minor-version)
189             (if (and (boundp 'emacs-beta-version)
190                      emacs-beta-version)
191                 (format "b%d" emacs-beta-version))
192             (if (and with-codename
193                      (boundp 'xemacs-codename)
194                      xemacs-codename)
195                 (format " (%s)" xemacs-codename))))
196    (t emacs-version)))
197
198 (defun wl-extended-emacs-version3 (&optional delimiter with-codename)
199   "Stringified Emacs version.
200 Separate DELIMITER (default is \" \").  If WITH-CODENAME add XEmacs codename."
201   (cond
202    ((and (boundp 'mule-version)
203          mule-version
204          (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
205     (format "Emacs%s%d.%d Mule%s%s%s"
206             (or delimiter " ")
207             emacs-major-version
208             emacs-minor-version
209             (or delimiter " ")
210             (wl-match-string 1 mule-version)
211             (if with-codename
212                 (wl-match-string 2 mule-version)
213               "")))
214    ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
215     (if (boundp 'nemacs-version)
216         (let ((nemacs-codename-assoc '(("3.3.2" . " (FUJIMUSUME)")
217                                        ("3.3.1" . " (HINAMATSURI)")
218                                        ("3.2.3" . " (YUMENO-AWAYUKI)"))))
219           (format "Emacs%s%s Nemacs%s%s%s"
220                   (or delimiter " ")
221                   (wl-match-string 1 emacs-version)
222                   (or delimiter " ")
223                   nemacs-version
224                   (or (and with-codename
225                            (cdr (assoc nemacs-version
226                                        nemacs-codename-assoc)))
227                       "")))
228       (concat "Emacs" (or delimiter " ")
229               (wl-match-string 1 emacs-version))))
230    ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
231                   emacs-version)
232     (concat (wl-match-string 1 emacs-version)
233             (or delimiter " ")
234             (format "%d.%d" emacs-major-version emacs-minor-version)
235             (if (and (boundp 'emacs-beta-version)
236                      emacs-beta-version)
237                 (format "b%d" emacs-beta-version))
238             (if (and with-codename
239                      (boundp 'xemacs-codename)
240                      xemacs-codename)
241                 (format " (%s)" xemacs-codename))))
242    (t emacs-version)))
243
244
245 ;; for backward compatibility
246 (defconst wl-appname (product-name (product-find 'wl-version)))
247 (make-obsolete-variable
248  'wl-appname
249  "use (product-name (product-find 'wl-version)) insteaed.")
250
251 (defconst wl-version (product-version-string (product-find 'wl-version)))
252 (make-obsolete-variable
253  'wl-version
254  "use (product-version-string (product-find 'wl-version)) instead.")
255
256 (defconst wl-codename (product-code-name (product-find 'wl-version)))
257 (make-obsolete-variable
258  'wl-codename
259  "use (product-code-name (product-find 'wl-version)) instead.")
260
261 ;;; wl-version.el ends here