New feature: toggle visibility of mime buttons.
[more-wl.git] / wl / wl-version.el
blob4fdb1cb2cd025342e1d411d8577d07728d2ce41d
1 ;;; wl-version.el --- Version information for Wanderlust.
3 ;; Copyright (C) 2000-2001 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 2000-2001 TAKAHASHI Kaoru <kaoru@kaisei.org>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; TAKAHASHI Kaoru <kaoru@kaisei.org>
8 ;; Keywords: mail, net news
10 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
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.
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.
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.
28 ;;; Commentary:
30 ;; Put the following lines to each file of Wanderlust package.
32 ;; (require 'product)
33 ;; (product-provide (provide FEATURE) (require 'wl-version))
35 ;;; Code:
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
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 "Almost Unreal"))
51 (defconst wl-version-status nil
52 "Wanderlust verstion status. For override default rule.
53 If nil, use default rule.")
56 ;; set version-string
57 (product-version-as-string 'wl-version)
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)))
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")))
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)
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 (wl-generate-user-agent-string-1
91 ;; for backward compatibility
92 (and (boundp 'mime-edit-insert-user-agent-field)
93 mime-edit-insert-user-agent-field)))
95 (defun wl-generate-user-agent-string-1 (&optional verbose)
96 "Return User-Agent field value.
97 If VERBOSE return with SEMI, FLIM and APEL version."
98 (cond
99 ;; Don't use `product-string-verbose' for short User-Agent field value.
100 ((not verbose)
101 (concat (product-string-1 'wl-version t) " "
102 (wl-extended-emacs-version3 "/" t)))
103 ;; SEMI (verbose)
104 ((and (boundp 'mime-edit-user-agent-value) mime-edit-user-agent-value)
105 (concat (product-string-verbose 'wl-version) " "
106 mime-edit-user-agent-value))
107 ;; error case
109 (product-string-1 'wl-version nil))))
111 ;; from gnus
112 (defun wl-extended-emacs-version (&optional with-codename)
113 "Stringified Emacs version.
114 If WITH-CODENAME add XEmacs codename."
115 (cond
116 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
117 (concat "Emacs " (elmo-match-string 1 emacs-version)
118 (when (boundp 'mule-version) (concat "/Mule " mule-version))))
119 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
120 emacs-version)
121 (concat (elmo-match-string 1 emacs-version)
122 (format " %d.%d" emacs-major-version emacs-minor-version)
123 (when (and (boundp 'emacs-beta-version) emacs-beta-version)
124 (format "b%d" emacs-beta-version))
125 (when (and with-codename
126 (boundp 'xemacs-codename) xemacs-codename)
127 (concat " - \"" xemacs-codename "\""))))
128 (t emacs-version)))
130 (defun wl-extended-emacs-version2 (&optional delimiter with-codename)
131 "Stringified Emacs version.
132 Separate DELIMITER (default is \" \"). If WITH-CODENAME add XEmacs codename."
133 (cond
134 ((and (boundp 'mule-version) mule-version
135 (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
136 (format "Mule%s%s@%d.%d%s"
137 (or delimiter " ")
138 (elmo-match-string 1 mule-version)
139 emacs-major-version
140 emacs-minor-version
141 (if with-codename
142 (elmo-match-string 2 mule-version)
143 "")))
144 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
145 (concat "Emacs" (or delimiter " ")
146 (elmo-match-string 1 emacs-version)))
147 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
148 emacs-version)
149 (concat (elmo-match-string 1 emacs-version)
150 (or delimiter " ")
151 (format "%d.%d" emacs-major-version emacs-minor-version)
152 (when (and (boundp 'emacs-beta-version) emacs-beta-version)
153 (format "b%d" emacs-beta-version))
154 (when (and with-codename
155 (boundp 'xemacs-codename) xemacs-codename)
156 (format " (%s)" xemacs-codename))))
157 (t emacs-version)))
159 (defun wl-extended-emacs-version3 (&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) mule-version
164 (string-match "\\([0-9]+\.[0-9]+\\)\\(.*$\\)" mule-version))
165 (format "Emacs%s%d.%d Mule%s%s%s"
166 (or delimiter " ")
167 emacs-major-version
168 emacs-minor-version
169 (or delimiter " ")
170 (elmo-match-string 1 mule-version)
171 (if with-codename
172 (elmo-match-string 2 mule-version)
173 "")))
174 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
175 (concat "Emacs" (or delimiter " ")
176 (elmo-match-string 1 emacs-version)))
177 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
178 emacs-version)
179 (concat (elmo-match-string 1 emacs-version)
180 (or delimiter " ")
181 (format "%d.%d" emacs-major-version emacs-minor-version)
182 (when (and (boundp 'emacs-beta-version) emacs-beta-version)
183 (format "b%d" emacs-beta-version))
184 (when (and with-codename
185 (boundp 'xemacs-codename) xemacs-codename)
186 (format " (%s)" xemacs-codename))))
187 (t emacs-version)))
190 ;; for backward compatibility
191 (defconst wl-appname (product-name (product-find 'wl-version)))
192 (make-obsolete-variable
193 'wl-appname
194 "use (product-name (product-find 'wl-version)) insteaed.")
196 (defconst wl-version (product-version-string (product-find 'wl-version)))
197 (make-obsolete-variable
198 'wl-version
199 "use (product-version-string (product-find 'wl-version)) instead.")
201 (defconst wl-codename (product-code-name (product-find 'wl-version)))
202 (make-obsolete-variable
203 'wl-codename
204 "use (product-code-name (product-find 'wl-version)) instead.")
206 ;;; wl-version.el ends here