]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/isearch.el (isearch-filter-predicates): Rename from `isearch-filter-predicate'.
authorJuri Linkov <juri@jurta.org>
Mon, 27 May 2013 22:42:11 +0000 (01:42 +0300)
committerJuri Linkov <juri@jurta.org>
Mon, 27 May 2013 22:42:11 +0000 (01:42 +0300)
Doc fix.
(isearch-message-prefix): Display text from the property
`isearch-message-prefix' of the currently active filters.
(isearch-search): Don't compare `isearch-filter-predicate' with
`isearch-filter-visible'.  Call `run-hook-with-args-until-failure'
on `isearch-filter-predicates'.  Also check `search-invisible' for t
or call `isearch-range-invisible'.
(isearch-filter-visible): Make obsolete.
(isearch-lazy-highlight-search):
Call `run-hook-with-args-until-failure' on
`isearch-filter-predicates' and use `isearch-range-invisible'.

* lisp/info.el (Info-search): Call `run-hook-with-args-until-failure' on
`isearch-filter-predicates' instead of `funcall'ing
`isearch-filter-predicate'.
(Info-mode): Set `Info-isearch-filter' to
`isearch-filter-predicates' instead of `isearch-filter-predicate'.

* lisp/dired-aux.el (dired-isearch-filter-predicate-orig): Remove variable.
(dired-isearch-filenames-toggle, dired-isearch-filenames-setup)
(dired-isearch-filenames-end): Add and remove
`dired-isearch-filter-filenames' in `isearch-filter-predicates'
instead of changing the value of `isearch-filter-predicate'.
Rebind `dired-isearch-filenames-toggle' from "\M-sf" to "\M-sff".
(dired-isearch-filter-filenames): Don't use `isearch-filter-visible'.
Put property `isearch-message-prefix' to "filename " on
`dired-isearch-filter-filenames'.

* lisp/wdired.el (wdired-change-to-wdired-mode):
Add `isearch-filter-predicates' to `wdired-isearch-filter-read-only'
locally instead of changing `isearch-filter-predicate'.
(wdired-isearch-filter-read-only): Don't use `isearch-filter-visible'.

Fixes: debbugs:11378
etc/NEWS
lisp/ChangeLog
lisp/dired-aux.el
lisp/dired.el
lisp/info.el
lisp/isearch.el
lisp/wdired.el

index 2fe3ba79d4f22ce3852c604b810b0866ee1201d7..fbb32326dacb2be82dec82c57d5100806c11fc83 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -384,6 +384,8 @@ file using `set-file-extended-attributes'.
 *** `lisp-complete-symbol'
 *** `field-complete'
 *** `minibuffer-completion-contents'
+*** `isearch-nonincremental-exit-minibuffer'
+*** `isearch-filter-visible'
 
 ** `with-wrapper-hook' is obsoleted by `add-function'.
 The few hooks that used with-wrapper-hook are replaced as follows:
