aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-11-07 22:33:31 +0000
committerStefan Monnier2005-11-07 22:33:31 +0000
commit4acbd507acdfd90932b3110c20b62b12fa750acb (patch)
treefac283e906aa31e2ff87e14b2a0f2c96f1a261d4
parentb3910238f46c7093304354adea3870dc25afb68f (diff)
downloademacs-4acbd507acdfd90932b3110c20b62b12fa750acb.tar.gz
emacs-4acbd507acdfd90932b3110c20b62b12fa750acb.zip
(reveal-post-command): Rework the handling of
reveal-open-spots, so as to be more reliable. There were several tricky corner cases where an open spot might be lost, or where a closed spot might end up on the list of open spots. Only reveal text that's ellipsised.
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/reveal.el100
2 files changed, 67 insertions, 51 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 12ad61f077d..dabac813087 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,14 @@
12005-11-07 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * reveal.el (reveal-post-command): Rework the handling of
4 reveal-open-spots, so as to be more reliable. There were several
5 tricky corner cases where an open spot might be lost, or where
6 a closed spot might end up on the list of open spots.
7 Only reveal text that's ellipsised.
8
12005-11-07 Carsten Dominik <dominik@science.uva.nl> 92005-11-07 Carsten Dominik <dominik@science.uva.nl>
2 10
3 * textmodes/org.el (org-export-as-html): Removed bogus (debug) form. 11 * textmodes/org.el (org-export-as-html): Remove bogus (debug) form.
4 12
52005-11-06 Richard M. Stallman <rms@gnu.org> 132005-11-06 Richard M. Stallman <rms@gnu.org>
6 14
@@ -19,14 +27,14 @@
19 27
202005-11-07 Masatake YAMATO <jet@gyve.org> 282005-11-07 Masatake YAMATO <jet@gyve.org>
21 29
22 * man.el (Man-reference-regexp): Accpet spaces between 30 * man.el (Man-reference-regexp): Accpet spaces between
23 `Man-name-regexp' and `Man-section-regexp'. 31 `Man-name-regexp' and `Man-section-regexp'.
24 (Man-apropos-regexp): New variable. 32 (Man-apropos-regexp): New variable.
25 (Man-abstract-xref-man-page): Use value for `Man-target-string' 33 (Man-abstract-xref-man-page): Use value for `Man-target-string'
26 if available. 34 if available.
27 (Man-highlight-references, Man-highlight-references0): Handle 35 (Man-highlight-references, Man-highlight-references0):
28 the case when `Man-arguments' includes "-k". 36 Handle the case when `Man-arguments' includes "-k".
29 (Man-highlight-references0): Rename the argument `TARGET-POS' to 37 (Man-highlight-references0): Rename the argument `TARGET-POS' to
30 `TARGET'. `TARGET' can be a number, function or nil. 38 `TARGET'. `TARGET' can be a number, function or nil.
31 39
322005-11-06 Nick Roberts <nickrob@snap.net.nz> 402005-11-06 Nick Roberts <nickrob@snap.net.nz>
diff --git a/lisp/reveal.el b/lisp/reveal.el
index 41b7c4268c2..06f8940eddc 100644
--- a/lisp/reveal.el
+++ b/lisp/reveal.el
@@ -44,11 +44,11 @@
44;;; Todo: 44;;; Todo:
45 45
46;; - find other hysteresis features. 46;; - find other hysteresis features.
47;; - don't hide after a scroll command
48;; - delay hiding by a couple seconds (i.e. hide in the background)
47 49
48;;; Code: 50;;; Code:
49 51
50(require 'pcvs-util)
51
52(defgroup reveal nil 52(defgroup reveal nil
53 "Reveal hidden text on the fly." 53 "Reveal hidden text on the fly."
54 :group 'editing) 54 :group 'editing)
@@ -58,7 +58,9 @@
58 :type 'boolean 58 :type 'boolean
59 :group 'reveal) 59 :group 'reveal)
60 60
61(defvar reveal-open-spots nil) 61(defvar reveal-open-spots nil
62 "List of spots in the buffer which are open.
63Each element has the form (WINDOW . OVERLAY).")
62(make-variable-buffer-local 'reveal-open-spots) 64(make-variable-buffer-local 'reveal-open-spots)
63 65
64(defvar reveal-last-tick nil) 66(defvar reveal-last-tick nil)
@@ -74,35 +76,34 @@
74 ;; FIXME: do we actually know that (current-buffer) = (window-buffer) ? 76 ;; FIXME: do we actually know that (current-buffer) = (window-buffer) ?
75 (with-local-quit 77 (with-local-quit
76 (condition-case err 78 (condition-case err
77 (let* ((spots (cvs-partition 79 (let ((old-ols (delq nil
78 (lambda (x) 80 (mapcar
79 ;; We refresh any spot in the current window as well 81 (lambda (x)
80 ;; as any spots associated with a dead window or a window 82 ;; We refresh any spot in the current window as
81 ;; which does not show this buffer any more. 83 ;; well as any spots associated with a dead
82 (or (eq (car x) (selected-window)) 84 ;; window or a window which does not show this
83 (not (window-live-p (car x))) 85 ;; buffer any more.
84 (not (eq (window-buffer (car x)) 86 (if (or (eq (car x) (selected-window))
85 (current-buffer))))) 87 (not (window-live-p (car x)))
86 reveal-open-spots)) 88 (not (eq (window-buffer (car x))
87 (old-ols (mapcar 'cdr (car spots))) 89 (current-buffer))))
88 (repeat t)) 90 (cdr x)))
89 (setq reveal-open-spots (cdr spots)) 91 reveal-open-spots)))
92 (repeat t))
90 ;; Open new overlays. 93 ;; Open new overlays.
91 (while repeat 94 (while repeat
92 (setq repeat nil) 95 (setq repeat nil)
93 (dolist (ol (nconc (when (and reveal-around-mark mark-active) 96 (dolist (ol (nconc (when (and reveal-around-mark mark-active)
94 (overlays-at (mark))) 97 (overlays-at (mark)))
95 (overlays-at (point)))) 98 (overlays-at (point))))
96 (push (cons (selected-window) ol) reveal-open-spots)
97 (setq old-ols (delq ol old-ols)) 99 (setq old-ols (delq ol old-ols))
98 (let ((inv (overlay-get ol 'invisible)) open) 100 (let ((inv (overlay-get ol 'invisible)) open)
99 (when (and inv 101 (when (and inv
100 ;; There's an `invisible' property. Make sure it's 102 ;; There's an `invisible' property. Make sure it's
101 ;; actually invisible. 103 ;; actually invisible, and ellipsised.
102 (or (not (listp buffer-invisibility-spec)) 104 (and (consp buffer-invisibility-spec)
103 (memq inv buffer-invisibility-spec) 105 (cdr (assq inv buffer-invisibility-spec)))
104 (assq inv buffer-invisibility-spec)) 106 (or (setq open
105 (or (setq open
106 (or (overlay-get ol 'reveal-toggle-invisible) 107 (or (overlay-get ol 'reveal-toggle-invisible)
107 (and (symbolp inv) 108 (and (symbolp inv)
108 (get inv 'reveal-toggle-invisible)) 109 (get inv 'reveal-toggle-invisible))
@@ -111,8 +112,10 @@
111 (and (consp buffer-invisibility-spec) 112 (and (consp buffer-invisibility-spec)
112 (cdr (assq inv buffer-invisibility-spec)))) 113 (cdr (assq inv buffer-invisibility-spec))))
113 (overlay-put ol 'reveal-invisible inv)) 114 (overlay-put ol 'reveal-invisible inv))
115 (push (cons (selected-window) ol) reveal-open-spots)
114 (if (null open) 116 (if (null open)
115 (overlay-put ol 'invisible nil) 117 (progn ;; (debug)
118 (overlay-put ol 'invisible nil))
116 ;; Use the provided opening function and repeat (since the 119 ;; Use the provided opening function and repeat (since the
117 ;; opening function might have hidden a subpart around point). 120 ;; opening function might have hidden a subpart around point).
118 (setq repeat t) 121 (setq repeat t)
@@ -133,32 +136,37 @@
133 ;; should be rear-advance when it's open, but things like 136 ;; should be rear-advance when it's open, but things like
134 ;; outline-minor-mode make it non-rear-advance because it's 137 ;; outline-minor-mode make it non-rear-advance because it's
135 ;; a better choice when it's closed). 138 ;; a better choice when it's closed).
136 (dolist (ol old-ols) 139 nil
137 (push (cons (selected-window) ol) reveal-open-spots))
138 ;; The last command was only a point motion or some such 140 ;; The last command was only a point motion or some such
139 ;; non-buffer-modifying command. Let's close whatever can be closed. 141 ;; non-buffer-modifying command. Let's close whatever can be closed.
140 (dolist (ol old-ols) 142 (dolist (ol old-ols)
141 (when (and (eq (current-buffer) (overlay-buffer ol)) 143 (if (and (>= (point) (save-excursion
142 (not (rassq ol reveal-open-spots))) 144 (goto-char (overlay-start ol))
143 (if (and (>= (point) (save-excursion 145 (line-beginning-position 1)))
144 (goto-char (overlay-start ol)) 146 (<= (point) (save-excursion
145 (line-beginning-position 1))) 147 (goto-char (overlay-end ol))
146 (<= (point) (save-excursion 148 (line-beginning-position 2)))
147 (goto-char (overlay-end ol)) 149 ;; If the application has moved the overlay to some other
148 (line-beginning-position 2)))) 150 ;; buffer, we'd better reset the buffer to its
149 ;; Still near the overlay: keep it open. 151 ;; original state.
150 (push (cons (selected-window) ol) reveal-open-spots) 152 (eq (current-buffer) (overlay-buffer ol)))
151 ;; Really close it. 153 ;; Still near the overlay: keep it open.
152 (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv) 154 nil
153 (if (or open 155 ;; Really close it.
154 (and (setq inv (overlay-get ol 'reveal-invisible)) 156 (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
155 (setq open (or (get inv 'reveal-toggle-invisible) 157 (if (or open
156 (overlay-get ol 'isearch-open-invisible-temporary))))) 158 (and (setq inv (overlay-get ol 'reveal-invisible))
157 (condition-case err 159 (setq open (or (get inv 'reveal-toggle-invisible)
158 (funcall open ol t) 160 (overlay-get ol 'isearch-open-invisible-temporary)))))
159 (error (message "!!Reveal-hide (funcall %s %s t): %s !!" 161 (condition-case err
160 open ol err))) 162 (funcall open ol t)
161 (overlay-put ol 'invisible inv)))))))) 163 (error (message "!!Reveal-hide (funcall %s %s t): %s !!"
164 open ol err)))
165 (overlay-put ol 'invisible inv))
166 ;; Remove the olverlay from the list of open spots.
167 (setq reveal-open-spots
168 (delq (rassoc ol reveal-open-spots)
169 reveal-open-spots)))))))
162 (error (message "Reveal: %s" err))))) 170 (error (message "Reveal: %s" err)))))
163 171
164(defvar reveal-mode-map 172(defvar reveal-mode-map