From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#1352: 23.0.60; isearch-success-function Date: Sun, 16 Nov 2008 23:16:17 +0200 Organization: JURTA Message-ID: <87fxlrid7i.fsf@jurta.org> References: <005c01c9477b$6adb8290$0200a8c0@us.oracle.com> Reply-To: Juri Linkov , 1352@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1226871064 9997 80.91.229.12 (16 Nov 2008 21:31:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Nov 2008 21:31:04 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, 1352@emacsbugs.donarmstrong.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 16 22:32:05 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L1pDu-0005Ws-T3 for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Nov 2008 22:32:04 +0100 Original-Received: from localhost ([127.0.0.1]:46827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1pCm-0002qU-Cn for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Nov 2008 16:30:52 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L1pCC-0002dZ-N6 for bug-gnu-emacs@gnu.org; Sun, 16 Nov 2008 16:30:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L1pCA-0002cK-FZ for bug-gnu-emacs@gnu.org; Sun, 16 Nov 2008 16:30:16 -0500 Original-Received: from [199.232.76.173] (port=42912 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L1pCA-0002cF-AC for bug-gnu-emacs@gnu.org; Sun, 16 Nov 2008 16:30:14 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:33897) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L1pC9-0005zS-HC for bug-gnu-emacs@gnu.org; Sun, 16 Nov 2008 16:30:14 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mAGLU8Y5032200; Sun, 16 Nov 2008 13:30:08 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id mAGLP4Gp030611; Sun, 16 Nov 2008 13:25:04 -0800 X-Loop: don@donarmstrong.com Resent-From: Juri Linkov Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sun, 16 Nov 2008 21:25:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1352 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1352-submit@emacsbugs.donarmstrong.com id=B1352.122687034829144 (code B ref 1352); Sun, 16 Nov 2008 21:25:04 +0000 Original-Received: (at 1352) by emacsbugs.donarmstrong.com; 16 Nov 2008 21:19:08 +0000 Original-Received: from relay03.kiev.sovam.com (relay03.kiev.sovam.com [62.64.120.201]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mAGLJ3VX029138 for <1352@emacsbugs.donarmstrong.com>; Sun, 16 Nov 2008 13:19:05 -0800 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1L1p1J-00048w-OH; Sun, 16 Nov 2008 23:19:02 +0200 In-Reply-To: (Stefan Monnier's message of "Sat, 15 Nov 2008 20:10:46 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: 4a7b5a5b2e932d77e907085f616b0add X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 5467 [Oct 22 2008] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: white ip list X-SpamTest-Rate: 10 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sun, 16 Nov 2008 16:30:16 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:22419 gmane.emacs.pretest.bugs:23360 Archived-At: >> The name of `isearch-success-function' seems wrong, if we believe the >> doc string. The doc string suggests that it is a predicate that >> filters the search hits that would otherwise be available. That's very >> general. If that's true, then the name should reflect this meaning - >> perhaps `isearch-predicate'. > > Actually, based on your description, I'd name it `isearch-filter-predicate'. The name `isearch-success-function' was created to be consistent with other *-function variables and with `isearch-success', but I agree that more clear names are better. So the patch below renames it to `isearch-filter-predicate' and also renames `isearch-success-function-default' to `isearch-filter-invisible', plus renames in Dired and Info, and doc fixes: Index: lisp/isearch.el =================================================================== RCS file: /sources/emacs/emacs/lisp/isearch.el,v retrieving revision 1.335 diff -c -r1.335 isearch.el *** lisp/isearch.el 11 Nov 2008 20:11:34 -0000 1.335 --- lisp/isearch.el 16 Nov 2008 21:07:27 -0000 *************** *** 176,186 **** "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 the search. If this function returns nil, continue ! searching without stopping at this match.") ;; Search ring. --- 176,187 ---- "Function to save a function restoring the mode-specific isearch state to the search status stack.") ! (defvar isearch-filter-predicate 'isearch-filter-invisible ! "Predicate that filters the search hits that would normally be available. ! Search hits that dissatisfy the predicate are skipped. The function ! has two arguments: the positions of start and end of text matched by ! the search. If this function returns nil, continue searching without ! stopping at this match.") ;; Search ring. *************** *** 2257,2263 **** (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) --- 2258,2264 ---- (isearch-no-upper-case-p isearch-string isearch-regexp))) (condition-case lossage (let ((inhibit-point-motion-hooks ! (and (eq isearch-filter-predicate 'isearch-filter-invisible) search-invisible)) (inhibit-quit nil) (case-fold-search isearch-case-fold-search) *************** *** 2267,2278 **** (while retry (setq isearch-success (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) --- 2268,2279 ---- (while retry (setq isearch-success (isearch-search-string isearch-string nil t)) ! ;; Clear RETRY unless the search predicate says ! ;; to skip this search hit. (if (or (not isearch-success) (bobp) (eobp) (= (match-beginning 0) (match-end 0)) ! (funcall isearch-filter-predicate (match-beginning 0) (match-end 0))) (setq retry nil))) (setq isearch-just-started nil) *************** *** 2451,2460 **** 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)))) --- 2452,2461 ---- nil) (setq isearch-hidden t))))))) ! (defun isearch-filter-invisible (beg end) ! "Default predicate to filter out invisible text. ! It filters search hits to those that are visible (at least partially), ! unless invisible text too can be searched." (or (eq search-invisible t) (not (isearch-range-invisible beg end)))) *************** *** 2640,2651 **** (if isearch-lazy-highlight-wrapped isearch-lazy-highlight-end (window-start)))))) ! ;; Use a loop like in `isearch-search' (while retry (setq success (isearch-search-string isearch-lazy-highlight-last-string bound t)) (if (or (not success) ! (funcall isearch-success-function (match-beginning 0) (match-end 0))) (setq retry nil))) success) --- 2642,2655 ---- (if isearch-lazy-highlight-wrapped isearch-lazy-highlight-end (window-start)))))) ! ;; Use a loop like in `isearch-search'. (while retry (setq success (isearch-search-string isearch-lazy-highlight-last-string bound t)) + ;; Clear RETRY unless the search predicate says + ;; to skip this search hit. (if (or (not success) ! (funcall isearch-filter-predicate (match-beginning 0) (match-end 0))) (setq retry nil))) success) Index: lisp/dired-aux.el =================================================================== RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v retrieving revision 1.181 diff -c -r1.181 dired-aux.el *** lisp/dired-aux.el 11 Nov 2008 20:12:44 -0000 1.181 --- lisp/dired-aux.el 16 Nov 2008 21:12:49 -0000 *************** *** 2303,2328 **** :group 'dired :version "23.1") ! (defvar dired-isearch-orig-success-function nil) (defun dired-isearch-filenames-toggle () "Toggle file names searching on or off. ! When on, Isearch checks the success of the current matching point ! using the function `dired-isearch-success-function' that matches only ! at file names. When off, it uses the default function ! `isearch-success-function-default'." (interactive) ! (setq isearch-success-function ! (if (eq isearch-success-function 'dired-isearch-success-function) ! 'isearch-success-function-default ! 'dired-isearch-success-function)) (setq isearch-success t isearch-adjusted t) (isearch-update)) --- 2303,2328 ---- :group 'dired :version "23.1") ! (defvar dired-isearch-filter-predicate-orig nil) (defun dired-isearch-filenames-toggle () "Toggle file names searching on or off. ! When on, Isearch skips matches outside file names using the predicate ! `dired-isearch-filter-filenames' that matches only at file names. ! When off, it uses the default predicate `isearch-filter-invisible'." (interactive) ! (setq isearch-filter-predicate ! (if (eq isearch-filter-predicate 'dired-isearch-filter-filenames) ! 'isearch-filter-invisible ! 'dired-isearch-filter-filenames)) (setq isearch-success t isearch-adjusted t) (isearch-update)) *************** *** 2330,2351 **** (defun dired-isearch-filenames-setup () "Set up isearch to search in Dired file names. Intended to be added to `isearch-mode-hook'." ! (when dired-isearch-filenames (define-key isearch-mode-map "\M-sf" 'dired-isearch-filenames-toggle) ! (setq dired-isearch-orig-success-function ! (default-value 'isearch-success-function)) ! (setq-default isearch-success-function 'dired-isearch-success-function) (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t))) (defun dired-isearch-filenames-end () "Clean up the Dired file name search after terminating isearch." (define-key isearch-mode-map "\M-sf" nil) ! (setq-default isearch-success-function dired-isearch-orig-success-function) (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)) ! (defun dired-isearch-success-function (beg end) "Match only at visible regions with the text property `dired-filename'." ! (and (isearch-success-function-default beg end) (if dired-isearch-filenames (text-property-not-all (min beg end) (max beg end) 'dired-filename nil) --- 2330,2355 ---- (defun dired-isearch-filenames-setup () "Set up isearch to search in Dired file names. Intended to be added to `isearch-mode-hook'." ! (when (or (eq dired-isearch-filenames 'dired-filename) (define-key isearch-mode-map "\M-sf" 'dired-isearch-filenames-toggle) ! (setq dired-isearch-filter-predicate-orig ! (default-value 'isearch-filter-predicate)) ! (setq-default isearch-filter-predicate 'dired-isearch-filter-filenames) (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t))) (defun dired-isearch-filenames-end () "Clean up the Dired file name search after terminating isearch." (define-key isearch-mode-map "\M-sf" nil) ! (setq-default isearch-filter-predicate dired-isearch-filter-predicate-orig) (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)) ! (defun dired-isearch-filter-filenames (beg end) "Match only at visible regions with the text property `dired-filename'." ! (and (isearch-filter-invisible beg end) (if dired-isearch-filenames (text-property-not-all (min beg end) (max beg end) 'dired-filename nil) Index: lisp/info.el =================================================================== RCS file: /sources/emacs/emacs/lisp/info.el,v retrieving revision 1.551 diff -u -r1.551 info.el --- lisp/info.el 20 Oct 2008 02:23:01 -0000 1.551 +++ lisp/info.el 16 Nov 2008 21:10:12 -0000 @@ -1660,7 +1660,7 @@ (point-max))) (while (and (not give-up) (or (null found) - (not (funcall isearch-success-function beg-found found)))) + (not (funcall isearch-filter-predicate beg-found found)))) (let ((search-spaces-regexp (if (or (not isearch-mode) isearch-regexp) Info-search-whitespace-regexp))) @@ -1740,7 +1740,7 @@ (setq give-up nil found nil) (while (and (not give-up) (or (null found) - (not (funcall isearch-success-function beg-found found)))) + (not (funcall isearch-filter-predicate beg-found found)))) (let ((search-spaces-regexp (if (or (not isearch-mode) isearch-regexp) Info-search-whitespace-regexp))) @@ -1847,7 +1847,7 @@ (defun Info-isearch-start () (setq Info-isearch-initial-node nil)) -(defun Info-search-success-function (beg-found found) +(defun Info-isearch-filter-predicate (beg-found found) "Skip invisible text, node header line and Tag Table node." (save-match-data (let ((backward (< found beg-found))) @@ -3533,8 +3533,8 @@ 'Info-isearch-wrap) (set (make-local-variable 'isearch-push-state-function) 'Info-isearch-push-state) - (set (make-local-variable 'isearch-success-function) - 'Info-search-success-function) + (set (make-local-variable 'isearch-filter-predicate) + 'Info-isearch-filter-predicate) (set (make-local-variable 'search-whitespace-regexp) Info-search-whitespace-regexp) (set (make-local-variable 'revert-buffer-function) -- Juri Linkov http://www.jurta.org/emacs/