(overlayp): New alias.
[elisp/apel.git] / poe-xemacs.el
1 ;;; poe-xemacs.el --- poe submodule for XEmacs -*-byte-compile-dynamic: t;-*-
2
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995,1996,1997,1998 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 ;;; @ color
29 ;;;
30
31 (defun-maybe set-cursor-color (color-name)
32   "Set the text cursor color of the selected frame to COLOR.
33 When called interactively, prompt for the name of the color to use."
34   (interactive "sColor: ")
35   (set-frame-property (selected-frame) 'cursor-color
36                       (if (color-instance-p color-name)
37                           color-name
38                         (make-color-instance color-name))))
39
40
41 ;;; @ face
42 ;;;
43
44 (defalias-maybe 'face-list 'list-faces)
45
46 (or (memq 'underline (face-list))
47     (and (fboundp 'make-face)
48          (make-face 'underline)))
49
50 (or (face-differs-from-default-p 'underline)
51     (set-face-underline-p 'underline t))
52
53
54 ;;; @ overlay
55 ;;;
56
57 (condition-case nil
58     (require 'overlay)
59   (error (defalias 'make-overlay 'make-extent)
60          (defalias 'overlayp 'extentp)
61          (defalias 'overlay-put 'set-extent-property)
62          (defalias 'overlay-buffer 'extent-buffer)
63          (defun move-overlay (extent start end &optional buffer)
64            (set-extent-endpoints extent start end)
65            )
66          (defalias 'delete-overlay 'detach-extent)
67          ))
68
69
70 ;;; @ dired
71 ;;;
72
73 (defun-maybe dired-other-frame (dirname &optional switches)
74   "\"Edit\" directory DIRNAME.  Like `dired' but makes a new frame."
75   (interactive (dired-read-dir-and-switches "in other frame "))
76   (switch-to-buffer-other-frame (dired-noselect dirname switches))
77   )
78
79
80 ;;; @ to avoid bug of XEmacs 19.14
81 ;;;
82
83 (or (string-match "^../"
84                   (file-relative-name "/usr/local/share" "/usr/local/lib"))
85     ;; This function was imported from Emacs 19.33.
86     (defun file-relative-name (filename &optional directory)
87       "Convert FILENAME to be relative to DIRECTORY
88 (default: default-directory). [poe-xemacs.el]"
89       (setq filename (expand-file-name filename)
90             directory (file-name-as-directory
91                        (expand-file-name
92                         (or directory default-directory))))
93       (let ((ancestor ""))
94         (while (not (string-match (concat "^" (regexp-quote directory))
95                                   filename))
96           (setq directory (file-name-directory (substring directory 0 -1))
97                 ancestor (concat "../" ancestor)))
98         (concat ancestor (substring filename (match-end 0)))))
99     )
100
101
102 ;;; @ for anything older than XEmacs 20.2
103 ;;;
104
105 ;; eval-after-load is not defined in XEmacs but after-load-alist is
106 ;; usable.  See subr.el in XEmacs.
107
108 (defun-maybe eval-after-load (file form)
109   "Arrange that, if FILE is ever loaded, FORM will be run at that time.
110 This makes or adds to an entry on `after-load-alist'.
111 If FILE is already loaded, evaluate FORM right now.
112 It does nothing if FORM is already on the list for FILE.
113 FILE should be the name of a library, with no directory name."
114   ;; Make sure there is an element for FILE.
115   (or (assoc file after-load-alist)
116       (setq after-load-alist (cons (list file) after-load-alist)))
117   ;; Add FORM to the element if it isn't there.
118   (let ((elt (assoc file after-load-alist)))
119     (or (member form (cdr elt))
120         (progn
121           (nconc elt (list form))
122           ;; If the file has been loaded already, run FORM right away.
123           (and (assoc file load-history)
124                (eval form)))))
125   form)
126
127 ;; (defun-maybe eval-after-load (file form)
128 ;;   (or (assoc file after-load-alist)
129 ;;       (setq after-load-alist (cons (list file) after-load-alist)))
130 ;;   (let ((elt (assoc file after-load-alist)))
131 ;;     (or (member form (cdr elt))
132 ;;         (nconc elt (list form))))
133 ;;   form)
134
135
136 ;;; @ Emacs 20.3 emulation
137 ;;;
138
139 (defalias-maybe 'line-beginning-position 'point-at-bol)
140
141 (defalias-maybe 'line-end-position 'point-at-eol)
142
143
144 ;;; @ end
145 ;;;
146
147 (provide 'poe-xemacs)
148
149 ;;; poe-xemacs.el ends here