annotate lisp/utils/annotations.el @ 0:376386a54a3c r19-14

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