0
|
1 ;;; outl-mouse.el --- outline mode mouse commands for Emacs
|
|
2
|
|
3 ;; Copyright 1994 (C) Andy Piper <ajp@eng.cam.ac.uk>
|
|
4 ;; Keywords: outlines, mouse
|
|
5
|
|
6 ;; This file is part of XEmacs.
|
|
7
|
|
8 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
9 ;; under the terms of the GNU General Public License as published by
|
|
10 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;; any later version.
|
|
12
|
|
13 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 ;; General Public License for more details.
|
|
17
|
|
18 ;; You should have received a copy of the GNU General Public License
|
|
19 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
20 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21 ;;
|
|
22 ;; outl-mouse.el v1.3.8:
|
|
23 ;;
|
|
24 ;; Defines button one to hide blocks when clicked on outline-up-arrow
|
|
25 ;; and expand blocks when clicked on outline-down-arrow. Features are
|
|
26 ;; activated when outline-minor-mode or outline-mode are turned
|
|
27 ;; on. There is also a menu for each glyph on button 3.
|
|
28 ;;
|
|
29 ;; To use put:
|
|
30 ;; (require 'outl-mouse)
|
|
31 ;; in your .emacs file.
|
|
32 ;;
|
|
33 ;; If you use func-menu all the time and want outl-mouse on all the
|
|
34 ;; time as well then put:
|
|
35 ;; (setq outline-sync-with-func-menu t)
|
|
36 ;; outlining will then be turned on when func-menu is. Note that this
|
|
37 ;; requires a patch to func-menu 2.16 (in 19.10) to work:
|
|
38 ;;
|
|
39 ;RCS file: func-menu.el,v
|
|
40 ;retrieving revision 1.1
|
|
41 ;diff -r1.1 func-menu.el
|
|
42 ;180a181,183
|
|
43 ;> (defvar fume-found-function-hook nil
|
|
44 ;> "*Hook to call after every function match.")
|
|
45 ;>
|
|
46 ;1137,1138c1140,1142
|
|
47 ;< (if (listp funcname)
|
|
48 ;< (setq funclist (cons funcname funclist)))
|
|
49 ;---
|
|
50 ;> (cond ((listp funcname)
|
|
51 ;> (setq funclist (cons funcname funclist))
|
|
52 ;> (save-excursion (run-hooks 'fume-found-function-hook))))
|
|
53 ;;
|
|
54 ;; If you want mac-style outlining then set outline-mac-style to t.
|
|
55 ;; If you want the outline arrows on the left then set
|
|
56 ;; outline-glyphs-on-left to t. If you have xpm then arrows are much
|
|
57 ;; better defined.
|
|
58 ;;
|
|
59 ;; This package uses func-menu to define outline regexps if they are
|
|
60 ;; not already defined. You should no longer need to use out-xtra.
|
|
61 ;;
|
|
62 ;; You can define the package to do something other than outlining by
|
|
63 ;; setting outline-fold-in-function and outline-fold-out-function.
|
|
64 ;;
|
|
65 ;; You can define the color of outline arrows, but only in your .emacs.
|
|
66 ;;
|
|
67 ;; Only works in XEmacs 19.10 and onwards.
|
|
68 ;;
|
|
69 ;; User definable variables.
|
|
70 ;;
|
|
71 (defvar outline-mac-style nil
|
|
72 "*If t then outline glyphs will be right and down arrows.")
|
|
73
|
|
74 (defvar outline-glyphs-on-left nil
|
|
75 "*The position of outline glyphs on a line.")
|
|
76
|
|
77 (defvar outline-glyph-colour "Gray75"
|
|
78 "*The colour of outlining arrows.")
|
|
79
|
|
80 (defvar outline-glyph-shade-colour "Gray40"
|
|
81 "*The shadow colour of outlining arrows.")
|
|
82
|
|
83 (defvar outline-glyph-lit-colour "Gray90"
|
|
84 "*The lit colour of outlining arrows.")
|
|
85
|
|
86 (defvar outline-fold-in-function 'outline-fold-in
|
|
87 "Function to call for folding in.
|
|
88 The function should take an annotation argument.")
|
|
89 (make-variable-buffer-local 'outline-fold-in-function)
|
|
90
|
|
91 (defvar outline-fold-out-function 'outline-fold-out
|
|
92 "Function to call for folding out.
|
|
93 The function should take an annotation argument.")
|
|
94 (make-variable-buffer-local 'outline-fold-out-function)
|
|
95
|
|
96 (defvar outline-sync-with-func-menu nil
|
|
97 "*If t then outline glyphs are permanently added by func-menu scans.
|
|
98 If outline-minor-mode is turned off then turing it back on will have
|
|
99 no effect. Instead the buffer should be rescanned from the function
|
|
100 menu.")
|
|
101
|
|
102 (defvar outline-move-point-after-click t
|
|
103 "*If t then point is moved to the current heading when clicked.")
|
|
104
|
|
105 (defvar outline-scanning-message "Adding glyphs... (%3d%%)"
|
|
106 "*Progress message during the scanning of the buffer.
|
|
107 Set this to nil to inhibit progress messages.")
|
|
108
|
|
109 ;;
|
|
110 ;; No user definable variables beyond this point.
|
|
111 ;;
|
|
112 (defconst outline-up-arrow
|
|
113 (make-pixmap ; an up-arrow
|
|
114 (if (featurep 'xpm)
|
|
115 (concat "/* XPM */
|
|
116 static char * arrow[] = {
|
|
117 \"10 10 5 1\",
|
|
118 \" c none\",
|
|
119 \". c " outline-glyph-lit-colour "\",
|
|
120 \"X c " outline-glyph-shade-colour "\",
|
|
121 \"o c " outline-glyph-colour "\",
|
|
122 \"O c " outline-glyph-shade-colour "\",
|
|
123 \" .X \",
|
|
124 \" .X \",
|
|
125 \" ..XX \",
|
|
126 \" ..XX \",
|
|
127 \" ..ooXX \",
|
|
128 \" ..ooXX \",
|
|
129 \" ..ooooXX \",
|
|
130 \" ..ooooXX \",
|
|
131 \"..OOOOOOXX\",
|
|
132 \"OOOOOOOOOO\"};")
|
|
133 (list 10 10 (concat "\000\000\000\000\060\000\060\000\150\000"
|
|
134 "\150\000\324\000\324\000\376\001\376\001"))))
|
|
135 "Bitmap object for outline up glyph.")
|
|
136
|
|
137 (defconst outline-up-arrow-mask
|
|
138 (make-pixmap ; an up-arrow
|
|
139 (if (featurep 'xpm)
|
|
140 (concat "/* XPM */
|
|
141 static char * arrow[] = {
|
|
142 \"10 10 5 1\",
|
|
143 \" c none\",
|
|
144 \". c " outline-glyph-shade-colour "\",
|
|
145 \"X c " outline-glyph-lit-colour "\",
|
|
146 \"o c " outline-glyph-colour "\",
|
|
147 \"O c " outline-glyph-lit-colour "\",
|
|
148 \" .X \",
|
|
149 \" .X \",
|
|
150 \" ..XX \",
|
|
151 \" ..XX \",
|
|
152 \" ..ooXX \",
|
|
153 \" ..ooXX \",
|
|
154 \" ..ooooXX \",
|
|
155 \" ..ooooXX \",
|
|
156 \"..OOOOOOXX\",
|
|
157 \"OOOOOOOOOO\"};")
|
|
158 (list 10 10 (concat "\000\000\000\000\060\000\060\000\130\000"
|
|
159 "\130\000\254\000\274\000\006\001\376\001"))))
|
|
160 "Bitmap object for outline depressed up glyph.")
|
|
161
|
|
162 (defconst outline-down-arrow
|
|
163 (make-pixmap ; a down-arrow
|
|
164 (if (featurep 'xpm)
|
|
165 (concat "/* XPM */
|
|
166 static char * down[] = {
|
|
167 \"10 10 5 1\",
|
|
168 \" c " outline-glyph-lit-colour "\",
|
|
169 \". c " outline-glyph-lit-colour "\",
|
|
170 \"X c " outline-glyph-shade-colour "\",
|
|
171 \"o c none\",
|
|
172 \"O c " outline-glyph-colour "\",
|
|
173 \" \",
|
|
174 \".. XX\",
|
|
175 \"o..OOOOXXo\",
|
|
176 \"o..OOOOXXo\",
|
|
177 \"oo..OOXXoo\",
|
|
178 \"oo..OOXXoo\",
|
|
179 \"ooo..XXooo\",
|
|
180 \"ooo..XXooo\",
|
|
181 \"oooo.Xoooo\",
|
|
182 \"oooo.Xoooo\"};")
|
|
183 (list 10 10 (concat "\000\000\000\000\376\001\202\001\364\000"
|
|
184 "\324\000\150\000\150\000\060\000\060\000"))))
|
|
185 "Bitmap object for outline down glyph.")
|
|
186
|
|
187 (defconst outline-down-arrow-mask
|
|
188 (make-pixmap ; a down-arrow
|
|
189 (if (featurep 'xpm)
|
|
190 (concat "/* XPM */
|
|
191 static char * down[] = {
|
|
192 \"10 10 5 1\",
|
|
193 \" c " outline-glyph-shade-colour "\",
|
|
194 \". c " outline-glyph-shade-colour "\",
|
|
195 \"X c " outline-glyph-lit-colour "\",
|
|
196 \"o c none\",
|
|
197 \"O c " outline-glyph-colour "\",
|
|
198 \" \",
|
|
199 \".. XX\",
|
|
200 \"o..OOOOXXo\",
|
|
201 \"o..OOOOXXo\",
|
|
202 \"oo..OOXXoo\",
|
|
203 \"oo..OOXXoo\",
|
|
204 \"ooo..XXooo\",
|
|
205 \"ooo..XXooo\",
|
|
206 \"oooo.Xoooo\",
|
|
207 \"oooo.Xoooo\"};")
|
|
208 (list 10 10 (concat "\000\000\000\000\376\001\376\001\254\000"
|
|
209 "\254\000\130\000\130\000\060\000\060\000"))))
|
|
210 "Bitmap object for outline depressed down glyph.")
|
|
211
|
|
212 (defconst outline-right-arrow
|
|
213 (make-pixmap ; a right-arrow
|
|
214 (if (featurep 'xpm)
|
|
215 (concat "/* XPM */
|
|
216 static char * right[] = {
|
|
217 \"10 10 5 1\",
|
|
218 \" c " outline-glyph-lit-colour "\",
|
|
219 \". c " outline-glyph-lit-colour "\",
|
|
220 \"X c none\",
|
|
221 \"o c " outline-glyph-colour "\",
|
|
222 \"O c " outline-glyph-shade-colour "\",
|
|
223 \" .XXXXXXXX\",
|
|
224 \" ...XXXXXX\",
|
|
225 \" ....XXXX\",
|
|
226 \" oo....XX\",
|
|
227 \" oooo....\",
|
|
228 \" ooooOOOO\",
|
|
229 \" ooOOOOXX\",
|
|
230 \" OOOOXXXX\",
|
|
231 \" OOOXXXXXX\",
|
|
232 \" OXXXXXXXX\"};")
|
|
233 (list 10 10 (concat "\000\000\006\000\032\000\142\000\232\001"
|
|
234 "\352\001\172\000\036\000\006\000\000\000"))))
|
|
235 "Bitmap object for outline right glyph.")
|
|
236
|
|
237 (defconst outline-right-arrow-mask
|
|
238 (make-pixmap ; a right-arrow
|
|
239 (if (featurep 'xpm)
|
|
240 (concat "/* XPM */
|
|
241 static char * right[] = {
|
|
242 \"10 10 5 1\",
|
|
243 \" c " outline-glyph-shade-colour "\",
|
|
244 \". c " outline-glyph-shade-colour "\",
|
|
245 \"X c none\",
|
|
246 \"o c " outline-glyph-colour "\",
|
|
247 \"O c " outline-glyph-lit-colour "\",
|
|
248 \" .XXXXXXXX\",
|
|
249 \" ...XXXXXX\",
|
|
250 \" ....XXXX\",
|
|
251 \" oo....XX\",
|
|
252 \" oooo....\",
|
|
253 \" ooooOOOO\",
|
|
254 \" ooOOOOXX\",
|
|
255 \" OOOOXXXX\",
|
|
256 \" OOOXXXXXX\",
|
|
257 \" OXXXXXXXX\"};")
|
|
258 (list 10 10 (concat "\000\000\006\000\036\000\176\000\346\001"
|
|
259 "\236\001\146\000\036\000\006\000\000\000"))))
|
|
260 "Bitmap object for outline depressed right glyph.")
|
|
261
|
|
262 (defvar outline-glyph-menu
|
|
263 '("Outline Commands"
|
|
264 ["Hide all" hide-body t]
|
|
265 ["Hide all subtrees" hide-subtrees-same-level t]
|
8
|
266 ["Hide subtree" hide-subtree t]
|
|
267 ; ["Hide body" hide-body t]
|
0
|
268 "---"
|
8
|
269 ["Show all" show-all t]
|
0
|
270 ["Show subtree" show-subtree t]
|
|
271 ["Show body" show-entry t]
|
|
272 "---"
|
|
273 ["Update buffer" outline-add-glyphs t]
|
|
274 ["Rescan buffer" outline-rescan-buffer t])
|
|
275 "Menu of commands for outline glyphs.")
|
|
276
|
|
277 (set-pixmap-contributes-to-line-height outline-down-arrow nil)
|
|
278 (set-pixmap-contributes-to-line-height outline-up-arrow nil)
|
|
279 (set-pixmap-contributes-to-line-height outline-down-arrow-mask nil)
|
|
280 (set-pixmap-contributes-to-line-height outline-up-arrow-mask nil)
|
|
281 (set-pixmap-contributes-to-line-height outline-right-arrow nil)
|
|
282 (set-pixmap-contributes-to-line-height outline-right-arrow-mask nil)
|
|
283
|
|
284 (require 'annotations)
|
|
285 (require 'advice) ; help me doctor !
|
|
286 (require 'outline)
|
|
287 (require 'func-menu) ; for those most excellent regexps.
|
|
288
|
|
289 (add-hook 'outline-mode-hook 'outline-mouse-hooks)
|
|
290 (add-hook 'outline-minor-mode-hook 'outline-mouse-hooks)
|
|
291 ;; I thought this was done already ...
|
|
292 (make-variable-buffer-local 'outline-regexp)
|
|
293 (make-variable-buffer-local 'outline-level)
|
|
294
|
|
295 (cond (outline-sync-with-func-menu
|
|
296 (add-hook 'fume-found-function-hook 'outline-heading-add-glyph-1)
|
|
297 (setq-default fume-rescan-buffer-hook '(lambda ()
|
|
298 (outline-minor-mode 1)))))
|
|
299
|
|
300 (defadvice fume-set-defaults (after fume-set-defaults-ad activate)
|
|
301 "Advise fume-set-defaults to setup outline regexps."
|
|
302 (if (and (not (assq 'outline-regexp (buffer-local-variables)))
|
|
303 fume-function-name-regexp)
|
|
304 (progn
|
|
305 (setq outline-regexp (if (listp fume-function-name-regexp)
|
|
306 (car fume-function-name-regexp)
|
|
307 fume-function-name-regexp))
|
|
308 (setq outline-level '(lambda () 1)))))
|
|
309
|
|
310 (defadvice outline-minor-mode (after outline-mode-mouse activate)
|
|
311 "Advise outline-minor-mode to delete glyphs when switched off."
|
|
312 (if (not outline-minor-mode)
|
|
313 (progn
|
|
314 (outline-delete-glyphs)
|
|
315 (show-all))))
|
|
316
|
|
317 ;; advise all outline commands so that glyphs are synced after use
|
|
318 (defadvice show-all (after show-all-ad activate)
|
|
319 "Advise show-all to sync headings."
|
|
320 (outline-sync-visible-sub-headings-in-region (point-min) (point-max)))
|
|
321
|
|
322 (defadvice hide-subtree (after hide-subtree-ad activate)
|
|
323 "Advise hide-subtree to sync headings."
|
|
324 (outline-sync-visible-sub-headings))
|
|
325
|
|
326 (defadvice hide-entry (after hide-entry-ad activate)
|
|
327 "Advise hide-entry to sync headings."
|
|
328 (outline-sync-visible-sub-headings))
|
|
329
|
|
330 (defadvice hide-body (after hide-body-ad activate)
|
|
331 "Advise hide-body to sync headings."
|
|
332 (outline-sync-visible-sub-headings-in-region (point-min) (point-max)))
|
|
333
|
|
334 (defadvice show-subtree (after show-subtree-ad activate)
|
|
335 "Advise show-subtree to sync headings."
|
|
336 (outline-sync-visible-sub-headings))
|
|
337
|
|
338 (defadvice show-entry (after show-entry-ad activate)
|
|
339 "Advise shown-entry to sync headings."
|
|
340 (outline-sync-visible-sub-headings))
|
|
341
|
|
342 ;;;###autoload
|
|
343 (defun outl-mouse-mode ()
|
|
344 "Calls outline-mode, with outl-mouse extensions"
|
|
345 (interactive)
|
|
346 (outline-mode))
|
|
347
|
|
348 ;;;###autoload
|
|
349 (defun outl-mouse-minor-mode (&optional arg)
|
|
350 "Toggles outline-minor-mode, with outl-mouse extensions"
|
|
351 (interactive "P")
|
|
352 (outline-minor-mode arg))
|
|
353
|
|
354 (defun hide-subtrees-same-level ()
|
|
355 "Hide all subtrees below the current level."
|
|
356 (interactive)
|
|
357 (save-excursion
|
|
358 (while (progn
|
|
359 (hide-subtree)
|
|
360 (condition-case nil
|
|
361 (progn
|
|
362 (outline-forward-same-level 1)
|
|
363 t)
|
|
364 (error nil))))))
|
|
365
|
|
366 (defun outline-mouse-hooks ()
|
|
367 "Hook for installing outlining with the mouse."
|
|
368 ;; use function menu regexps if not set
|
|
369 (fume-set-defaults)
|
|
370 ;; only add glyphs when we're not synced.
|
|
371 (if (not outline-sync-with-func-menu) (outline-add-glyphs))
|
|
372 ;; add C-a to local keymap
|
|
373 (let ((outline (cond ((keymapp (lookup-key (current-local-map)
|
|
374 outline-minor-mode-prefix))
|
|
375 (lookup-key (current-local-map)
|
|
376 outline-minor-mode-prefix))
|
|
377 (t
|
|
378 (define-key (current-local-map)
|
|
379 outline-minor-mode-prefix (make-sparse-keymap))
|
|
380 (lookup-key (current-local-map)
|
|
381 outline-minor-mode-prefix)))))
|
|
382 (define-key outline "\C-a" 'outline-heading-add-glyph)
|
|
383 (define-key outline-mode-map "\C-c\C-a" 'outline-heading-add-glyph)))
|
|
384
|
|
385 (defun outline-add-glyphs ()
|
|
386 "Add annotations and glyphs to all heading lines that don't have them."
|
|
387 (interactive)
|
|
388 (save-excursion
|
|
389 (and outline-scanning-message (message outline-scanning-message 0))
|
|
390 (goto-char (point-min))
|
|
391 (if (not (outline-on-heading-p)) (outline-next-visible-heading-safe))
|
|
392 (while
|
|
393 (progn
|
|
394 (outline-heading-add-glyph-1)
|
|
395 (and outline-scanning-message
|
|
396 (message outline-scanning-message (fume-relative-position)))
|
|
397 (outline-next-visible-heading-safe)))
|
|
398 (and outline-scanning-message
|
|
399 (message "%s done" (format outline-scanning-message 100)))))
|
|
400
|
|
401 (defun outline-delete-glyphs ()
|
|
402 "Remove annotations and glyphs from heading lines."
|
|
403 (save-excursion
|
|
404 (mapcar 'outline-heading-delete-glyph (annotation-list))))
|
|
405
|
|
406 (defun outline-rescan-buffer ()
|
|
407 "Remove and insert all annotations."
|
|
408 (interactive)
|
|
409 (outline-delete-glyphs)
|
|
410 (outline-add-glyphs)
|
|
411 (save-excursion
|
|
412 (outline-sync-visible-sub-headings-in-region (point-min) (point-max))))
|
|
413
|
|
414 (defun outline-heading-delete-glyph (ext)
|
|
415 "Delete annotation and glyph from a heading with annotation EXT."
|
|
416 (if (and
|
|
417 (progn
|
|
418 (goto-char (extent-start-position ext))
|
|
419 (beginning-of-line)
|
|
420 (outline-on-heading-p))
|
|
421 (extent-property ext 'outline))
|
|
422 (delete-annotation ext))
|
|
423 nil)
|
|
424
|
|
425 (defun outline-heading-add-glyph ()
|
|
426 "Interactive version of outline-heading-add-glyph-1."
|
|
427 (interactive)
|
|
428 (save-excursion
|
|
429 (outline-heading-add-glyph-1)))
|
|
430
|
|
431 (defun outline-heading-add-glyph-1 ()
|
|
432 "Add glyph to the end of heading line which point is on.
|
|
433 Returns nil if point is not on a heading or glyph already exists."
|
|
434 (if (or (not (outline-on-heading-p))
|
|
435 (outline-heading-has-glyph-p)
|
|
436 (save-excursion (forward-line) (outline-on-heading-p)))
|
|
437 nil
|
|
438 (outline-back-to-heading)
|
|
439 (let ((anot2
|
|
440 (make-annotation (if outline-mac-style
|
|
441 outline-right-arrow
|
|
442 outline-down-arrow)
|
|
443 (save-excursion (if outline-glyphs-on-left nil
|
|
444 (outline-end-of-heading))
|
|
445 (point))
|
|
446 'text nil t
|
|
447 (if outline-mac-style
|
|
448 outline-right-arrow-mask
|
|
449 outline-down-arrow-mask)))
|
|
450 (anot1
|
|
451 (make-annotation (if outline-mac-style
|
|
452 outline-down-arrow
|
|
453 outline-up-arrow)
|
|
454 (save-excursion (if outline-glyphs-on-left nil
|
|
455 (outline-end-of-heading))
|
|
456 (point))
|
|
457 'text nil t
|
|
458 (if outline-mac-style
|
|
459 outline-down-arrow-mask
|
|
460 outline-up-arrow-mask))))
|
|
461 ;; we cunningly make the annotation data point to its twin.
|
|
462 (set-annotation-data anot1 anot2)
|
|
463 (set-extent-property anot1 'outline 'up)
|
|
464 (set-annotation-action anot1 'outline-up-click)
|
|
465 (set-annotation-menu anot1 outline-glyph-menu)
|
|
466 (set-extent-priority anot1 1)
|
|
467 (set-annotation-data anot2 anot1)
|
|
468 (set-extent-property anot2 'outline 'down)
|
|
469 (set-annotation-menu anot2 outline-glyph-menu)
|
|
470 (set-annotation-action anot2 'outline-down-click)
|
|
471 (annotation-hide anot2))
|
|
472 t))
|
|
473
|
|
474 (defun outline-heading-has-glyph-p ()
|
|
475 "Return t if heading has an outline glyph."
|
|
476 (catch 'found
|
|
477 (mapcar
|
|
478 '(lambda(a)
|
|
479 (if (extent-property a 'outline)
|
|
480 (throw 'found t)))
|
|
481 (annotations-in-region (save-excursion (outline-back-to-heading) (point))
|
|
482 (save-excursion (outline-end-of-heading)
|
|
483 (+ 1 (point)))
|
|
484 (current-buffer)))
|
|
485 nil))
|
|
486
|
|
487 (defun outline-sync-visible-sub-headings-in-region (pmin pmax)
|
|
488 "Make sure all anotations on headings in region PMIN PMAX are
|
|
489 displayed correctly."
|
|
490 (mapcar '(lambda (x)
|
|
491 (goto-char (extent-start-position x))
|
|
492 (beginning-of-line)
|
|
493 (cond ((and (eq (extent-property x 'outline) 'down)
|
|
494 ;; skip things we can't see
|
|
495 (not (eq (preceding-char) ?\^M)))
|
|
496 (if (outline-more-to-hide)
|
|
497 ;; reveal my twin
|
|
498 (annotation-reveal (annotation-data x))
|
|
499 (annotation-hide (annotation-data x)))
|
|
500 (if (not (outline-hidden-p))
|
|
501 ;; hide my self
|
|
502 (annotation-hide x)
|
|
503 (annotation-reveal x)))))
|
|
504 (annotations-in-region pmin pmax (current-buffer))))
|
|
505
|
|
506 (defun outline-sync-visible-sub-headings ()
|
|
507 "Make sure all anotations on sub-headings below the one point is on are
|
|
508 displayed correctly."
|
|
509 (outline-sync-visible-sub-headings-in-region
|
|
510 (point)
|
|
511 (progn (outline-end-of-subtree) (point))))
|
|
512
|
|
513 (defun outline-fold-out (annotation)
|
|
514 "Fold out the current heading."
|
|
515 (beginning-of-line)
|
|
516 ; (if (not (equal (condition-case nil
|
|
517 ; (save-excursion (outline-next-visible-heading 1)
|
|
518 ; (point))
|
|
519 ; (error nil))
|
|
520 ; (save-excursion (outline-next-heading)
|
|
521 ; (if (eobp) nil (point)))))
|
|
522 (if (save-excursion (outline-next-heading)
|
|
523 (eq (preceding-char) ?\^M))
|
|
524 (progn
|
|
525 (save-excursion (show-children))
|
|
526 (outline-sync-visible-sub-headings))
|
|
527 ;; mess with single entry
|
|
528 (if (outline-hidden-p)
|
|
529 (progn
|
|
530 (save-excursion (show-entry))
|
|
531 ;; reveal my twin and hide me
|
|
532 (annotation-hide annotation)
|
|
533 (annotation-reveal (annotation-data annotation))))))
|
|
534
|
|
535 (defun outline-fold-in (annotation)
|
|
536 "Fold in the current heading."
|
|
537 (beginning-of-line)
|
|
538 ;; mess with single entries
|
|
539 (if (not (outline-hidden-p))
|
|
540 (progn
|
|
541 (save-excursion (hide-entry))
|
|
542 (if (not (outline-more-to-hide))
|
|
543 (annotation-hide annotation))
|
|
544 (annotation-reveal (annotation-data annotation)))
|
|
545 ;; otherwise look for more leaves
|
|
546 (save-excursion
|
|
547 (if (outline-more-to-hide t)
|
|
548 (hide-subtree)
|
|
549 (hide-leaves)))
|
|
550 ;; sync everything
|
|
551 (outline-sync-visible-sub-headings)))
|
|
552
|
|
553 (defun outline-more-to-hide (&optional arg)
|
|
554 "Return t if there are more visible sub-headings or text.
|
|
555 With ARG return t only if visible sub-headings have no visible text."
|
|
556 (if (not (outline-hidden-p))
|
|
557 (if arg nil t)
|
|
558 (save-excursion
|
|
559 (and (< (funcall outline-level) (condition-case nil
|
|
560 (progn
|
|
561 (outline-next-visible-heading 1)
|
|
562 (funcall outline-level))
|
|
563 (error 0)))
|
|
564 (if (and (not (outline-hidden-p)) arg)
|
|
565 nil t)))))
|
|
566
|
|
567 (defun outline-hidden-p ()
|
|
568 "Return t if point is on the header of a hidden subtree."
|
|
569 (save-excursion
|
|
570 (let ((end-of-entry (save-excursion (outline-next-heading))))
|
|
571 ;; Make sure that the end of the entry really exists.
|
|
572 (if (not end-of-entry)
|
|
573 (setq end-of-entry (point-max)))
|
|
574 (outline-back-to-heading)
|
|
575 ;; If there are ANY ^M's, the entry is hidden.
|
|
576 (search-forward "\^M" end-of-entry t))))
|
|
577
|
|
578 (defun outline-next-visible-heading-safe ()
|
|
579 "Safely go to the next visible heading.
|
|
580 nil is returned if there is none."
|
|
581 (condition-case nil
|
|
582 (progn
|
|
583 (outline-next-visible-heading 1)
|
|
584 t)
|
|
585 (error nil)))
|
|
586
|
|
587 (defun outline-up-click (data ev)
|
|
588 "Annotation action for clicking on an up arrow.
|
|
589 DATA is the annotation data. EV is the mouse click event."
|
|
590 (save-excursion
|
|
591 (goto-char (extent-end-position (event-glyph-extent ev)))
|
|
592 (funcall outline-fold-in-function (event-glyph-extent ev)))
|
|
593 (if outline-move-point-after-click
|
|
594 (progn
|
|
595 (goto-char (extent-end-position (event-glyph-extent ev)))
|
|
596 (beginning-of-line))))
|
|
597 ; This line demonstrates a bug in redisplay
|
|
598 (defun outline-down-click (data ev)
|
|
599 "Annotation action for clicking on a down arrow.
|
|
600 DATA is the annotation data. EV is the mouse click event."
|
|
601 (save-excursion
|
|
602 (goto-char (extent-end-position (event-glyph-extent ev)))
|
|
603 (funcall outline-fold-out-function (event-glyph-extent ev)))
|
|
604 (if outline-move-point-after-click
|
|
605 (progn
|
|
606 (goto-char (extent-end-position (event-glyph-extent ev)))
|
|
607 (beginning-of-line))))
|
|
608
|
|
609
|
|
610 (provide 'outl-mouse)
|
|
611 (provide 'outln-18) ; fool auctex - outline is ok now.
|
|
612
|
|
613 ;; Local Variables:
|
|
614 ;; outline-regexp: ";;; \\|(def.."
|
|
615 ;; End:
|
|
616
|
|
617
|
|
618
|