Mercurial > emacs
annotate lisp/emacs-lisp/lucid.el @ 4422:e51a7e8fffe2
*** empty log message ***
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Mon, 02 Aug 1993 20:48:12 +0000 |
parents | b9ce445fb406 |
children | 96c0a97da147 |
rev | line source |
---|---|
2484 | 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 | |
2088 | 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)) | |
2089 | 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) | |
3389
91f64e9078e9
(copy-tree): Use let* to bind new before i.
Richard M. Stallman <rms@gnu.org>
parents:
3002
diff
changeset
|
32 (let* ((new (copy-sequence tree)) |
91f64e9078e9
(copy-tree): Use let* to bind new before i.
Richard M. Stallman <rms@gnu.org>
parents:
3002
diff
changeset
|
33 (i (1- (length new)))) |
2089 | 34 (while (>= i 0) |
35 (aset new i (copy-tree (aref new i))) | |
36 (setq i (1- i))) | |
37 new) | |
38 tree))) | |
39 | |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
40 (defalias 'current-time-seconds 'current-time) |
2089 | 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 remove-hook (hook-var function) | |
4415
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
56 "Remove a function from a hook, if it is present. |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
57 First argument HOOK-VAR (a symbol) is the name of a hook, second |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
58 argument FUNCTION is the function to remove (compared with `eq')." |
2089 | 59 (if (boundp 'hook-var) |
4415
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
60 (let ((old (symbol-value hook-var))) |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
61 ;; If the hook value is a single function, turn it into a list. |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
62 (if (or (not (listp old)) (eq (car old) 'lambda)) |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
63 (set hook-var (list old))) |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
64 ;; Now delete FUNCTION. |
b9ce445fb406
(remove-hook): Doc string added.
Richard M. Stallman <rms@gnu.org>
parents:
3399
diff
changeset
|
65 (set hook-var (delq function (symbol-value hook-var)))))) |
2089 | 66 |
67 (defun remprop (symbol prop) | |
68 (let ((plist (symbol-plist symbol))) | |
69 (while (eq (car plist) prop) | |
70 (setplist symbol (setq plist (cdr (cdr plist))))) | |
71 (while plist | |
72 (if (eq (nth 2 plist) prop) | |
73 (setcdr (cdr plist) (nthcdr 4 plist))) | |
74 (setq plist (cdr (cdr plist)))))) | |
2168 | 75 |
2206 | 76 (defun map-keymap (function keymap &optional sort-first) |
2168 | 77 "Call FUNCTION for every binding in KEYMAP. |
78 This includes bindings inherited from a parent keymap. | |
79 FUNCTION receives two arguments each time it is called: | |
80 the character (more generally, the event type) that is bound, | |
3399 | 81 and the binding it has. |
82 | |
83 Note that passing the event type directly to `define-key' does not work | |
84 in Emacs 19. We do not emulate that particular feature of Lucid Emacs. | |
85 If your code does that, modify it to make a vector containing the event | |
86 type that you get. That will work in both versions of Emacs." | |
2206 | 87 (if sort-first |
88 (let (list) | |
89 (map-keymap (function (lambda (a b) | |
90 (setq list (cons (cons a b) list)))) | |
91 keymap) | |
92 (setq list (sort list | |
93 (function (lambda (a b) | |
94 (setq a (car a) b (car b)) | |
95 (if (integerp a) | |
96 (if (integerp b) (< a b) | |
97 t) | |
98 (if (integerp b) t | |
99 (string< a b))))))) | |
100 (while list | |
101 (funcall function (car (car list)) (cdr (car list))) | |
102 (setq list (cdr list)))) | |
103 (while (consp keymap) | |
104 (if (consp (car keymap)) | |
105 (funcall function (car (car keymap)) (cdr (car keymap))) | |
106 (if (vectorp (car keymap)) | |
107 (let ((i (1- (length (car keymap)))) | |
108 (vector (car keymap))) | |
109 (while (>= i 0) | |
110 (funcall function i (aref vector i)) | |
111 (setq i (1- i)))))) | |
112 (setq keymap (cdr keymap))))) | |
113 | |
114 (defun real-path-name (name &optional default) | |
115 (file-truename (expand-file-name name default))) | |
116 | |
117 ;; It's not clear what to return if the mouse is not in FRAME. | |
118 (defun read-mouse-position (frame) | |
119 (let ((pos (mouse-position))) | |
120 (if (eq (car pos) frame) | |
121 (cdr pos)))) | |
122 | |
123 (defun switch-to-other-buffer (arg) | |
124 "Switch to the previous buffer. | |
125 With a numeric arg N, switch to the Nth most recent buffer. | |
126 With an arg of 0, buries the current buffer at the | |
127 bottom of the buffer stack." | |
128 (interactive "p") | |
129 (if (eq arg 0) | |
130 (bury-buffer (current-buffer))) | |
131 (switch-to-buffer | |
132 (if (<= arg 1) (other-buffer (current-buffer)) | |
2631
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
133 (nth (1+ arg) |
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
134 (apply 'nconc |
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
135 (mapcar |
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
136 (lambda (buf) |
3002
7274509e47a3
* lucid.el (switch-to-other-buffer): Build the list of acceptable
Jim Blandy <jimb@redhat.com>
parents:
2631
diff
changeset
|
137 (if (= ?\ (string-to-char (buffer-name buf))) |
2631
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
138 nil |
3002
7274509e47a3
* lucid.el (switch-to-other-buffer): Build the list of acceptable
Jim Blandy <jimb@redhat.com>
parents:
2631
diff
changeset
|
139 (list buf))) |
7274509e47a3
* lucid.el (switch-to-other-buffer): Build the list of acceptable
Jim Blandy <jimb@redhat.com>
parents:
2631
diff
changeset
|
140 (buffer-list))))))) |
2388
3f27c886f375
(try-face-font, find-face, get-face): New aliases.
Richard M. Stallman <rms@gnu.org>
parents:
2281
diff
changeset
|
141 |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
142 (defalias 'find-face 'internal-find-face) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
143 (defalias 'get-face 'internal-get-face) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
144 (defalias 'try-face-font 'internal-try-face-font) |
2206 | 145 |
146 ;; Support the Lucid names with `screen' instead of `frame'. | |
147 | |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
148 (defalias 'current-screen-configuration 'current-frame-configuration) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
149 (defalias 'delete-screen 'delete-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
150 (defalias 'find-file-new-screen 'find-file-other-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
151 (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
152 (defalias 'find-tag-new-screen 'find-tag-other-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
153 ;;(defalias 'focus-screen 'focus-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
154 (defalias 'iconify-screen 'iconify-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
155 (defalias 'mail-new-screen 'mail-other-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
156 (defalias 'make-screen-invisible 'make-frame-invisible) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
157 (defalias 'make-screen-visible 'make-frame-visible) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
158 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
159 (defalias 'modify-screen-parameters 'modify-frame-parameters) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
160 (defalias 'next-screen 'next-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
161 ;; (defalias 'next-multiscreen-window 'next-multiframe-window) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
162 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
163 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
164 (defalias 'redraw-screen 'redraw-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
165 ;; (defalias 'screen-char-height 'frame-char-height) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
166 ;; (defalias 'screen-char-width 'frame-char-width) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
167 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
168 ;; (defalias 'screen-focus 'frame-focus) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
169 (defalias 'screen-height 'frame-height) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
170 (defalias 'screen-list 'frame-list) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
171 ;; (defalias 'screen-live-p 'frame-live-p) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
172 (defalias 'screen-parameters 'frame-parameters) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
173 (defalias 'screen-pixel-height 'frame-pixel-height) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
174 (defalias 'screen-pixel-width 'frame-pixel-width) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
175 (defalias 'screen-root-window 'frame-root-window) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
176 (defalias 'screen-selected-window 'frame-selected-window) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
177 (defalias 'lower-screen 'lower-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
178 (defalias 'raise-screen 'raise-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
179 (defalias 'screen-visible-p 'frame-visible-p) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
180 (defalias 'screen-width 'frame-width) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
181 (defalias 'screenp 'framep) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
182 (defalias 'select-screen 'select-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
183 (defalias 'selected-screen 'selected-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
184 ;; (defalias 'set-screen-configuration 'set-frame-configuration) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
185 ;; (defalias 'set-screen-height 'set-frame-height) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
186 (defalias 'set-screen-position 'set-frame-position) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
187 (defalias 'set-screen-size 'set-frame-size) |
2631
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
188 ;; (defalias 'set-screen-width 'set-frame-width) |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
189 (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
190 ;; (defalias 'unfocus-screen 'unfocus-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
191 (defalias 'visible-screen-list 'visible-frame-list) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
192 (defalias 'window-screen 'window-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
193 (defalias 'x-create-screen 'x-create-frame) |
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2484
diff
changeset
|
194 (defalias 'x-new-screen 'new-frame) |
2484 | 195 |
2631
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
196 (provide 'lucid) |
1e3d854828fc
* lucid.el: Comment out fset of set-screen-width properly.
Jim Blandy <jimb@redhat.com>
parents:
2571
diff
changeset
|
197 |
2484 | 198 ;;; end of lucid.el |