From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#14013: 24.3.50; dired-isearch-filenames-regexp is matching text outside filenames Date: Fri, 22 Mar 2013 01:03:31 +0200 Organization: JURTA Message-ID: <87vc8ke4os.fsf@mail.jurta.org> References: <87li9hk5e5.fsf@web.de> <87wqt1vd0o.fsf@mail.jurta.org> <87d2ut4mji.fsf@web.de> <87620lvavl.fsf@mail.jurta.org> <87zjxxsd6c.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363907303 11482 80.91.229.3 (21 Mar 2013 23:08:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2013 23:08:23 +0000 (UTC) Cc: 14013@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 22 00:08:49 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UIobH-00047b-J0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Mar 2013 00:08:47 +0100 Original-Received: from localhost ([::1]:41409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIoau-0005xm-2h for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Mar 2013 19:08:24 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIoak-0005ua-R5 for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 19:08:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIoaf-0004aB-Rc for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 19:08:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIoaf-0004a7-O1 for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 19:08:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UIocU-0001Mz-4k for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 19:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Mar 2013 23:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14013 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14013-submit@debbugs.gnu.org id=B14013.13639073725222 (code B ref 14013); Thu, 21 Mar 2013 23:10:02 +0000 Original-Received: (at 14013) by debbugs.gnu.org; 21 Mar 2013 23:09:32 +0000 Original-Received: from localhost ([127.0.0.1]:39487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIoc0-0001MB-DC for submit@debbugs.gnu.org; Thu, 21 Mar 2013 19:09:32 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:50244 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIoby-0001M3-Dg for 14013@debbugs.gnu.org; Thu, 21 Mar 2013 19:09:31 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id CF732258B92960; Thu, 21 Mar 2013 16:07:35 -0700 (PDT) In-Reply-To: <87zjxxsd6c.fsf@web.de> (Michael Heerdegen's message of "Thu, 21 Mar 2013 03:24:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72771 Archived-At: > Would it be an appropriate approach to use a more sophisticated value > for `isearch-search-fun-function' for that case? This function could > e.g. jump to the next filename before starting searching. Instead of duplicating the complex logic of `isearch-search-fun-function' in a new specialized function it would be better to implement this using hooks. We have already a post-processing hook `isearch-update-post-hook' invoked after isearch has found matches. So we need a similar hook invoked before isearch starts searching matches, with a name like `isearch-search-fun-pre-hook'. It fixes your test case of searching for ".*": === modified file 'lisp/isearch.el' --- lisp/isearch.el 2013-02-25 21:10:59 +0000 +++ lisp/isearch.el 2013-03-21 22:53:41 +0000 @@ -163,6 +163,9 @@ (defcustom isearch-resume-in-command-his (defvar isearch-mode-hook nil "Function(s) to call after starting up an incremental search.") +(defvar isearch-search-fun-pre-hook nil + "Function(s) to call before isearch starts searching matches in the buffer.") + (defvar isearch-update-post-hook nil "Function(s) to call after isearch has found matches in the buffer.") @@ -2651,7 +2654,9 @@ (defun isearch-search-string (string bou If found, move point to the end of the occurrence, update the match data, and return point." (let* ((func (isearch-search-fun)) - (pos1 (save-excursion (funcall func string bound noerror))) + (pos1 (save-excursion + (run-hooks 'isearch-search-fun-pre-hook) + (funcall func string bound noerror))) pos2) (when (and ;; Avoid "obsolete" warnings for translation-table-for-input. === modified file 'lisp/dired-aux.el' --- lisp/dired-aux.el 2013-02-28 21:51:11 +0000 +++ lisp/dired-aux.el 2013-03-21 22:54:14 +0000 @@ -2506,6 +2506,12 @@ (defun dired-isearch-filenames-toggle () (setq isearch-success t isearch-adjusted t) (isearch-update)) +(defun dired-isearch-filenames-pre-hook () + (unless (get-text-property (point) 'dired-filename) + (if isearch-forward + (goto-char (or (next-single-property-change (point) 'dired-filename) (point-max))) + (goto-char (or (previous-single-property-change (point) 'dired-filename) (point-min)))))) + ;;;###autoload (defun dired-isearch-filenames-setup () "Set up isearch to search in Dired file names. @@ -2518,14 +2524,16 @@ (defun dired-isearch-filenames-setup () (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))) + (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t) + (add-hook 'isearch-search-fun-pre-hook 'dired-isearch-filenames-pre-hook nil t))) (defun dired-isearch-filenames-end () "Clean up the Dired file name search after terminating isearch." (setq isearch-message-prefix-add nil) (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)) + (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t) + (remove-hook 'isearch-search-fun-pre-hook 'dired-isearch-filenames-pre-hook t)) (defun dired-isearch-filter-filenames (beg end) "Test whether the current search hit is a visible file name. === modified file 'lisp/wdired.el' --- lisp/wdired.el 2013-03-05 17:13:01 +0000 +++ lisp/wdired.el 2013-03-21 22:55:11 +0000 @@ -241,6 +241,7 @@ (defun wdired-change-to-wdired-mode () (set (make-local-variable 'query-replace-skip-read-only) t) (set (make-local-variable 'isearch-filter-predicate) 'wdired-isearch-filter-read-only) + (add-hook 'isearch-search-fun-pre-hook 'dired-isearch-filenames-pre-hook nil t) (use-local-map wdired-mode-map) (force-mode-line-update) (setq buffer-read-only nil) Also (run-hooks 'isearch-search-fun-pre-hook) should be added to replace.el, but first I have to install the pending patches in bug#11378 and bug#11746.