annotate lisp/utils/annotations.el @ 159:3bb7ccffb0c0 r20-3b6

Import from CVS: tag r20-3b6
author cvs
date Mon, 13 Aug 2007 09:41:43 +0200
parents 0293115a14e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; annotations.el --- interface to marginal annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992-1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Created: 10-Oct-93, Chuck Thompson <cthomp@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: extensions, hypermedia, outlining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Enhanced by Andy Piper <ajp@eng.cam.ac.uk>: 6-may-94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Last modified: 12-May-95 by Chuck Thompson.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
26 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; The annotations are implemented on top of extents. The extent property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; 'annotation of an extent being used as an annotation is vector of size 6:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; [<data> <action> <menu> <glyph> <down-glyph> <rightp>]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar make-annotation-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "*Function or functions to run immediately after creating an annotation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar before-delete-annotation-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*Function or functions to run immediately before deleting an annotation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar after-delete-annotation-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "*Function or functions to run immediately after deleting an annotation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defvar annotation-local-map-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (set-keymap-name map 'annotation-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (define-key map 'button1 'annotation-activate-function-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (define-key map 'button3 'annotation-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 "Keymap used to activate annotations with only annotation data passed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar annotation-local-map-with-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (set-keymap-name map 'annotation-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (define-key map 'button1 'annotation-activate-function-with-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (define-key map 'button3 'annotation-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 "Keymap used to activate annotations with annotation data and event passed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; When the mouse is pressed and released over an annotation glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; this will run the annotation action passing a single arg, the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; of the annotation data field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun annotation-activate-function-default (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((extent (event-glyph-extent event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (mouse-down t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (up-glyph nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; make the glyph look pressed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (cond ((annotation-down-glyph extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (setq up-glyph (annotation-glyph extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (set-annotation-glyph extent (annotation-down-glyph extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (while mouse-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq event (next-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (button-release-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (setq mouse-down nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; make the glyph look released
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (cond ((annotation-down-glyph extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (set-annotation-glyph extent up-glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (if (eq extent (event-glyph-extent event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if (annotation-action extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (funcall (annotation-action extent) (annotation-data extent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; When the mouse is pressed and released over an annotation glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; this will run the annotation action passing two args, the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; of the annotation data field and the event which triggered the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; annotation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun annotation-activate-function-with-event (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (let ((extent (event-glyph-extent event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (mouse-down t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (up-glyph nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; make the glyph look pressed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (cond ((annotation-down-glyph extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq up-glyph (annotation-glyph extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (set-annotation-glyph extent (annotation-down-glyph extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (while mouse-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (setq event (next-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if (button-release-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (setq mouse-down nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; make the glyph look released
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (cond ((annotation-down-glyph extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (set-annotation-glyph extent up-glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (eq extent (event-glyph-extent event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (if (annotation-action extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (funcall (annotation-action extent) (annotation-data extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; #### Glyphs should be glyphs should be glyphs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defun make-annotation (glyph &optional pos layout buffer with-event d-glyph rightp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 "Create a marginal annotation, displayed using GLYPH, at position POS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 GLYPH may be either a glyph object or a string. Use layout policy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 LAYOUT and place the annotation in buffer BUFFER. If POS is nil, point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 used. If LAYOUT is nil, `whitespace' is used. If BUFFER is nil, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 current buffer is used. If WITH-EVENT is non-nil, then when an annotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 is activated, the triggering event is passed as the second arg to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 annotation function. If D-GLYPH is non-nil then it is used as the glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 that will be displayed when button1 is down. If RIGHTP is non-nil then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 the glyph will be displayed on the right side of the buffer instead of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 left."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (let ((new-annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; get the buffer to add the annotation at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if (not buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (setq buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (setq buffer (get-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; get the position to put it at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if (not pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; make sure it gets some layout policy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if (not layout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq layout 'whitespace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; make sure the glyph arguments are actually glyphs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if (and glyph (not (glyphp glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq glyph (make-glyph glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (and d-glyph (not (glyphp d-glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq d-glyph (make-glyph d-glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; create the actual annotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (setq new-annotation (make-extent pos pos buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (detach-extent new-annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (set-extent-endpoints new-annotation pos pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (if rightp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (set-extent-end-glyph new-annotation glyph layout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (set-extent-begin-glyph new-annotation glyph layout))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (set-extent-property new-annotation 'annotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (vector nil nil nil glyph d-glyph rightp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (set-extent-property new-annotation 'end-closed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (set-extent-property new-annotation 'start-open t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (set-extent-property new-annotation 'duplicable t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if with-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (set-extent-property new-annotation 'keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 annotation-local-map-with-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (set-extent-property new-annotation 'keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 annotation-local-map-default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (run-hook-with-args 'make-annotation-hook new-annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 new-annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (fset 'make-graphic-annotation 'make-annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (make-obsolete 'make-graphic-annotation 'make-annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun delete-annotation (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Remove ANNOTATION from its buffer. This does not modify the buffer text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (run-hook-with-args 'before-delete-annotation-hook annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (delete-extent annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (run-hooks 'after-delete-annotation-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defun annotationp (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "T if OBJECT is an annotation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (and (extent-live-p annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (not (null (extent-property annotation 'annotation)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun annotation-visible (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "T if there is enough available space to display ANNOTATION."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (not (extent-property annotation 'glyph-invisible))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun annotation-at (&optional pos buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Return the first annotation at POS in BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 BUFFER defaults to the current buffer. POS defaults to point in BUFFER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (car (annotations-at pos buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (make-obsolete 'annotation-at 'annotations-at)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun annotation-layout (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Return the layout policy of annotation ANNOTATION. The layout policy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 is set using `set-annotation-layout'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (eq 'right (annotation-side annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (extent-end-glyph-layout annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (extent-begin-glyph-layout annotation))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defun annotation-side (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Return the side of the buffer the annotation is displayed on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Return value is either 'left or 'right."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if (aref (extent-property annotation 'annotation) 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 'right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 'left))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun set-annotation-layout (annotation layout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Set the layout policy of ANNOTATION to LAYOUT. The function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 `annotation-layout' returns the current layout policy."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (eq 'right (annotation-side annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (set-extent-end-glyph-layout annotation layout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (set-extent-begin-glyph-layout annotation layout))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; Now that annotatios use glyphs this function has little value and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; will actually not work as is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;(defun annotation-type (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ; "Return the display type of the annotation ANNOTATION. The type will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;be one of the following symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ; pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ; bitmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ; string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ; nil (the object is not an annotation)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ; (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ; nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ; (let ((glyph (annotation-glyph annotation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ; (if (stringp glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ; 'stringp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ; (if (not (pixmapp glyph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ; (error "%s is a corrupt annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ; (if (> (pixmap-depth glyph) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ; 'pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ; 'bitmap))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (make-obsolete 'annotation-type "This function no longer has any meaning.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun annotation-width (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "Return the width of the annotation ANNOTATION in pixels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (glyph-width (annotation-glyph annotation))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (defun annotation-glyph (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "If ANNOTATION is of type `string' return the string. Otherwise, return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 the glyph object used to display ANNOTATION. The glyph is set using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 `set-annotation-glyph'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (aref (extent-property annotation 'annotation) 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defun set-annotation-glyph (annotation glyph &optional layout side)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "Set the representation of ANNOTATION to GLYPH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 GLYPH should be a glyph object. If LAYOUT is non-nil, set the layout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 policy of the annotation to LAYOUT. If SIDE is equal to 'left or 'right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 change the side of the annotation to that value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 The function `annotation-glyph' returns the current glyph."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (not layout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (setq layout (extent-layout annotation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (or (eq side 'right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (and (not (eq side 'left))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (eq (annotation-side annotation) 'right)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (set-extent-end-glyph annotation glyph layout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (set-extent-begin-glyph annotation glyph layout))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (aset (extent-property annotation 'annotation) 3 glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (if (eq side 'right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (aset (extent-property annotation 'annotation) 5 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (eq side 'left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (aset (extent-property annotation 'annotation) 5 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (annotation-glyph annotation))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun annotation-down-glyph (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "If ANNOTATION is of type `string' return the down string. Otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 return the glyph object of the down-glyph representing ANNOTATION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 The down-glyph is set using `set-annotation-down-glyph'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (aref (extent-property annotation 'annotation) 4)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defun set-annotation-down-glyph (annotation glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 "Set the depressed representation of ANNOTATION to GLYPH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 GLYPH should be a glyph object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 The function `annotation-down-glyph' returns the current down-glyph."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (aset (extent-property annotation 'annotation) 4 glyph)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (define-obsolete-function-alias 'annotation-graphic 'annotation-glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (define-obsolete-function-alias 'set-annotation-graphic 'set-annotation-glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defun annotation-data (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "Return the data associated with annotation ANNOTATION. The data is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 set using `set-annotation-data'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (aref (extent-property annotation 'annotation) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (defun set-annotation-data (annotation data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 "Set the data field of ANNOTATION to DATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 The function `annotation-data' returns the current data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (aset (extent-property annotation 'annotation) 0 data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun annotation-action (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 "Return the action associated with annotation ANNOTATION. The action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 is set using `set-annotation-action'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (aref (extent-property annotation 'annotation) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defun set-annotation-action (annotation action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Set the action field of ANNOTATION to ACTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 The function `annotation-action' returns the current action."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (aset (extent-property annotation 'annotation) 1 action)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (defun annotation-face (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "Return the face associated with annotation ANNOTATION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 The face is set using `set-annotation-face'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (extent-face annotation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defun set-annotation-face (annotation face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "Set the face associated with annotation ANNOTATION to FACE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 The function `annotation-face' returns the current face."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (set-extent-face annotation face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun hide-annotation (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Remove ANNOTATION's glyph so that it is invisible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (if (eq (annotation-side annotation) 'left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (set-extent-begin-glyph annotation nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (set-extent-end-glyph annotation nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (define-obsolete-function-alias 'annotation-hide 'hide-annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defun reveal-annotation (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "Add ANNOTATION's glyph so that it is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (eq (annotation-side annotation) 'left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (set-extent-begin-glyph annotation (annotation-glyph annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (set-extent-end-glyph annotation (annotation-glyph annotation))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (define-obsolete-function-alias 'annotation-reveal 'reveal-annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun annotations-in-region (start end buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "Return all annotations in BUFFER between START and END inclusively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (if (< start (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (error "<start> not in range of buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if (> end (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (error "<end> not in range of buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (let (note-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (map-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (function (lambda (extent dummy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if (annotationp extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (setq note-list (cons extent note-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 buffer start end nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 note-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun annotations-at (&optional pos buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "Return a list of all annotations at POS in BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 If BUFFER is nil, the current buffer is used. If POS is nil, point is used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (if (not buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if (not pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (setq pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (annotations-in-region pos pos buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (defun annotation-list (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 "Return a list of all annotations in BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 If BUFFER is nil, the current buffer is used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (if (not buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (annotations-in-region (point-min) (point-max) buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defun all-annotations ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "Return a list of all annotations in existence."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (let ((b (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (while b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq result (nconc result (annotation-list (car b))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (setq b (cdr b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;;; #### really this menus junk should append to the prevailing menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;;; in the same way `popup-mode-menu' does. --jwz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; annotations menu stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (defun annotation-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 "Pop up a menu of annotations commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 Point is temporarily moved to the click position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (let ((extent (event-glyph-extent event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (goto-char (extent-end-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if (annotation-menu extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (popup-menu (annotation-menu extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (popup-mode-menu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (defun set-annotation-menu (annotation menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 "Set the menu field of ANNOTATION to MENU. The function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 `annotation-menu' returns the current menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (aset (extent-property annotation 'annotation) 2 menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (defun annotation-menu (annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 "Return the menu associated with annotation ANNOTATION. The menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 is set using `set-annotation-menu'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (not (annotationp annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (error "%s is not an annotation" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (aref (extent-property annotation 'annotation) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (provide 'annotations)