0549710d3c9be442f06de877f49c8303812b77d8
[elisp/apel.git] / emu-xemacs.el
1 ;;; emu-xemacs.el --- emu API implementation for XEmacs
2
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995,1996,1997 MORIOKA Tomohiko
5
6 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Version:
8 ;;      $Id: emu-xemacs.el,v 7.17 1997/03/06 17:46:39 morioka Exp $
9 ;; Keywords: emulation, compatibility, XEmacs
10
11 ;; This file is part of XEmacs.
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 ;; 02111-1307, USA.
27
28 ;;; Code:
29
30 ;;; @ face
31 ;;;
32
33 (or (fboundp 'face-list)
34     (defalias 'face-list 'list-faces)
35     )
36
37 (or (memq 'underline (face-list))
38     (and (fboundp 'make-face)
39          (make-face 'underline)
40          ))
41
42 (or (face-differs-from-default-p 'underline)
43     (set-face-underline-p 'underline t))
44
45
46 ;;; @ overlay
47 ;;;
48
49 (defalias 'tl:make-overlay 'make-extent)
50 (defalias 'tl:overlay-put 'set-extent-property)
51 (defalias 'tl:overlay-buffer 'extent-buffer)
52
53 (defun tl:move-overlay (extent start end &optional buffer)
54   (set-extent-endpoints extent start end)
55   )
56
57
58 ;;; @@ visible/invisible
59 ;;;
60
61 (defmacro enable-invisible ())
62
63 (defmacro end-of-invisible ())
64
65 (defun invisible-region (start end)
66   (if (save-excursion
67         (goto-char start)
68         (eq (following-char) ?\n)
69         )
70       (setq start (1+ start))
71     )
72   (put-text-property start end 'invisible t)
73   )
74
75 (defun visible-region (start end)
76   (put-text-property start end 'invisible nil)
77   )
78
79 (defun invisible-p (pos)
80   (if (save-excursion
81         (goto-char pos)
82         (eq (following-char) ?\n)
83         )
84       (setq pos (1+ pos))
85     )
86   (get-text-property pos 'invisible)
87   )
88
89 (defun next-visible-point (pos)
90   (save-excursion
91     (if (save-excursion
92           (goto-char pos)
93           (eq (following-char) ?\n)
94           )
95         (setq pos (1+ pos))
96       )
97     (or (next-single-property-change pos 'invisible)
98         (point-max))
99     ))
100
101
102 ;;; @ mouse
103 ;;;
104
105 (defvar mouse-button-1 'button1)
106 (defvar mouse-button-2 'button2)
107 (defvar mouse-button-3 'button3)
108
109
110 ;;; @ dired
111 ;;;
112
113 (or (fboundp 'dired-other-frame)
114     (defun dired-other-frame (dirname &optional switches)
115       "\"Edit\" directory DIRNAME.  Like `dired' but makes a new frame."
116       (interactive (dired-read-dir-and-switches "in other frame "))
117       (switch-to-buffer-other-frame (dired-noselect dirname switches))
118       )
119     )
120
121
122 ;;; @ string
123 ;;;
124
125 (defmacro char-list-to-string (char-list)
126   "Convert list of character CHAR-LIST to string. [emu-xemacs.el]"
127   `(mapconcat #'char-to-string ,char-list ""))
128
129
130 ;;; @@ to avoid bug of XEmacs 19.14
131 ;;;
132
133 (or (string-match "^../"
134                   (file-relative-name "/usr/local/share" "/usr/local/lib"))
135     ;; This function was imported from Emacs 19.33.
136     (defun file-relative-name (filename &optional directory)
137       "Convert FILENAME to be relative to DIRECTORY
138 (default: default-directory). [emu-xemacs.el]"
139       (setq filename (expand-file-name filename)
140             directory (file-name-as-directory
141                        (expand-file-name
142                         (or directory default-directory))))
143       (let ((ancestor ""))
144         (while (not (string-match (concat "^" (regexp-quote directory))
145                                   filename))
146           (setq directory (file-name-directory (substring directory 0 -1))
147                 ancestor (concat "../" ancestor)))
148         (concat ancestor (substring filename (match-end 0)))
149         ))
150     )
151
152     
153 ;;; @ end
154 ;;;
155
156 (provide 'emu-xemacs)
157
158 ;;; emu-xemacs.el ends here