index 509c940a8f469852dd585f58f696b464284053fd..486e5d75343d5b69e57d1badd15355a771ede1ac 100644 (file)
@@ -1,3 +1,40 @@
+2013-05-27  Juri Linkov  <juri@jurta.org>
+
+       * isearch.el (isearch-filter-predicates): Rename from
+       `isearch-filter-predicate'.  Doc fix.  (Bug#11378)
+       (isearch-message-prefix): Display text from the property
+       `isearch-message-prefix' of the currently active filters.
+       (isearch-search): Don't compare `isearch-filter-predicate' with
+       `isearch-filter-visible'.  Call `run-hook-with-args-until-failure'
+       on `isearch-filter-predicates'.  Also check `search-invisible' for t
+       or call `isearch-range-invisible'.
+       (isearch-filter-visible): Make obsolete.
+       (isearch-lazy-highlight-search):
+       Call `run-hook-with-args-until-failure' on
+       `isearch-filter-predicates' and use `isearch-range-invisible'.
+
+       * info.el (Info-search): Call `run-hook-with-args-until-failure' on
+       `isearch-filter-predicates' instead of `funcall'ing
+       `isearch-filter-predicate'.
+       (Info-mode): Set `Info-isearch-filter' to
+       `isearch-filter-predicates' instead of `isearch-filter-predicate'.
+
+       * dired-aux.el (dired-isearch-filter-predicate-orig):
+       Remove variable.
+       (dired-isearch-filenames-toggle, dired-isearch-filenames-setup)
+       (dired-isearch-filenames-end): Add and remove
+       `dired-isearch-filter-filenames' in `isearch-filter-predicates'
+       instead of changing the value of `isearch-filter-predicate'.
+       Rebind `dired-isearch-filenames-toggle' from "\M-sf" to "\M-sff".
+       (dired-isearch-filter-filenames): Don't use `isearch-filter-visible'.
+       Put property `isearch-message-prefix' to "filename " on
+       `dired-isearch-filter-filenames'.
+
+       * wdired.el (wdired-change-to-wdired-mode):
+       Add `isearch-filter-predicates' to `wdired-isearch-filter-read-only'
+       locally instead of changing `isearch-filter-predicate'.
+       (wdired-isearch-filter-read-only): Don't use `isearch-filter-visible'.
+
 2013-05-27  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/easy-mmode.el (define-minor-mode):
index f6ff32b0b01412c046f5802c480e689625d89706..7cb63f6b012f2c97603d6b81bd7d9866c9a25791 100644 (file)
@@ -2491,18 +2491,16 @@ a file name.  Otherwise, it searches the whole buffer without restrictions."
   :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 original predicate."
   (interactive)
