annotate lisp/prim/overlay.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents
children 56c54cf7c5b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;;; overlay.el --- overlay support.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;;; Copyright (C) 1997 Free Software Foundation, Inc.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; Maintainer: XEmacs
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Keywords: internal
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13 ;; any later version.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18 ;; General Public License for more details.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 (defun overlayp (object)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 "Return t if OBJECT is an overlay."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 (and (extentp object)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 (extent-property object 'overlay)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 (defun make-overlay (beg end &optional buffer front-advance rear-advance)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 "Create a new overlay with range BEG to END in BUFFER.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 If omitted, BUFFER defaults to the current buffer.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 BEG and END may be integers or markers.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 The fourth arg FRONT-ADVANCE, if non-nil, makes the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 front delimiter advance when text is inserted there.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 The fifth arg REAR-ADVANCE, if non-nil, makes the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 rear delimiter advance when text is inserted there."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 (let (overlay temp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 (if (null buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 (setq buffer (current-buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (check-argument-type 'bufferp buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 (if (> beg end)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 (setq temp beg
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 beg end
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 end temp))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 (setq overlay (make-extent beg end buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 (set-extent-property overlay 'overlay t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 (if front-advance
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 (set-extent-property overlay 'start-open t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (set-extent-property overlay 'start-closed t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 (if rear-advance
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (set-extent-property overlay 'end-closed t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (set-extent-property overlay 'end-open t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 overlay))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 (defun move-overlay (overlay beg end &optional buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 "Set the endpoints of OVERLAY to BEG and END in BUFFER.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 If BUFFER is omitted, and OVERLAY is in no buffer, put it in the current
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 buffer."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 (let (temp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 (if (null buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 (setq buffer (extent-object overlay)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 (if (null buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 (setq buffer (current-buffer)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 (check-argument-type 'bufferp buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 (if (and (= beg end)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 (not (null (extent-property overlay 'evaporate))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80 (delete-overlay overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 (if (> beg end)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (setq temp beg
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 beg end
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 end temp))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 (set-extent-endpoints overlay beg end buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 overlay)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (defun delete-overlay (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 "Delete the overlay OVERLAY from its buffer."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (detach-extent overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 (defun overlay-start (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 "Return the position at which OVERLAY starts."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (extent-start-position overlay))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (defun overlay-end (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 "Return the position at which OVERLAY ends."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 (extent-end-position overlay))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 (defun overlay-buffer (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 "Return the buffer OVERLAY belongs to."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (extent-object overlay))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (defun overlay-properties (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 "Return a list of the properties on OVERLAY.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 This is a copy of OVERLAY's plist; modifying its conses has no effect on
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 OVERLAY."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (extent-properties overlay))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 (defun overlays-at (pos)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 "Return a list of the overlays that contain position POS."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 (overlays-in pos pos))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (defun overlays-in (beg end)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 "Return a list of the overlays that overlap the region BEG ... END.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124 Overlap means that at least one character is contained within the overlay
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 and also contained within the specified region.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126 Empty overlays are included in the result if they are located at BEG
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 or between BEG and END."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (let (lst)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 (mapcar (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130 (lambda (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (and (extent-property overlay 'overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 (setq lst (append lst (list overlay))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 (extent-list nil beg end))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 lst))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 (defun next-overlay-change (pos)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 "Return the next position after POS where an overlay starts or ends.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 If there are no more overlay boundaries after POS, return (point-max)."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139 (let ((next (point-max))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 end)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 (mapcar (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 (lambda (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 (if (< (setq end (extent-end-position overlay)) next)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 (setq next end))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 (overlays-in pos end))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 next))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148 (defun previous-overlay-change (pos)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 "Return the previous position before POS where an overlay starts or ends.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150 If there are no more overlay boundaries before POS, return (point-min)."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151 (let ((prev (point-min))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 beg)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153 (mapcar (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 (lambda (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (if (and (> (setq beg (extent-start-position overlay)) prev)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 (< beg pos))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157 (setq prev beg))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158 (overlays-in prev pos))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
159 prev))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
160
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
161 (defun overlay-lists ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
162 "Return a pair of lists giving all the overlays of the current buffer.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
163 The car has all the overlays before the overlay center;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
164 the cdr has all the overlays after the overlay center.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
165 Recentering overlays moves overlays between these lists.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
166 The lists you get are copies, so that changing them has no effect.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
167 However, the overlays you get are the real objects that the buffer uses."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
168 (if (not (boundp 'xemacs-internal-overlay-center-pos))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
169 (overlay-recenter (/ (- (point-max) (point-min)) 2)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
170 (let ((pos xemacs-internal-overlay-center-pos)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
171 before after)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
172 (mapcar
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
173 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
174 (lambda (overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
175 (if (extent-property overlay 'overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
176 (if (> pos (extent-end-position overlay))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
177 (setq before (append before (list overlay)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
178 (setq after (append after (list overlay)))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
179 (extent-list))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
180 (list before after)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
181
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
182 (defun overlay-recenter (pos)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
183 "Recenter the overlays of the current buffer around position POS."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
184 (set (make-local-variable 'xemacs-internal-overlay-center-pos) pos))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
185
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
186 (defun overlay-get (overlay prop)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
187 "Get the property of overlay OVERLAY with property name PROP."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
188 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
189 (extent-property overlay prop))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
190
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
191 (defun overlay-put (overlay prop value)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
192 "Set one property of overlay OVERLAY: give property PROP value VALUE."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
193 (check-argument-type 'overlayp overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
194 (cond ((eq prop 'evaporate)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
195 (set-extent-property overlay 'detachable value))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
196 ((eq prop 'before-string)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
197 (set-extent-property overlay 'begin-glyph
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
198 (make-glyph (vector 'string :data value))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
199 ((eq prop 'after-string)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
200 (set-extent-property overlay 'end-glyph
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
201 (make-glyph (vector 'string :data value))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
202 ((memq prop '(window insert-in-front-hooks insert-behind-hooks
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
203 modification-hooks))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
204 (error "cannot support overlay '%s property under XEmacs"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
205 prop)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
206 (set-extent-property overlay prop value))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
207
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
208 (provide 'overlay)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
209
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
210 ;;; overlay.el ends here