emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to control isearch for invisible text


From: David Kastrup
Subject: Re: how to control isearch for invisible text
Date: Sun, 13 Aug 2006 09:14:46 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> - documenting `isearch-invisible' in the Emacs manual?
>> - and the Elisp manual?
>> - creating a toggle for it?
>> - having `occur' and `query-replace' respect the option?
>
> I think `occur' always makes things visible because it copies text
> and overlays are not copied along, so the invisibility gets lost.  I
> do think query-replace should be improved to open invisible text
> just like isearch does.

For what it's worth, preview-latex contains the following code:

(defadvice replace-highlight (before preview)
  "Make `query-replace' open preview text about to be replaced."
  (preview-open-overlays
   (overlays-in (ad-get-arg 0) (ad-get-arg 1))))

(defcustom preview-query-replace-reveal t
  "*Make `query-replace' autoreveal previews."
  :group 'preview-appearance
  :type 'boolean
  :require 'preview
  :set (lambda (symbol value)
         (set-default symbol value)
         (if value
             (ad-enable-advice 'replace-highlight 'before 'preview)
           (ad-disable-advice 'replace-highlight 'before 'preview))
         (ad-activate 'replace-highlight))
  :initialize #'custom-initialize-reset)

Text opened by preview-open-overlays gets closed again when
post-command-hook finds it has left the region.


It turns out that for XEmacs we do things differently for some reason:
probably it does not have the invisible open properties.  There we
have

(defun preview-open-overlay (ovr ignored)
  "Open the active preview OVR, IGNORED gets ignored.
NIL is returned: this is for `map-extents'."
  (preview-toggle ovr)
  (push ovr preview-temporary-opened)
  nil)

(defadvice isearch-highlight (before preview protect disable)
  "Make isearch open preview text that's a search hit.
Also make `query-replace' open preview text about to be replaced."
  (map-extents #'preview-open-overlay nil
               (ad-get-arg 0) (ad-get-arg 1)
               nil nil 'preview-state 'active))


I remember it took quite a long time to find this least invasive place
for the advice, so it is likely that the call places of
replace-highlight might be the best location for implementing this
functionality within Emacs.

Bonus points if it does not clash with preview-latex's current
implementation...

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

[Prev in Thread] Current Thread [Next in Thread]