From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: Type Ahead Find
Date: Sun, 20 Mar 2005 22:19:48 +0200 [thread overview]
Message-ID: <87u0n6xenn.fsf@jurta.org> (raw)
In-Reply-To: <E1DCoCp-0006Qf-2Y@fencepost.gnu.org> (Richard Stallman's message of "Sat, 19 Mar 2005 19:22:11 -0500")
Richard Stallman <rms@gnu.org> writes:
> But it allows to narrow the search only
> to specific text part (such as e.g. in Firefox typing a ' before the
> search string searches only links) which is currently not easily
> implementable in Emacs.
>
> Making such a feature useful, and not intolerable, in the context
> of Emacs is not a simple matter. I think I'd rather turn off any
> feature that makes some printing characters special in isearch.
The change I proposed has nothing to do with making some characters
special in isearch.
> Please let's not think about this now. If you'd like to work
> on new features for after the release, how about implementing
> some of the features listed in etc/TODO?
This is not a new feature. This is the change very closely related
to other recent fixes in isearch.el. I want to finish all fixes
related to isearch.el before the next release.
Essentially, my proposed change is to make configurable the
currently hard-coded constraint imposed by `isearch-range-invisible'
in `isearch-search'. The new variable `isearch-success-function'
will allow to override it with a user-defined function.
Also in the course of preparing this change I noticed some problems
in isearch.el related to searching of invisible text:
The lazy highlighting feature creates overlays even for matches inside
invisible texts. A solution is to create a loop similar to the while-loop
in `isearch-search', but instead of `isearch-range-invisible' (which also
opens invisible overlays) to use the following condition in
`isearch-lazy-highlight-search':
(text-property-any (match-beginning 0) (match-end 0)
'invisible nil)
This condition seems to be more correct even if it lazy-highlights
partly hidden matches. An alternative condition
(not (text-property-not-all (match-beginning 0) (match-end 0)
'invisible nil))
that lazy-highlights a match only if it is fully visible, doesn't
follow the logic of `isearch-range-invisible' used in `isearch-search'
which matches partly invisible text.
The current version of a patch is below:
Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.261
diff -u -w -b -r1.261 isearch.el
--- lisp/isearch.el 18 Mar 2005 09:59:31 -0000 1.261
+++ lisp/isearch.el 20 Mar 2005 20:03:07 -0000
@@ -165,6 +165,11 @@
"Function to save a function restoring the mode-specific isearch state
to the search status stack.")
+(defvar isearch-success-function nil
+ "Function to report whether the new search match is considered successful.
+The function has two arguments: the positions of start and end of text
+matched by search.")
+
;; Search ring.
(defvar search-ring nil
@@ -2039,7 +2046,8 @@
(setq isearch-case-fold-search
(isearch-no-upper-case-p isearch-string isearch-regexp)))
(condition-case lossage
- (let ((inhibit-point-motion-hooks search-invisible)
+ (let ((inhibit-point-motion-hooks
+ (and (not isearch-success-function) search-invisible))
(inhibit-quit nil)
(case-fold-search isearch-case-fold-search)
(search-spaces-regexp search-whitespace-regexp)
@@ -2052,12 +2060,15 @@
isearch-string nil t))
;; Clear RETRY unless we matched some invisible text
;; and we aren't supposed to do that.
- (if (or (eq search-invisible t)
- (not isearch-success)
+ (if (or (not isearch-success)
(bobp) (eobp)
(= (match-beginning 0) (match-end 0))
+ (if isearch-success-function
+ (funcall isearch-success-function
+ (match-beginning 0) (match-end 0))
+ (or (eq search-invisible t)
(not (isearch-range-invisible
- (match-beginning 0) (match-end 0))))
+ (match-beginning 0) (match-end 0))))))
(setq retry nil)))
(setq isearch-just-started nil)
(if isearch-success
@@ -2369,7 +2381,6 @@
isearch-lazy-highlight-window-end))))
;; something important did indeed change
(lazy-highlight-cleanup t) ;kill old loop & remove overlays
- (when (not isearch-error)
(setq isearch-lazy-highlight-start-limit beg
isearch-lazy-highlight-end-limit end)
(setq isearch-lazy-highlight-window (selected-window)
@@ -2384,7 +2395,7 @@
(unless (equal isearch-string "")
(setq isearch-lazy-highlight-timer
(run-with-idle-timer lazy-highlight-initial-delay nil
- 'isearch-lazy-highlight-update))))))
+ 'isearch-lazy-highlight-update)))))
(defun isearch-lazy-highlight-search ()
"Search ahead for the next or previous match, for lazy highlighting.
@@ -2393,9 +2404,9 @@
(isearch-regexp isearch-lazy-highlight-regexp)
(search-spaces-regexp search-whitespace-regexp))
(condition-case nil
- (funcall (isearch-search-fun)
- isearch-lazy-highlight-last-string
- (if isearch-forward
+ (let ((retry t)
+ (success nil)
+ (bound (if isearch-forward
(min (or isearch-lazy-highlight-end-limit (point-max))
(if isearch-lazy-highlight-wrapped
isearch-lazy-highlight-start
@@ -2403,8 +2414,22 @@
(max (or isearch-lazy-highlight-start-limit (point-min))
(if isearch-lazy-highlight-wrapped
isearch-lazy-highlight-end
- (window-start))))
- t)
+ (window-start))))))
+ (while retry
+ (setq success
+ (funcall (isearch-search-fun)
+ isearch-lazy-highlight-last-string
+ bound t))
+ (if (or (not success)
+ (eq (point) bound)
+ (if isearch-success-function
+ (funcall isearch-success-function
+ (match-beginning 0) (match-end 0))
+ (text-property-any
+ (match-beginning 0) (match-end 0)
+ 'invisible nil)))
+ (setq retry nil)))
+ success)
(error nil))))
(defun isearch-lazy-highlight-update ()
--
Juri Linkov
http://www.jurta.org/emacs/
prev parent reply other threads:[~2005-03-20 20:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-18 19:45 Type Ahead Find Juri Linkov
2005-03-18 20:21 ` Drew Adams
2005-03-18 21:53 ` Stefan Monnier
2005-03-19 12:29 ` Juri Linkov
2005-03-19 21:19 ` Miles Bader
2005-03-19 22:09 ` David Kastrup
2005-03-19 23:33 ` Miles Bader
2005-03-20 20:17 ` Juri Linkov
2005-03-20 21:46 ` David Kastrup
2005-03-20 22:04 ` Miles Bader
2005-03-21 19:28 ` Juri Linkov
2005-03-20 20:14 ` Juri Linkov
2005-03-20 20:22 ` Juri Linkov
2005-03-20 0:22 ` Richard Stallman
2005-03-20 20:19 ` Juri Linkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87u0n6xenn.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.