help-gnu-emacs
[Top][All Lists]
Advanced

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

Teach isearch to open invisible only if visible search failed?


From: Leo
Subject: Teach isearch to open invisible only if visible search failed?
Date: Sun, 05 Dec 2010 06:41:40 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.90 (Mac OS X 10.6.5)

Hello all Emacsen,

I use C-s/r for navigating around text a lot and I have found it slows
me down in large text shown in outline structure in outline or org mode
etc. So I wonder how to set up isearch so that it only opens invisible
text when search in the visible fails.

My attempt is like this but it doesn't work as smoothly as I'd like.

(setq search-invisible nil)
(add-hook 'isearch-update-post-hook
          (lambda () (when (and (or (not isearch-success)
                                    isearch-error)
                                ;; prevent infinite loop
                                (not (eq search-invisible 'open)))
                       (setq search-invisible 'open)
                       (isearch-search)
                       (isearch-update))))
(add-hook 'isearch-mode-end-hook
          (lambda () (setq search-invisible nil)))

I wonder if someone familiar with isearch can propose a better setup.
Thanks in advance.

Leo




reply via email to

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