;;; reveal.el --- Automatically reveal hidden text at point
;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-;; Author: Stefan Monnier <monnier@cs.yale.edu>
+;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: outlines
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(defgroup reveal nil
"Reveal hidden text on the fly."
- :group 'editing)
+ :group 'convenience)
(defcustom reveal-around-mark t
"Reveal text around the mark, if active."
;; a window which does not show this buffer any more.
(cond
((eq (car x) (selected-window)) (cdr x))
- ((not (eq (window-buffer (car x)) (current-buffer)))
+ ((not (and (window-live-p (car x))
+ (eq (window-buffer (car x)) (current-buffer))))
;; Adopt this since it's owned by a window that's
;; either not live or at least not showing this
;; buffer any more.
(overlays-at (mark)))
(overlays-at (point))))
(setq old-ols (delq ol old-ols))
- (let ((inv (overlay-get ol 'invisible)) open)
- (when (and inv
- ;; There's an `invisible' property. Make sure it's
- ;; actually invisible, and ellipsised.
- (and (consp buffer-invisibility-spec)
- (cdr (assq inv buffer-invisibility-spec)))
- (or (setq open
- (or (overlay-get ol 'reveal-toggle-invisible)
- (and (symbolp inv)
- (get inv 'reveal-toggle-invisible))
- (overlay-get ol 'isearch-open-invisible-temporary)))
- (overlay-get ol 'isearch-open-invisible)
- (and (consp buffer-invisibility-spec)
- (cdr (assq inv buffer-invisibility-spec))))
- (overlay-put ol 'reveal-invisible inv))
- (push (cons (selected-window) ol) reveal-open-spots)
- (if (null open)
- (overlay-put ol 'invisible nil)
- ;; Use the provided opening function and repeat (since the
- ;; opening function might have hidden a subpart around point).
- (setq repeat t)
- (condition-case err
- (funcall open ol nil)
- (error (message "!!Reveal-show (funcall %s %s nil): %s !!"
- open ol err)
- ;; Let's default to a meaningful behavior to avoid
- ;; getting stuck in an infinite loop.
- (setq repeat nil)
- (overlay-put ol 'invisible nil)))))))))
+ (when (overlay-start ol) ;Check it's still live.
+ (let ((inv (overlay-get ol 'invisible)) open)
+ (when (and inv
+ ;; There's an `invisible' property. Make sure it's
+ ;; actually invisible, and ellipsised.
+ (and (consp buffer-invisibility-spec)
+ (cdr (assq inv buffer-invisibility-spec)))
+ (or (setq open
+ (or (overlay-get ol 'reveal-toggle-invisible)
+ (and (symbolp inv)
+ (get inv 'reveal-toggle-invisible))
+ (overlay-get ol 'isearch-open-invisible-temporary)))
+ (overlay-get ol 'isearch-open-invisible)
+ (and (consp buffer-invisibility-spec)
+ (cdr (assq inv buffer-invisibility-spec))))
+ (overlay-put ol 'reveal-invisible inv))
+ (push (cons (selected-window) ol) reveal-open-spots)
+ (if (null open)
+ (overlay-put ol 'invisible nil)
+ ;; Use the provided opening function and repeat (since the
+ ;; opening function might have hidden a subpart around point
+ ;; or moved/killed some of the overlays).
+ (setq repeat t)
+ (condition-case err
+ (funcall open ol nil)
+ (error (message "!!Reveal-show (funcall %s %s nil): %s !!"
+ open ol err)
+ ;; Let's default to a meaningful behavior to avoid
+ ;; getting stuck in an infinite loop.
+ (setq repeat nil)
+ (overlay-put ol 'invisible nil))))))))))
old-ols)
(defun reveal-close-old-overlays (old-ols)