[7238] | 1 | ;;; poe-xemacs.el --- poe submodule for XEmacs |
---|
| 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 | (require 'pym) |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | ;;; @ color |
---|
| 32 | ;;; |
---|
| 33 | |
---|
| 34 | (defun-maybe set-cursor-color (color-name) |
---|
| 35 | "Set the text cursor color of the selected frame to COLOR. |
---|
| 36 | When called interactively, prompt for the name of the color to use." |
---|
| 37 | (interactive "sColor: ") |
---|
| 38 | (set-frame-property (selected-frame) 'cursor-color |
---|
| 39 | (if (color-instance-p color-name) |
---|
| 40 | color-name |
---|
| 41 | (make-color-instance color-name)))) |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | ;;; @ face |
---|
| 45 | ;;; |
---|
| 46 | |
---|
| 47 | (defalias-maybe 'face-list 'list-faces) |
---|
| 48 | |
---|
| 49 | (or (memq 'underline (face-list)) |
---|
| 50 | (and (fboundp 'make-face) |
---|
| 51 | (make-face 'underline))) |
---|
| 52 | |
---|
| 53 | (or (face-differs-from-default-p 'underline) |
---|
| 54 | (set-face-underline-p 'underline t)) |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | ;;; @ overlay |
---|
| 58 | ;;; |
---|
| 59 | |
---|
| 60 | (condition-case nil |
---|
| 61 | (require 'overlay) |
---|
| 62 | (error |
---|
| 63 | (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 | (defalias 'delete-overlay 'detach-extent))) |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | ;;; @ dired |
---|
| 73 | ;;; |
---|
| 74 | |
---|
| 75 | (defun-maybe dired-other-frame (dirname &optional switches) |
---|
| 76 | "\"Edit\" directory DIRNAME. Like `dired' but makes a new frame." |
---|
| 77 | (interactive (dired-read-dir-and-switches "in other frame ")) |
---|
| 78 | (switch-to-buffer-other-frame (dired-noselect dirname switches))) |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | ;;; @ timer |
---|
| 82 | ;;; |
---|
| 83 | |
---|
| 84 | (condition-case nil |
---|
| 85 | (require 'timer) |
---|
| 86 | (error |
---|
| 87 | (require 'itimer) |
---|
| 88 | (defun-maybe run-at-time (time repeat function &rest args) |
---|
| 89 | (start-itimer (make-temp-name "rat") |
---|
| 90 | `(lambda () |
---|
| 91 | (,function ,@args)) |
---|
| 92 | time repeat)) |
---|
| 93 | (defalias 'cancel-timer 'delete-itimer) |
---|
| 94 | (defun with-timeout-handler (tag) |
---|
| 95 | (throw tag 'timeout)) |
---|
| 96 | (defmacro-maybe with-timeout (list &rest body) |
---|
| 97 | (let ((seconds (car list)) |
---|
| 98 | (timeout-forms (cdr list))) |
---|
| 99 | `(let ((with-timeout-tag (cons nil nil)) |
---|
| 100 | with-timeout-value with-timeout-timer) |
---|
| 101 | (if (catch with-timeout-tag |
---|
| 102 | (progn |
---|
| 103 | (setq with-timeout-timer |
---|
| 104 | (run-at-time ,seconds nil |
---|
| 105 | 'with-timeout-handler |
---|
| 106 | with-timeout-tag)) |
---|
| 107 | (setq with-timeout-value (progn . ,body)) |
---|
| 108 | nil)) |
---|
| 109 | (progn . ,timeout-forms) |
---|
| 110 | (cancel-timer with-timeout-timer) |
---|
| 111 | with-timeout-value)))))) |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | ;;; @ to avoid bug of XEmacs 19.14 |
---|
| 115 | ;;; |
---|
| 116 | |
---|
| 117 | (or (string-match "^../" |
---|
| 118 | (file-relative-name "/usr/local/share" "/usr/local/lib")) |
---|
| 119 | ;; This function was imported from Emacs 19.33. |
---|
| 120 | (defun file-relative-name (filename &optional directory) |
---|
| 121 | "Convert FILENAME to be relative to DIRECTORY |
---|
| 122 | (default: default-directory)." |
---|
| 123 | (setq filename (expand-file-name filename) |
---|
| 124 | directory (file-name-as-directory |
---|
| 125 | (expand-file-name |
---|
| 126 | (or directory default-directory)))) |
---|
| 127 | (let ((ancestor "")) |
---|
| 128 | (while (not (string-match (concat "^" (regexp-quote directory)) |
---|
| 129 | filename)) |
---|
| 130 | (setq directory (file-name-directory (substring directory 0 -1)) |
---|
| 131 | ancestor (concat "../" ancestor))) |
---|
| 132 | (concat ancestor (substring filename (match-end 0)))))) |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | ;;; @ Emacs 20.3 emulation |
---|
| 136 | ;;; |
---|
| 137 | |
---|
| 138 | (defalias-maybe 'line-beginning-position 'point-at-bol) |
---|
| 139 | (defalias-maybe 'line-end-position 'point-at-eol) |
---|
| 140 | |
---|
| 141 | ;;; @ XEmacs 21 emulation |
---|
| 142 | ;;; |
---|
| 143 | |
---|
| 144 | ;; XEmacs 20.5 and later: (set-extent-properties EXTENT PLIST) |
---|
| 145 | (defun-maybe set-extent-properties (extent plist) |
---|
| 146 | "Change some properties of EXTENT. |
---|
| 147 | PLIST is a property list. |
---|
| 148 | For a list of built-in properties, see `set-extent-property'." |
---|
| 149 | (while plist |
---|
| 150 | (set-extent-property extent (car plist) (cadr plist)) |
---|
| 151 | (setq plist (cddr plist)))) |
---|
| 152 | |
---|
| 153 | ;;; @ end |
---|
| 154 | ;;; |
---|
| 155 | |
---|
| 156 | (require 'product) |
---|
| 157 | (product-provide (provide 'poe-xemacs) (require 'apel-ver)) |
---|
| 158 | |
---|
| 159 | ;;; poe-xemacs.el ends here |
---|