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