all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-pretest-bug@gnu.org
Subject: Re: 23.0.60; isearch for M-: incorrect in Info
Date: Mon, 21 Apr 2008 02:54:15 +0300	[thread overview]
Message-ID: <87prskummg.fsf@jurta.org> (raw)
In-Reply-To: <jwvtzhx2qid.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 19 Apr 2008 22:48:36 -0400")

>> + (defvar isearch-success-function nil
> [...]
>> ! 		  (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))))))
>
> Better just call isearch-success-function unconditionally and move the
> default code to the default value of isearch-success-function.
>
> I understand that may require many more changes to your code, tho, but
> I think it's important to always make when you introduce such
> a foo-function variable to make sure that it is possible to reproduce
> the default value (since it's often desirable to do almost the same as
> the default).

I can't invent a good name for the default function that describes exactly
what it does, so I named it simply `isearch-success-function-default'.
I've seen this naming convention in other places too.

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.316
diff -c -r1.316 isearch.el
*** lisp/isearch.el	18 Apr 2008 10:29:23 -0000	1.316
--- lisp/isearch.el	20 Apr 2008 23:51:28 -0000
***************
*** 178,183 ****
--- 178,188 ----
    "Function to save a function restoring the mode-specific isearch state
  to the search status stack.")
  
+ (defvar isearch-success-function 'isearch-success-function-default
+   "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
***************
*** 2104,2110 ****
        (setq isearch-case-fold-search
  	    (isearch-no-upper-case-p isearch-string isearch-regexp)))
    (condition-case lossage
!       (let ((inhibit-point-motion-hooks search-invisible)
  	    (inhibit-quit nil)
  	    (case-fold-search isearch-case-fold-search)
  	    (search-spaces-regexp search-whitespace-regexp)
--- 2174,2182 ----
        (setq isearch-case-fold-search
  	    (isearch-no-upper-case-p isearch-string isearch-regexp)))
    (condition-case lossage
!       (let ((inhibit-point-motion-hooks
! 	     (and (eq isearch-success-function 'isearch-success-function-default)
! 		  search-invisible))
  	    (inhibit-quit nil)
  	    (case-fold-search isearch-case-fold-search)
  	    (search-spaces-regexp search-whitespace-regexp)
***************
*** 2115,2126 ****
  		(isearch-search-string 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)
  		  (bobp) (eobp)
  		  (= (match-beginning 0) (match-end 0))
! 		  (not (isearch-range-invisible
! 			(match-beginning 0) (match-end 0))))
  	      (setq retry nil)))
  	(setq isearch-just-started nil)
  	(if isearch-success
--- 2187,2197 ----
  		(isearch-search-string isearch-string nil t))
  	  ;; Clear RETRY unless we matched some invisible text
  	  ;; and we aren't supposed to do that.
! 	  (if (or (not isearch-success)
  		  (bobp) (eobp)
  		  (= (match-beginning 0) (match-end 0))
! 		  (funcall isearch-success-function
! 			   (match-beginning 0) (match-end 0)))
  	      (setq retry nil)))
  	(setq isearch-just-started nil)
  	(if isearch-success
***************
*** 2298,2303 ****
--- 2369,2381 ----
  		  nil)
  	      (setq isearch-hidden t)))))))
  
+ (defun isearch-success-function-default (beg end)
+   "Default function to report if the new search match is successful.
+ Returns t if search can match hidden text, or otherwise checks if some
+ text from BEG to END is visible."
+   (or (eq search-invisible t)
+       (not (isearch-range-invisible beg end))))
+ 
  \f
  ;; General utilities
  
-- 
Juri Linkov
http://www.jurta.org/emacs/




  reply	other threads:[~2008-04-20 23:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14  0:16 23.0.60; isearch for M-: incorrect in Info Drew Adams
2008-04-15 22:29 ` Juri Linkov
2008-04-15 23:27   ` Drew Adams
2008-04-17 23:14     ` Juri Linkov
2008-04-18 20:21       ` Stefan Monnier
2008-04-19 22:48         ` Juri Linkov
2008-04-20  2:48           ` Stefan Monnier
2008-04-20 23:54             ` Juri Linkov [this message]
2008-04-21  1:05               ` Stefan Monnier

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=87prskummg.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.