3e54caf5508e00a772823df3aeebf3e3bd853275
[elisp/riece.git] / lisp / riece-compat.el
1 ;;; riece-compat.el --- compatibility functions
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1998-09-28
6 ;; Keywords: IRC, riece, APEL
7
8 ;; This file is part of Riece.
9
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Code:
26
27 (if (featurep 'xemacs)
28     (require 'riece-xemacs)
29   (require 'riece-emacs))
30
31 (defalias 'riece-mode-line-buffer-identification
32   'identity)
33
34 (defun riece-simplify-mode-line-format ()
35   "Remove unnecessary information from `mode-line-format'."
36   (let ((value (rassq 'mode-line-modified mode-line-format)))
37     (if value
38         (setq mode-line-format (delq value (copy-sequence mode-line-format)))
39       mode-line-format)))
40
41 (defun riece-line-beginning-position ()
42   (save-excursion
43     (beginning-of-line)
44     (point)))
45
46 (defun riece-line-end-position ()
47   (save-excursion
48     (end-of-line)
49     (point)))
50
51 (autoload 'read-passwd "passwd")
52 (defvar riece-read-passwd #'read-passwd)
53 (defun riece-read-passwd (prompt)
54   (funcall riece-read-passwd prompt))
55
56 (if (string-match "0\\{0\\}" "")
57     (defun riece-make-interval-regexp (regexp min &optional max)
58       (if max
59           (format "%s\\{%d,%d\\}" regexp min max)
60         (format "%s\\{%d\\}" regexp min)))
61   ;; Emacs 20.7 doesn't support \{...\} in regexps.
62   (defun riece-make-interval-regexp (regexp min &optional max)
63     (mapconcat #'identity
64                (nconc (make-list min regexp)
65                       (if max
66                           (make-list (- max min) (concat regexp "?"))))
67                "")))
68
69 (provide 'riece-compat)
70
71 ;;; riece-compat.el ends here