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