Undo.
[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 "0.1.2"
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
60 (defun riece-extended-version ()
61   "Stringified Riece version and Emacs version.
62 See the variable `riece-user-agent'."
63   (interactive)
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            ((string-match
84              "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
85              emacs-version)
86             (concat
87              (match-string 1 emacs-version)
88              (format "/%d.%d" emacs-major-version emacs-minor-version)
89              (if (match-beginning 3)
90                  (match-string 3 emacs-version)
91                "")
92              (if (boundp 'xemacs-codename)
93                  (concat
94                   " (" xemacs-codename
95                   (if system-v
96                       (concat ", " system-v ")")
97                     ")"))
98                "")))
99            (t emacs-version))))
100     (if (stringp riece-user-agent)
101         riece-user-agent
102       (concat riece-v
103               (when emacs-v
104                 (concat " " emacs-v))))))
105
106 (provide 'riece-version)
107
108 ;;; riece-version.el ends here