-  (setq isearch-filter-predicate
-       (if (eq isearch-filter-predicate 'dired-isearch-filter-filenames)
-           dired-isearch-filter-predicate-orig
-         'dired-isearch-filter-filenames))
+  (setq isearch-filter-predicates
+       (if (memq 'dired-isearch-filter-filenames isearch-filter-predicates)
+           (delq 'dired-isearch-filter-filenames isearch-filter-predicates)
+         (cons 'dired-isearch-filter-filenames isearch-filter-predicates)))
   (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
@@ -2513,29 +2511,27 @@ Intended to be added to `isearch-mode-hook'."
   (when (or (eq dired-isearch-filenames t)
            (and (eq dired-isearch-filenames 'dwim)
                 (get-text-property (point) 'dired-filename)))
-    (setq isearch-message-prefix-add "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)
+    (define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-toggle)
+    (add-hook 'isearch-filter-predicates 'dired-isearch-filter-filenames nil t)
     (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."
   (setq isearch-message-prefix-add nil)
-  (define-key isearch-mode-map "\M-sf" nil)
-  (setq-default isearch-filter-predicate dired-isearch-filter-predicate-orig)
+  (define-key isearch-mode-map "\M-sff" nil)
+  (remove-hook 'isearch-filter-predicates 'dired-isearch-filter-filenames t)
   (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
 
 (defun dired-isearch-filter-filenames (beg end)
-  "Test whether the current search hit is a visible file name.
+  "Test whether the current search hit is a file name.
 Return non-nil if the text from BEG to END is part of a file
-name (has the text property `dired-filename') and is visible."
-  (and (isearch-filter-visible beg end)
-       (if dired-isearch-filenames
-          (text-property-not-all (min beg end) (max beg end)
-                                 'dired-filename nil)
-        t)))
+name (has the text property `dired-filename')."
+  (if dired-isearch-filenames
+      (text-property-not-all (min beg end) (max beg end)
+                            'dired-filename nil)
+    t))
+
+(put 'dired-isearch-filter-filenames 'isearch-message-prefix "filename ")
 
 ;;;###autoload
 (defun dired-isearch-filenames ()
index f03e0aca4756d5d7f5a6b6ffbb7117e85eb6a934..5b6a78759dbab7c6a97f99d642fc4c72f020db49 100644 (file)
@@ -3864,7 +3864,7 @@ Ask means pop up a menu for the user to select one of copy, move or link."
 ;;;;;;  dired-run-shell-command dired-do-shell-command dired-do-async-shell-command
 ;;;;;;  dired-clean-directory dired-do-print dired-do-touch dired-do-chown
 ;;;;;;  dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff
-;;;;;;  dired-diff) "dired-aux" "dired-aux.el" "d6a694b6d13fa948465fde52a9ffb3ba")
+;;;;;;  dired-diff) "dired-aux" "dired-aux.el" "8f5af3aa4eee1b3448525896fa6f39a3")
 ;;; Generated autoloads from dired-aux.el
 
 (autoload 'dired-diff "dired-aux" "\
index b467373138304e52bd2610bc50192d5aac21021d..9dc312fc697348ef42855c6745c3ed9161d9af05 100644 (file)
@@ -1931,7 +1931,8 @@ If DIRECTION is `backward', search in the reverse direction."
                              (point-max)))
          (while (and (not give-up)
                      (or (null found)
-                         (not (funcall isearch-filter-predicate beg-found found))))
+                         (not (run-hook-with-args-until-failure
+                               'isearch-filter-predicates beg-found found))))
            (let ((search-spaces-regexp Info-search-whitespace-regexp))
              (if (if backward
                      (re-search-backward regexp bound t)
@@ -2009,7 +2010,8 @@ If DIRECTION is `backward', search in the reverse direction."
                (setq give-up nil found nil)
                (while (and (not give-up)
                            (or (null found)
-                               (not (funcall isearch-filter-predicate beg-found found))))
+                               (not (run-hook-with-args-until-failure
+                                     'isearch-filter-predicates beg-found found))))
                  (let ((search-spaces-regexp Info-search-whitespace-regexp))
                    (if (if backward
                            (re-search-backward regexp nil t)
@@ -4275,8 +4277,8 @@ Advanced commands:
        'Info-isearch-wrap)
   (set (make-local-variable 'isearch-push-state-function)
        'Info-isearch-push-state)
-  (set (make-local-variable 'isearch-filter-predicate)
-       'Info-isearch-filter)
+  (set (make-local-variable 'isearch-filter-predicates)
+       '(Info-isearch-filter))
   (set (make-local-variable 'revert-buffer-function)
        'Info-revert-buffer-function)
   (Info-set-mode-line)
index fe73bf7d6a4e21790d6997e44ba4a7748b25f351..5bf2818fadcc69aa91c10275d2e5508e57589090 100644 (file)
@@ -187,12 +187,21 @@ or to the end of the buffer for a backward search.")
   "Function to save a function restoring the mode-specific Isearch state
 to the search status stack.")
 
-(defvar isearch-filter-predicate 'isearch-filter-visible
-  "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.")
+(defvar isearch-filter-predicates nil
+  "Predicates that filter the search hits that would normally be available.
+Search hits that dissatisfy the list of predicates are skipped.
+Each function in this list has two arguments: the positions of
+start and end of text matched by the search.
+The search loop uses `run-hook-with-args-until-failure' to call
+each predicate in order, and when one of the predicates returns nil,
+skips this match and continues searching for the next match.
+When the list of predicates is empty, `run-hook-with-args-until-failure'
+returns non-nil that means that the found match is accepted.
+The property `isearch-message-prefix' put on the predicate's symbol
+specifies the prefix string displyed in the search message.")
+(define-obsolete-variable-alias 'isearch-filter-predicate
+                                'isearch-filter-predicates
+                                "24.4")
 
 ;; Search ring.
 
@@ -2491,6 +2500,13 @@ If there is no completion possible, say so and continue searching."
                              (< (point) isearch-opoint)))
                       "over")
                   (if isearch-wrapped "wrapped ")
+                  (mapconcat (lambda (s)
+                               (and (symbolp s)
+                                    (get s 'isearch-message-prefix)))
+                             (if (consp isearch-filter-predicates)
+                                 isearch-filter-predicates
+                               (list isearch-filter-predicates))
+                             "")
                   (if isearch-word
                       (or (and (symbolp isearch-word)
                                (get isearch-word 'isearch-message-prefix))
@@ -2622,10 +2638,7 @@ update the match data, and return point."
       (setq isearch-case-fold-search
            (isearch-no-upper-case-p isearch-string isearch-regexp)))
   (condition-case lossage
-      (let ((inhibit-point-motion-hooks
-             ;; FIXME: equality comparisons on functions is asking for trouble.
-            (and (eq isearch-filter-predicate 'isearch-filter-visible)
-                 search-invisible))
+      (let ((inhibit-point-motion-hooks search-invisible)
            (inhibit-quit nil)
            (case-fold-search isearch-case-fold-search)
            (retry t))
@@ -2638,8 +2651,15 @@ update the match data, and return point."
          (if (or (not isearch-success)
                  (bobp) (eobp)
                  (= (match-beginning 0) (match-end 0))
-                 (funcall isearch-filter-predicate
-                          (match-beginning 0) (match-end 0)))
+                 ;; When one of filter predicates returns nil,
+                 ;; retry the search.  Otherwise, act according
+                 ;; to search-invisible (open overlays, etc.)
+                 (and (run-hook-with-args-until-failure
+                       'isearch-filter-predicates
+                       (match-beginning 0) (match-end 0))
+                      (or (eq search-invisible t)
+                          (not (isearch-range-invisible
+                                (match-beginning 0) (match-end 0))))))
              (setq retry nil)))
        (setq isearch-just-started nil)
        (if isearch-success
@@ -2816,6 +2836,7 @@ determined by `isearch-range-invisible' unless invisible text can be
 searched too when `search-invisible' is t."
   (or (eq search-invisible t)
       (not (isearch-range-invisible beg end))))
+(make-obsolete 'isearch-filter-visible 'search-invisible "24.4")
 
 \f
 ;; General utilities
@@ -3041,8 +3062,11 @@ Attempt to do the search exactly the way the pending Isearch would."
          (if (or (not success)
                  (= (point) bound) ; like (bobp) (eobp) in `isearch-search'.
                  (= (match-beginning 0) (match-end 0))
-                 (funcall isearch-filter-predicate
-                          (match-beginning 0) (match-end 0)))
+                 (and (run-hook-with-args-until-failure
+                       'isearch-filter-predicates
+                       (match-beginning 0) (match-end 0))
+                      (not (isearch-range-invisible
+                            (match-beginning 0) (match-end 0)))))
              (setq retry nil)))
        success)
     (error nil)))
index 47cd99f45ac30b85f948877684f9a1ccead9be0d..55665fbb6a0483206ec579573a89a0b4f3ae41a5 100644 (file)
@@ -239,8 +239,7 @@ See `wdired-mode'."
        (dired-remember-marks (point-min) (point-max)))
   (set (make-local-variable 'wdired-old-point) (point))
   (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-filter-predicates 'wdired-isearch-filter-read-only nil t)
   (use-local-map wdired-mode-map)
   (force-mode-line-update)
   (setq buffer-read-only nil)
@@ -268,9 +267,8 @@ or \\[wdired-abort-changes] to abort changes")))
 
 (defun wdired-isearch-filter-read-only (beg end)
   "Skip matches that have a read-only property."
-  (and (isearch-filter-visible beg end)
-       (not (text-property-not-all (min beg end) (max beg end)
-                                  'read-only nil))))
+  (not (text-property-not-all (min beg end) (max beg end)
+                             'read-only nil)))
 
 ;; Protect the buffer so only the filenames can be changed, and put
 ;; properties so filenames (old and new) can be easily found.