1;;; lucid.el --- Emulate some Lucid Emacs functions. 2;; Copyright (C) 1993 Free Software Foundation, Inc. 3 4;; This file is part of GNU Emacs. 5 6;; GNU Emacs is free software; you can redistribute it and/or modify 7;; it under the terms of the GNU General Public License as published by 8;; the Free Software Foundation; either version 2, or (at your option) 9;; any later version. 10 11;; GNU Emacs is distributed in the hope that it will be useful, 12;; but WITHOUT ANY WARRANTY; without even the implied warranty of 13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14;; GNU General Public License for more details. 15 16;; You should have received a copy of the GNU General Public License 17;; along with GNU Emacs; see the file COPYING. If not, write to 18;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 20 21(defun add-timeout (secs function object &optional resignal) 22 (run-at-time secs resignal function object)) 23 24(defun disable-timeout (timeout) 25 (cancel-timer timeout)) 26 27(defun copy-tree (tree) 28 (if (consp tree) 29 (cons (copy-tree (car tree)) 30 (copy-tree (cdr tree))) 31 (if (vectorp tree) 32 (let* ((new (copy-sequence tree)) 33 (i (1- (length new)))) 34 (while (>= i 0) 35 (aset new i (copy-tree (aref new i))) 36 (setq i (1- i))) 37 new) 38 tree))) 39 40(defalias 'current-time-seconds 'current-time) 41 42(defun keymap-parent (keymap) 43 (let ((tail (cdr keymap))) 44 (while (and tail (not (eq (car tail) 'keymap))) 45 (setq tail (cdr tail))) 46 tail)) 47 48(defun set-keymap-parent (keymap new-parent) 49 (let ((tail (cdr keymap))) 50 (while (and tail (cdr tail) (not (eq (car (cdr tail)) 'keymap))) 51 (setq tail (cdr tail))) 52 (if tail 53 (setcdr tail new-parent)))) 54 55(defun remprop (symbol prop) 56 (let ((plist (symbol-plist symbol))) 57 (while (eq (car plist) prop) 58 (setplist symbol (setq plist (cdr (cdr plist))))) 59 (while plist 60 (if (eq (nth 2 plist) prop) 61 (setcdr (cdr plist) (nthcdr 4 plist))) 62 (setq plist (cdr (cdr plist)))))) 63 64(defun map-keymap (function keymap &optional sort-first) 65 "Call FUNCTION for every binding in KEYMAP. 66This includes bindings inherited from a parent keymap. 67FUNCTION receives two arguments each time it is called: 68the character (more generally, the event type) that is bound, 69and the binding it has. 70 71Note that passing the event type directly to `define-key' does not work 72in Emacs 19. We do not emulate that particular feature of Lucid Emacs. 73If your code does that, modify it to make a vector containing the event 74type that you get. That will work in both versions of Emacs." 75 (if sort-first 76 (let (list) 77 (map-keymap (function (lambda (a b) 78 (setq list (cons (cons a b) list)))) 79 keymap) 80 (setq list (sort list 81 (function (lambda (a b) 82 (setq a (car a) b (car b)) 83 (if (integerp a) 84 (if (integerp b) (< a b) 85 t) 86 (if (integerp b) t 87 (string< a b))))))) 88 (while list 89 (funcall function (car (car list)) (cdr (car list))) 90 (setq list (cdr list)))) 91 (while (consp keymap) 92 (if (consp (car keymap)) 93 (funcall function (car (car keymap)) (cdr (car keymap))) 94 (if (vectorp (car keymap)) 95 (let ((i (1- (length (car keymap)))) 96 (vector (car keymap))) 97 (while (>= i 0) 98 (funcall function i (aref vector i)) 99 (setq i (1- i)))))) 100 (setq keymap (cdr keymap))))) 101 102(defun real-path-name (name &optional default) 103 (file-truename (expand-file-name name default))) 104 105;; It's not clear what to return if the mouse is not in FRAME. 106(defun read-mouse-position (frame) 107 (let ((pos (mouse-position))) 108 (if (eq (car pos) frame) 109 (cdr pos)))) 110 111(defun switch-to-other-buffer (arg) 112 "Switch to the previous buffer. 113With a numeric arg N, switch to the Nth most recent buffer. 114With an arg of 0, buries the current buffer at the 115bottom of the buffer stack." 116 (interactive "p") 117 (if (eq arg 0) 118 (bury-buffer (current-buffer))) 119 (switch-to-buffer 120 (if (<= arg 1) (other-buffer (current-buffer)) 121 (nth (1+ arg) 122 (apply 'nconc 123 (mapcar 124 (lambda (buf) 125 (if (= ?\ (string-to-char (buffer-name buf))) 126 nil 127 (list buf))) 128 (buffer-list))))))) 129 130(defalias 'find-face 'internal-find-face) 131(defalias 'get-face 'internal-get-face) 132(defalias 'try-face-font 'internal-try-face-font) 133 134;; Support the Lucid names with `screen' instead of `frame'. 135 136(defalias 'current-screen-configuration 'current-frame-configuration) 137(defalias 'delete-screen 'delete-frame) 138(defalias 'find-file-new-screen 'find-file-other-frame) 139(defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame) 140(defalias 'find-tag-new-screen 'find-tag-other-frame) 141;;(defalias 'focus-screen 'focus-frame) 142(defalias 'iconify-screen 'iconify-frame) 143(defalias 'mail-new-screen 'mail-other-frame) 144(defalias 'make-screen-invisible 'make-frame-invisible) 145(defalias 'make-screen-visible 'make-frame-visible) 146;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list) 147(defalias 'modify-screen-parameters 'modify-frame-parameters) 148(defalias 'next-screen 'next-frame) 149;; (defalias 'next-multiscreen-window 'next-multiframe-window) 150;; (defalias 'previous-multiscreen-window 'previous-multiframe-window) 151;; (defalias 'redirect-screen-focus 'redirect-frame-focus) 152(defalias 'redraw-screen 'redraw-frame) 153;; (defalias 'screen-char-height 'frame-char-height) 154;; (defalias 'screen-char-width 'frame-char-width) 155;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register) 156;; (defalias 'screen-focus 'frame-focus) 157(defalias 'screen-height 'frame-height) 158(defalias 'screen-list 'frame-list) 159;; (defalias 'screen-live-p 'frame-live-p) 160(defalias 'screen-parameters 'frame-parameters) 161(defalias 'screen-pixel-height 'frame-pixel-height) 162(defalias 'screen-pixel-width 'frame-pixel-width) 163(defalias 'screen-root-window 'frame-root-window) 164(defalias 'screen-selected-window 'frame-selected-window) 165(defalias 'lower-screen 'lower-frame) 166(defalias 'raise-screen 'raise-frame) 167(defalias 'screen-visible-p 'frame-visible-p) 168(defalias 'screen-width 'frame-width) 169(defalias 'screenp 'framep) 170(defalias 'select-screen 'select-frame) 171(defalias 'selected-screen 'selected-frame) 172;; (defalias 'set-screen-configuration 'set-frame-configuration) 173;; (defalias 'set-screen-height 'set-frame-height) 174(defalias 'set-screen-position 'set-frame-position) 175(defalias 'set-screen-size 'set-frame-size) 176;; (defalias 'set-screen-width 'set-frame-width) 177(defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame) 178;; (defalias 'unfocus-screen 'unfocus-frame) 179(defalias 'visible-screen-list 'visible-frame-list) 180(defalias 'window-screen 'window-frame) 181(defalias 'x-create-screen 'x-create-frame) 182(defalias 'x-new-screen 'make-frame) 183 184(provide 'lucid) 185 186;;; end of lucid.el 187