Removed aliases for encode-coding-string & decode-coding-string since
[riece] / lisp / riece-version.el
1 ;;; riece-version.el --- version information handling
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., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Code:
28
29 (require 'riece-package-info)
30
31 ;; NOTE: Most part of this file is copied from Gnus.
32
33 (defcustom riece-user-agent 'emacs-riece-type
34   "Which information should be exposed in the User-Agent header.
35
36 It can be one of the symbols `riece' \(show only Riece version\), `emacs-riece'
37 \(show only Emacs and Riece versions\), `emacs-riece-config' \(same as
38 `emacs-riece' plus system configuration\), `emacs-riece-type' \(same as
39 `emacs-riece' plus system type\) or a custom string.  If you set it to a
40 string, be sure to use a valid format, see RFC 2616."
41   :group 'riece-options
42   :type '(choice
43           (item :tag "Show Riece and Emacs versions and system type"
44                 emacs-riece-type)
45           (item :tag "Show Riece and Emacs versions and system configuration"
46                 emacs-riece-config)
47           (item :tag "Show Riece and Emacs versions" emacs-riece)
48           (item :tag "Show only Riece version" riece)
49           (string :tag "Other")))
50
51 (defconst riece-version (format "%s v%s" riece-package-name
52                                 riece-version-number)
53   "Version string for this version of Riece.")
54
55 (eval-when-compile
56   (defvar emacs-program-version)
57   (defvar xemacs-codename)
58   (defvar sxemacs-codename))
59
60 (defun riece-extended-version ()
61   "Stringified Riece version and Emacs version.
62 See the variable `riece-user-agent'."
63   (let* ((riece-v
64           (concat riece-package-name "/"
65                   (prin1-to-string riece-version-number t)))
66          (system-v
67           (cond
68            ((eq riece-user-agent 'emacs-riece-config)
69             system-configuration)
70            ((eq riece-user-agent 'emacs-riece-type)
71             (symbol-name system-type))
72            (t nil)))
73          (emacs-v
74           (cond
75            ((eq riece-user-agent 'riece)
76             nil)
77            ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
78             (concat "Emacs/" (match-string 1 emacs-version)
79                     (if system-v
80                         (concat " (" system-v ")")
81                       "")))
82            ((featurep 'sxemacs)
83             (concat "SXEmacs/" emacs-program-version
84                     (when system-v
85                       (concat " ("
86                               (when sxemacs-codename
87                                 (concat sxemacs-codename ", "))
88                               system-v ")"))))
89            ((featurep 'xemacs)
90             (concat "XEmacs/" emacs-program-version
91                     (when system-v
92                       (concat " ("
93                               (when xemacs-codename
94                                 (concat xemacs-codename ", "))
95                               system-v ")"))))
96            (t emacs-version))))
97     (if (stringp riece-user-agent)
98         riece-user-agent
99       (concat riece-v
100               (when emacs-v
101                 (concat " " emacs-v))))))
102
103 (defun riece-version (&optional arg)
104   "Version number of this version of Riece.
105 If ARG, use user-agent format."
106   (interactive "P")
107   (if arg
108       (message "%s" (riece-extended-version))
109     (message "%s" riece-version)))
110
111 (provide 'riece-version)
112
113 ;;; riece-version.el ends here