/[emacs]/emacs/lisp/reveal.el
ViewVC logotype

Diff of /emacs/lisp/reveal.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10.4.1 by handa, Fri Apr 16 12:50:09 2004 UTC revision 1.10.4.2 by miles, Thu Nov 4 08:55:36 2004 UTC
# Line 1  Line 1 
1  ;;; reveal.el --- Automatically reveal hidden text at point  ;;; reveal.el --- Automatically reveal hidden text at point
2    
3  ;; Copyright (C) 2000, 2001  Free Software Foundation, Inc.  ;; Copyright (C) 2000, 2001, 2004  Free Software Foundation, Inc.
4    
5  ;; Author: Stefan Monnier <monnier@cs.yale.edu>  ;; Author: Stefan Monnier <monnier@cs.yale.edu>
6  ;; Keywords: outlines  ;; Keywords: outlines
# Line 59  Line 59 
59  (defvar reveal-open-spots nil)  (defvar reveal-open-spots nil)
60  (make-variable-buffer-local 'reveal-open-spots)  (make-variable-buffer-local 'reveal-open-spots)
61    
62    (defvar reveal-last-tick nil)
63    (make-variable-buffer-local 'reveal-last-tick)
64    
65  ;; Actual code  ;; Actual code
66    
67  (defun reveal-post-command ()  (defun reveal-post-command ()
# Line 90  Line 93 
93                            (overlays-at (point))))                            (overlays-at (point))))
94           (push (cons (selected-window) ol) reveal-open-spots)           (push (cons (selected-window) ol) reveal-open-spots)
95           (setq old-ols (delq ol old-ols))           (setq old-ols (delq ol old-ols))
96           (let ((open (overlay-get ol 'reveal-toggle-invisible)))           (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
97             (when (or open             (when (or open
98                       (let ((inv (overlay-get ol 'invisible)))                       (and (setq inv (overlay-get ol 'invisible))
99                         (and inv (symbolp inv)                            (symbolp inv)
100                              (or (setq open (or (get inv 'reveal-toggle-invisible)                            (or (setq open (or (get inv 'reveal-toggle-invisible)
101                                                 (overlay-get ol 'isearch-open-invisible-temporary)))                                               (overlay-get ol 'isearch-open-invisible-temporary)))
102                                  (overlay-get ol 'isearch-open-invisible)                                (overlay-get ol 'isearch-open-invisible)
103                                  (and (consp buffer-invisibility-spec)                                (and (consp buffer-invisibility-spec)
104                                       (assq inv buffer-invisibility-spec)))                                     (assq inv buffer-invisibility-spec)))
105                              (overlay-put ol 'reveal-invisible inv))))                            (overlay-put ol 'reveal-invisible inv)))
106               (if (null open)               (if (null open)
107                   (overlay-put ol 'invisible nil)                   (overlay-put ol 'invisible nil)
108                 ;; Use the provided opening function and repeat (since the                 ;; Use the provided opening function and repeat (since the
# Line 113  Line 116 
116                          (setq repeat nil)                          (setq repeat nil)
117                          (overlay-put ol 'invisible nil))))))))                          (overlay-put ol 'invisible nil))))))))
118       ;; Close old overlays.       ;; Close old overlays.
119       (dolist (ol old-ols)       (if (not (eq reveal-last-tick
120         (when (and (eq (current-buffer) (overlay-buffer ol))                    (setq reveal-last-tick (buffer-modified-tick))))
121                    (not (rassq ol reveal-open-spots)))           ;; The buffer was modified since last command: let's refrain from
122           (if (and (>= (point) (save-excursion           ;; closing any overlay because it tends to behave poorly when
123                                  (goto-char (overlay-start ol))           ;; inserting text at the end of an overlay (basically the overlay
124                                  (line-beginning-position 1)))           ;; should be rear-advance when it's open, but things like
125                    (<= (point) (save-excursion           ;; outline-minor-mode make it non-rear-advance because it's
126                                  (goto-char (overlay-end ol))           ;; a better choice when it's closed).
127                                  (line-beginning-position 2))))           (dolist (ol old-ols)
128               ;; Still near the overlay: keep it open.             (push (cons (selected-window) ol) reveal-open-spots))
129               (push (cons (selected-window) ol) reveal-open-spots)         ;; The last command was only a point motion or some such
130             ;; Really close it.         ;; non-buffer-modifying command.  Let's close whatever can be closed.
131             (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)         (dolist (ol old-ols)
132               (if (or open           (when (and (eq (current-buffer) (overlay-buffer ol))
133                       (and (setq inv (overlay-get ol 'reveal-invisible))                      (not (rassq ol reveal-open-spots)))
134                            (setq open (or (get inv 'reveal-toggle-invisible)             (if (and (>= (point) (save-excursion
135                                           (overlay-get ol 'isearch-open-invisible-temporary)))))                                    (goto-char (overlay-start ol))
136                   (condition-case err                                    (line-beginning-position 1)))
137                       (funcall open ol t)                      (<= (point) (save-excursion
138                     (error (message "!!Reveal-hide: %s !!" err)))                                    (goto-char (overlay-end ol))
139                 (overlay-put ol 'invisible inv)))))))                                    (line-beginning-position 2))))
140                   ;; Still near the overlay: keep it open.
141                   (push (cons (selected-window) ol) reveal-open-spots)
142                 ;; Really close it.
143                 (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
144                   (if (or open
145                           (and (setq inv (overlay-get ol 'reveal-invisible))
146                                (setq open (or (get inv 'reveal-toggle-invisible)
147                                               (overlay-get ol 'isearch-open-invisible-temporary)))))
148                       (condition-case err
149                           (funcall open ol t)
150                         (error (message "!!Reveal-hide: %s !!" err)))
151                     (overlay-put ol 'invisible inv))))))))
152     (error (message "Reveal: %s" err)))))     (error (message "Reveal: %s" err)))))
153    
154  ;;;###autoload  ;;;###autoload
# Line 171  With zero or negative ARG turn mode off. Line 186  With zero or negative ARG turn mode off.
186    
187  (provide 'reveal)  (provide 'reveal)
188    
189  ;;; arch-tag: 96ba0242-2274-4ed7-8e10-26bc0707b4d8  ;; arch-tag: 96ba0242-2274-4ed7-8e10-26bc0707b4d8
190  ;;; reveal.el ends here  ;;; reveal.el ends here

Legend:
Removed from v.1.10.4.1  
changed lines
  Added in v.1.10.4.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26