a61532c21e393289058be79b6b81f545941ad7c9
[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 emacs-program-version)
59   (defvar xemacs-codename)
60   (defvar sxemacs-codename))
61
62 (defun riece-extended-version ()
63   "Stringified Riece version and Emacs version.
64 See the variable `riece-user-agent'."
65   (let* ((riece-v
66           (concat riece-product-name "/"
67                   (prin1-to-string riece-version-number t)))
68          (system-v
69           (cond
70            ((eq riece-user-agent 'emacs-riece-config)
71             system-configuration)
72            ((eq riece-user-agent 'emacs-riece-type)
73             (symbol-name system-type))
74            (t nil)))
75          (emacs-v
76           (cond
77            ((eq riece-user-agent 'riece)
78             nil)
79            ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
80             (concat "Emacs/" (match-string 1 emacs-version)
81                     (if system-v
82                         (concat " (" system-v ")")
83                       "")))
84            ((featurep 'sxemacs)
85             (concat "SXEmacs/" emacs-program-version
86                     (when system-v
87                       (concat " ("
88                               (when sxemacs-codename
89                                 (concat sxemacs-codename ", "))
90                               system-v ")"))))
91            ((featurep 'xemacs)
92             (concat "XEmacs/" emacs-program-version
93                     (when system-v
94                       (concat " ("
95                               (when xemacs-codename
96                                 (concat xemacs-codename ", "))
97                               system-v ")"))))
98            (t emacs-version))))
99     (if (stringp riece-user-agent)
100         riece-user-agent
101       (concat riece-v
102               (when emacs-v
103                 (concat " " emacs-v))))))
104
105 (defun riece-version (&optional arg)
106   "Version number of this version of Riece.
107 If ARG, use user-agent format."
108   (interactive "P")
109   (if arg
110       (message "%s" (riece-extended-version))
111     (message "%s" riece-version)))
112
113 (provide 'riece-version)
114
115 ;;; riece-version.el ends here