* riece-unread.el: Use riece-facep to check existence of
[riece] / lisp / riece-xemacs.el
1 ;;; riece-xemacs.el --- XEmacs specific functions
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Keywords: emulation
6
7 ;; This file is part of Riece.
8
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Code:
25
26 (defun riece-xemacs-hide-modeline ()
27   "Remove modeline from current window."
28   (set-specifier has-modeline-p nil (current-buffer)))
29
30 (when (featurep 'scrollbar)
31   (defun riece-xemacs-hide-scrollbars ()
32     (if (boundp 'horizontal-scrollbar-visible-p)
33         (set-specifier horizontal-scrollbar-visible-p nil (current-buffer))
34       (if (boundp 'scrollbar-height)
35           (set-specifier scrollbar-height 0 (current-buffer)))))
36   (add-hook 'riece-user-list-mode-hook 'riece-xemacs-hide-scrollbars)
37   (add-hook 'riece-channel-list-mode-hook 'riece-xemacs-hide-scrollbars))
38
39 (add-hook 'riece-user-list-mode-hook 'riece-xemacs-hide-modeline)
40 (add-hook 'riece-channel-list-mode-hook 'riece-xemacs-hide-modeline)
41
42 (defun riece-xemacs-simplify-modeline-format ()
43   "Remove unnecessary information from `modeline-format'."
44   (setq modeline-format
45         (remrassq 'modeline-modified
46                   (delq 'modeline-multibyte-status
47                         (copy-sequence mode-line-format)))))
48
49 (defalias 'riece-simplify-mode-line-format
50   'riece-xemacs-simplify-modeline-format)
51
52 ;;; stolen (and renamed) from gnus-xmas.el.
53 ;;; In GNU Emacs, user can intercept whole mouse tracking events by
54 ;;; assigning [mouse-X].  In XEmacs, however, which causes different
55 ;;; effect, that is, the command assigned to [mouse-X] only catches
56 ;;; button-release events.
57 (defvar riece-mouse-2 [button2])
58
59 ;;; popup-menu compatibility stuff, stolen (and renamed) from
60 ;;; semi-def.el.
61 (defun riece-popup-menu-popup (menu event)
62   (let ((response (get-popup-menu-response menu event)))
63     (if response
64         (funcall (event-function response) (event-object response)))))
65
66 (defalias 'riece-event-buffer 'event-buffer)
67 (defalias 'riece-event-point 'event-point)
68
69 ;;; stolen (and renamed) from gnus-xmas.el.
70 (defalias 'riece-region-active-p 'region-active-p)
71
72 (defalias 'riece-make-overlay 'make-extent)
73 (defalias 'riece-overlay-put 'set-extent-property)
74 (defalias 'riece-overlay-start 'extent-start-position)
75 (defalias 'riece-overlay-buffer 'extent-buffer)
76
77 (defun riece-overlays-in (start end)
78   (extent-list (current-buffer) start end))
79
80 (defalias 'riece-delete-overlay 'delete-extent)
81
82 (defun riece-kill-all-overlays ()
83   "Delete all extents in the current buffer."
84   (map-extents (lambda (extent ignore)
85                  (delete-extent extent)
86                  nil)))
87
88 ;;; stolen (and renamed) from nnheaderxm.el.
89 (defun riece-xemacs-generate-timer-name (&optional prefix)
90   (let ((counter '(0)))
91     (format "%s-%d"
92             (or prefix
93                 "riece-xemacs-timer")
94             (prog1 (car counter)
95               (setcar counter (1+ (car counter)))))))
96
97 (defun riece-run-at-time (time repeat function &rest args)
98   (let ((name (riece-xemacs-generate-timer-name "riece-run-at-time")))
99     (start-itimer
100      name
101      `(lambda ()
102         (,function ,@args))
103      time repeat)
104     name))
105
106 (defun riece-run-with-idle-timer (time repeat function &rest args)
107   (let ((name (riece-xemacs-generate-timer-name "riece-run-with-idle-timer")))
108     (start-itimer
109      name
110      `(lambda ()
111         (,function ,@args))
112      time (if repeat 1) t)
113     name))
114
115 (defalias 'riece-cancel-timer 'delete-itimer)
116
117 (defun riece-match-string-no-properties (number &optional string)
118   (format "%s" (match-string number string)))
119
120 (defun riece-propertize-modeline-string (string &rest properties)
121   (let ((extent (make-extent nil nil)))
122     (set-extent-properties extent properties)
123     (cons extent string)))
124
125 (defalias 'riece-facep 'find-face)
126
127 (provide 'riece-xemacs)
128
129 ;;; riece-xemacs.el ends here