comparison lisp/emacs-lisp/lucid.el @ 30087:1b5db0f1b8b7

Require CL. (copy-tree, remprop): Remove, it's provided by CL. (map-keymap): Define in terms of cl-map-keymap. (extent-property, set-extent-end-glyph): New functions.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 05 Jul 2000 22:06:25 +0000
parents ce11e3471a36
children 67b464da13ec
comparison
equal deleted inserted replaced
30086:afe9cfd77aef 30087:1b5db0f1b8b7
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA. 20 ;; Boston, MA 02111-1307, USA.
21 21
22 ;;; Code: 22 ;;; Code:
23 23
24 (defun copy-tree (tree) 24 ;; XEmacs autoloads CL so we might as well make use of it.
25 (if (consp tree) 25 (require 'cl)
26 (cons (copy-tree (car tree))
27 (copy-tree (cdr tree)))
28 (if (vectorp tree)
29 (let* ((new (copy-sequence tree))
30 (i (1- (length new))))
31 (while (>= i 0)
32 (aset new i (copy-tree (aref new i)))
33 (setq i (1- i)))
34 new)
35 tree)))
36 26
37 (defalias 'current-time-seconds 'current-time) 27 (defalias 'current-time-seconds 'current-time)
38
39 (defun remprop (symbol prop)
40 (let ((plist (symbol-plist symbol)))
41 (while (eq (car plist) prop)
42 (setplist symbol (setq plist (cdr (cdr plist)))))
43 (while plist
44 (if (eq (nth 2 plist) prop)
45 (setcdr (cdr plist) (nthcdr 4 plist)))
46 (setq plist (cdr (cdr plist))))))
47 28
48 (defun map-keymap (function keymap &optional sort-first) 29 (defun map-keymap (function keymap &optional sort-first)
49 "Call FUNCTION for every binding in KEYMAP. 30 "Call FUNCTION for every binding in KEYMAP.
50 This includes bindings inherited from a parent keymap. 31 This does not include bindings inherited from a parent keymap.
51 FUNCTION receives two arguments each time it is called: 32 FUNCTION receives two arguments each time it is called:
52 the character (more generally, the event type) that is bound, 33 the character (more generally, the event type) that is bound,
53 and the binding it has. 34 and the binding it has.
54 35
55 Note that passing the event type directly to `define-key' does not work 36 Note that passing the event type directly to `define-key' does not work
56 in Emacs 19. We do not emulate that particular feature of Lucid Emacs. 37 in Emacs 19. We do not emulate that particular feature of Lucid Emacs.
57 If your code does that, modify it to make a vector containing the event 38 If your code does that, modify it to make a vector containing the event
58 type that you get. That will work in both versions of Emacs." 39 type that you get. That will work in both versions of Emacs."
59 (if sort-first 40 (if sort-first
60 (let (list) 41 (let (list)
61 (map-keymap (function (lambda (a b) 42 (cl-map-keymap (lambda (a b) (push (cons a b) list))
62 (setq list (cons (cons a b) list)))) 43 keymap)
63 keymap)
64 (setq list (sort list 44 (setq list (sort list
65 (function (lambda (a b) 45 (lambda (a b)
66 (setq a (car a) b (car b)) 46 (setq a (car a) b (car b))
67 (if (integerp a) 47 (if (integerp a)
68 (if (integerp b) (< a b) 48 (if (integerp b) (< a b)
69 t) 49 t)
70 (if (integerp b) t 50 (if (integerp b) t
71 (string< a b))))))) 51 (string< a b))))))
72 (while list 52 (dolist (p list)
73 (funcall function (car (car list)) (cdr (car list))) 53 (funcall function (car p) (cdr p))))
74 (setq list (cdr list)))) 54 (cl-map-keymap function keymap)))
75 (while (consp keymap)
76 (if (consp (car keymap))
77 (funcall function (car (car keymap)) (cdr (car keymap)))
78 (if (vectorp (car keymap))
79 (let ((i (1- (length (car keymap))))
80 (vector (car keymap)))
81 (while (>= i 0)
82 (funcall function i (aref vector i))
83 (setq i (1- i))))))
84 (setq keymap (cdr keymap)))))
85 55
86 (defun read-number (prompt &optional integers-only) 56 (defun read-number (prompt &optional integers-only)
87 "Read a number from the minibuffer. 57 "Read a number from the minibuffer.
88 Keep reentering the minibuffer until we get suitable input. 58 Keep reentering the minibuffer until we get suitable input.
89 If optional argument INTEGERS-ONLY is non-nil, insist on an integer." 59 If optional argument INTEGERS-ONLY is non-nil, insist on an integer."
139 (defalias 'exec-to-string 'shell-command-to-string) 109 (defalias 'exec-to-string 'shell-command-to-string)
140 110
141 (defun make-extent (beg end &optional buffer) 111 (defun make-extent (beg end &optional buffer)
142 (make-overlay beg end buffer)) 112 (make-overlay beg end buffer))
143 113
144 (defun extent-properties (extent) 114 (defun extent-properties (extent) (overlay-properties extent))
145 (overlay-properties extent)) 115 (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get))
146 116
147 (defun extent-at (pos &optional object property before) 117 (defun extent-at (pos &optional object property before)
148 (with-current-buffer (or object (current-buffer)) 118 (with-current-buffer (or object (current-buffer))
149 (let ((overlays (overlays-at pos))) 119 (let ((overlays (overlays-at pos)))
150 (when property 120 (when property
194 prop value (overlay-buffer extent)))) 164 prop value (overlay-buffer extent))))
195 (overlay-put extent prop value)) 165 (overlay-put extent prop value))
196 166
197 (defun set-extent-face (extent face) 167 (defun set-extent-face (extent face)
198 (set-extent-property extent 'face face)) 168 (set-extent-property extent 'face face))
169
170 (defun set-extent-end-glyph (extent glyph)
171 (set-extent-property extent 'after-string glyph))
199 172
200 (defun delete-extent (extent) 173 (defun delete-extent (extent)
201 (set-extent-property extent 'duplicable nil) 174 (set-extent-property extent 'duplicable nil)
202 (delete-overlay extent)) 175 (delete-overlay extent))
203 176