2005-02-18 Steve Youngs <steve@sxemacs.org>
[riece] / lisp / riece-version.el
1 ;;; riece-version.el --- version information about Riece
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;;        Free Software Foundation, Inc.
4 ;; Copyright (C) 1998-2003 Daiki Ueno
5
6 ;; Author: Daiki Ueno <ueno@unixuser.org>
7 ;; Created: 1998-09-28
8 ;; Keywords: IRC, riece
9
10 ;; This file is part of Riece.
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 ;;; Code:
28
29 ;; NOTE: Most part of this file is copied from Gnus.
30
31 (defcustom riece-user-agent 'emacs-riece-type
32   "Which information should be exposed in the User-Agent header.
33
34 It can be one of the symbols `riece' \(show only Riece version\), `emacs-riece'
35 \(show only Emacs and Riece versions\), `emacs-riece-config' \(same as
36 `emacs-riece' plus system configuration\), `emacs-riece-type' \(same as
37 `emacs-riece' plus system type\) or a custom string.  If you set it to a
38 string, be sure to use a valid format, see RFC 2616."
39   :group 'riece-options
40   :type '(choice
41           (item :tag "Show Riece and Emacs versions and system type"
42                 emacs-riece-type)
43           (item :tag "Show Riece and Emacs versions and system configuration"
44                 emacs-riece-config)
45           (item :tag "Show Riece and Emacs versions" emacs-riece)
46           (item :tag "Show only Riece version" riece)
47           (string :tag "Other")))
48
49 (defconst riece-product-name "Riece")
50
51 (defconst riece-version-number "1.0.7"
52   "Version number for this version of Riece.")
53
54 (defconst riece-version (format "Riece v%s" riece-version-number)
55   "Version string for this version of Riece.")
56
57 (eval-when-compile
58   (defvar xemacs-codename)
59   (defvar sxemacs-codename))
60
61 (defun riece-extended-version ()
62   "Stringified Riece version and Emacs version.
63 See the variable `riece-user-agent'."
64   (let* ((riece-v
65           (concat riece-product-name "/"
66                   (prin1-to-string riece-version-number t)))
67          (system-v
68           (cond
69            ((eq riece-user-agent 'emacs-riece-config)
70             system-configuration)
71            ((eq riece-user-agent 'emacs-riece-type)
72             (symbol-name system-type))
73            (t nil)))
74          (emacs-v
75           (cond
76            ((eq riece-user-agent 'riece)
77             nil)
78            ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
79             (concat "Emacs/" (match-string 1 emacs-version)
80                     (if system-v
81                         (concat " (" system-v ")")
82                       "")))
83            ((featurep 'sxemacs)
84             (concat "SXEmacs/" emacs-program-version
85                     (when system-v
86                       (concat " ("
87                               (when sxemacs-codename
88                                 (concat sxemacs-codename ", "))
89                               system-v ")"))))
90            ((featurep 'xemacs)
91             (concat "XEmacs/" emacs-program-version
92                     (when system-v
93                       (concat " ("
94                               (when xemacs-codename
95                                 (concat xemacs-codename ", "))
96                               system-v ")"))))
97            (t emacs-version))))
98     (if (stringp riece-user-agent)
99         riece-user-agent
100       (concat riece-v
101               (when emacs-v
102                 (concat " " emacs-v))))))
103
104 (defun riece-version (&optional arg)
105   "Version number of this version of Riece.
106 If ARG, use user-agent format."
107   (interactive "P")
108   (if arg
109       (message "%s" (riece-extended-version))
110     (message "%s" riece-version)))
111
112 (provide 'riece-version)
113
114 ;;; riece-version.el ends here