aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov2013-05-28 01:42:11 +0300
committerJuri Linkov2013-05-28 01:42:11 +0300
commit66fc57e3cdc9ffc2bed7a457a39a210fcf773e98 (patch)
tree68dc621e5e72aa29961545e7d69dd0b0d0f67d5b /lisp
parent6ef3db10430c653e302ca5983ade6f8eaa186f85 (diff)
downloademacs-66fc57e3cdc9ffc2bed7a457a39a210fcf773e98.tar.gz
emacs-66fc57e3cdc9ffc2bed7a457a39a210fcf773e98.zip
* lisp/isearch.el (isearch-filter-predicates): Rename from `isearch-filter-predicate'.
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
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog37
-rw-r--r--lisp/dired-aux.el36
-rw-r--r--lisp/dired.el2
-rw-r--r--lisp/info.el10
-rw-r--r--lisp/isearch.el52
-rw-r--r--lisp/wdired.el8
6 files changed, 101 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 509c940a8f4..486e5d75343 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,40 @@
12013-05-27 Juri Linkov <juri@jurta.org>
2
3 * isearch.el (isearch-filter-predicates): Rename from
4 `isearch-filter-predicate'. Doc fix. (Bug#11378)
5 (isearch-message-prefix): Display text from the property
6 `isearch-message-prefix' of the currently active filters.
7 (isearch-search): Don't compare `isearch-filter-predicate' with
8 `isearch-filter-visible'. Call `run-hook-with-args-until-failure'
9 on `isearch-filter-predicates'. Also check `search-invisible' for t
10 or call `isearch-range-invisible'.
11 (isearch-filter-visible): Make obsolete.
12 (isearch-lazy-highlight-search):
13 Call `run-hook-with-args-until-failure' on
14 `isearch-filter-predicates' and use `isearch-range-invisible'.
15
16 * info.el (Info-search): Call `run-hook-with-args-until-failure' on
17 `isearch-filter-predicates' instead of `funcall'ing
18 `isearch-filter-predicate'.
19 (Info-mode): Set `Info-isearch-filter' to
20 `isearch-filter-predicates' instead of `isearch-filter-predicate'.
21
22 * dired-aux.el (dired-isearch-filter-predicate-orig):
23 Remove variable.
24 (dired-isearch-filenames-toggle, dired-isearch-filenames-setup)
25 (dired-isearch-filenames-end): Add and remove
26 `dired-isearch-filter-filenames' in `isearch-filter-predicates'
27 instead of changing the value of `isearch-filter-predicate'.
28 Rebind `dired-isearch-filenames-toggle' from "\M-sf" to "\M-sff".
29 (dired-isearch-filter-filenames): Don't use `isearch-filter-visible'.
30 Put property `isearch-message-prefix' to "filename " on
31 `dired-isearch-filter-filenames'.
32
33 * wdired.el (wdired-change-to-wdired-mode):
34 Add `isearch-filter-predicates' to `wdired-isearch-filter-read-only'
35 locally instead of changing `isearch-filter-predicate'.
36 (wdired-isearch-filter-read-only): Don't use `isearch-filter-visible'.
37
12013-05-27 Stefan Monnier <monnier@iro.umontreal.ca> 382013-05-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 39
3 * emacs-lisp/easy-mmode.el (define-minor-mode): 40 * emacs-lisp/easy-mmode.el (define-minor-mode):
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index f6ff32b0b01..7cb63f6b012 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2491,18 +2491,16 @@ a file name. Otherwise, it searches the whole buffer without restrictions."
2491 :group 'dired 2491 :group 'dired
2492 :version "23.1") 2492 :version "23.1")
2493 2493
2494(defvar dired-isearch-filter-predicate-orig nil)
2495
2496(defun dired-isearch-filenames-toggle () 2494(defun dired-isearch-filenames-toggle ()
2497 "Toggle file names searching on or off. 2495 "Toggle file names searching on or off.
2498When on, Isearch skips matches outside file names using the predicate 2496When on, Isearch skips matches outside file names using the predicate
2499`dired-isearch-filter-filenames' that matches only at file names. 2497`dired-isearch-filter-filenames' that matches only at file names.
2500When off, it uses the original predicate." 2498When off, it uses the original predicate."
2501 (interactive) 2499 (interactive)
2502 (setq isearch-filter-predicate 2500 (setq isearch-filter-predicates
2503 (if (eq isearch-filter-predicate 'dired-isearch-filter-filenames) 2501 (if (memq 'dired-isearch-filter-filenames isearch-filter-predicates)
2504 dired-isearch-filter-predicate-orig 2502 (delq 'dired-isearch-filter-filenames isearch-filter-predicates)
2505 'dired-isearch-filter-filenames)) 2503 (cons 'dired-isearch-filter-filenames isearch-filter-predicates)))
2506 (setq isearch-success t isearch-adjusted t) 2504 (setq isearch-success t isearch-adjusted t)
2507 (isearch-update)) 2505 (isearch-update))
2508 2506
@@ -2513,29 +2511,27 @@ Intended to be added to `isearch-mode-hook'."
2513 (when (or (eq dired-isearch-filenames t) 2511 (when (or (eq dired-isearch-filenames t)
2514 (and (eq dired-isearch-filenames 'dwim) 2512 (and (eq dired-isearch-filenames 'dwim)
2515 (get-text-property (point) 'dired-filename))) 2513 (get-text-property (point) 'dired-filename)))
2516 (setq isearch-message-prefix-add "filename ") 2514 (define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-toggle)
2517 (define-key isearch-mode-map "\M-sf" 'dired-isearch-filenames-toggle) 2515 (add-hook 'isearch-filter-predicates 'dired-isearch-filter-filenames nil t)
2518 (setq dired-isearch-filter-predicate-orig
2519 (default-value 'isearch-filter-predicate))
2520 (setq-default isearch-filter-predicate 'dired-isearch-filter-filenames)
2521 (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t))) 2516 (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
2522 2517
2523(defun dired-isearch-filenames-end () 2518(defun dired-isearch-filenames-end ()
2524 "Clean up the Dired file name search after terminating isearch." 2519 "Clean up the Dired file name search after terminating isearch."
2525 (setq isearch-message-prefix-add nil) 2520 (setq isearch-message-prefix-add nil)
2526 (define-key isearch-mode-map "\M-sf" nil) 2521 (define-key isearch-mode-map "\M-sff" nil)
2527 (setq-default isearch-filter-predicate dired-isearch-filter-predicate-orig) 2522 (remove-hook 'isearch-filter-predicates 'dired-isearch-filter-filenames t)
2528 (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)) 2523 (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
2529 2524
2530(defun dired-isearch-filter-filenames (beg end) 2525(defun dired-isearch-filter-filenames (beg end)
2531 "Test whether the current search hit is a visible file name. 2526 "Test whether the current search hit is a file name.
2532Return non-nil if the text from BEG to END is part of a file 2527Return non-nil if the text from BEG to END is part of a file
2533name (has the text property `dired-filename') and is visible." 2528name (has the text property `dired-filename')."
2534 (and (isearch-filter-visible beg end) 2529 (if dired-isearch-filenames
2535 (if dired-isearch-filenames 2530 (text-property-not-all (min beg end) (max beg end)
2536 (text-property-not-all (min beg end) (max beg end) 2531 'dired-filename nil)
2537 'dired-filename nil) 2532 t))
2538 t))) 2533
2534(put 'dired-isearch-filter-filenames 'isearch-message-prefix "filename ")
2539 2535
2540;;;###autoload 2536;;;###autoload
2541(defun dired-isearch-filenames () 2537(defun dired-isearch-filenames ()
diff --git a/lisp/dired.el b/lisp/dired.el
index f03e0aca475..5b6a78759db 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3864,7 +3864,7 @@ Ask means pop up a menu for the user to select one of copy, move or link."
3864;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command 3864;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command
3865;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown 3865;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown
3866;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff 3866;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff
3867;;;;;; dired-diff) "dired-aux" "dired-aux.el" "d6a694b6d13fa948465fde52a9ffb3ba") 3867;;;;;; dired-diff) "dired-aux" "dired-aux.el" "8f5af3aa4eee1b3448525896fa6f39a3")
3868;;; Generated autoloads from dired-aux.el 3868;;; Generated autoloads from dired-aux.el
3869 3869
3870(autoload 'dired-diff "dired-aux" "\ 3870(autoload 'dired-diff "dired-aux" "\
diff --git a/lisp/info.el b/lisp/info.el
index b4673731383..9dc312fc697 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1931,7 +1931,8 @@ If DIRECTION is `backward', search in the reverse direction."
1931 (point-max))) 1931 (point-max)))
1932 (while (and (not give-up) 1932 (while (and (not give-up)
1933 (or (null found) 1933 (or (null found)
1934 (not (funcall isearch-filter-predicate beg-found found)))) 1934 (not (run-hook-with-args-until-failure
1935 'isearch-filter-predicates beg-found found))))
1935 (let ((search-spaces-regexp Info-search-whitespace-regexp)) 1936 (let ((search-spaces-regexp Info-search-whitespace-regexp))
1936 (if (if backward 1937 (if (if backward
1937 (re-search-backward regexp bound t) 1938 (re-search-backward regexp bound t)
@@ -2009,7 +2010,8 @@ If DIRECTION is `backward', search in the reverse direction."
2009 (setq give-up nil found nil) 2010 (setq give-up nil found nil)
2010 (while (and (not give-up) 2011 (while (and (not give-up)
2011 (or (null found) 2012 (or (null found)
2012 (not (funcall isearch-filter-predicate beg-found found)))) 2013 (not (run-hook-with-args-until-failure
2014 'isearch-filter-predicates beg-found found))))
2013 (let ((search-spaces-regexp Info-search-whitespace-regexp)) 2015 (let ((search-spaces-regexp Info-search-whitespace-regexp))
2014 (if (if backward 2016 (if (if backward
2015 (re-search-backward regexp nil t) 2017 (re-search-backward regexp nil t)
@@ -4275,8 +4277,8 @@ Advanced commands:
4275 'Info-isearch-wrap) 4277 'Info-isearch-wrap)
4276 (set (make-local-variable 'isearch-push-state-function) 4278 (set (make-local-variable 'isearch-push-state-function)
4277 'Info-isearch-push-state) 4279 'Info-isearch-push-state)
4278 (set (make-local-variable 'isearch-filter-predicate) 4280 (set (make-local-variable 'isearch-filter-predicates)
4279 'Info-isearch-filter) 4281 '(Info-isearch-filter))
4280 (set (make-local-variable 'revert-buffer-function) 4282 (set (make-local-variable 'revert-buffer-function)
4281 'Info-revert-buffer-function) 4283 'Info-revert-buffer-function)
4282 (Info-set-mode-line) 4284 (Info-set-mode-line)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index fe73bf7d6a4..5bf2818fadc 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -187,12 +187,21 @@ or to the end of the buffer for a backward search.")
187 "Function to save a function restoring the mode-specific Isearch state 187 "Function to save a function restoring the mode-specific Isearch state
188to the search status stack.") 188to the search status stack.")
189 189
190(defvar isearch-filter-predicate 'isearch-filter-visible 190(defvar isearch-filter-predicates nil
191 "Predicate that filters the search hits that would normally be available. 191 "Predicates that filter the search hits that would normally be available.
192Search hits that dissatisfy the predicate are skipped. The function 192Search hits that dissatisfy the list of predicates are skipped.
193has two arguments: the positions of start and end of text matched by 193Each function in this list has two arguments: the positions of
194the search. If this function returns nil, continue searching without 194start and end of text matched by the search.
195stopping at this match.") 195The search loop uses `run-hook-with-args-until-failure' to call
196each predicate in order, and when one of the predicates returns nil,
197skips this match and continues searching for the next match.
198When the list of predicates is empty, `run-hook-with-args-until-failure'
199returns non-nil that means that the found match is accepted.
200The property `isearch-message-prefix' put on the predicate's symbol
201specifies the prefix string displyed in the search message.")
202(define-obsolete-variable-alias 'isearch-filter-predicate
203 'isearch-filter-predicates
204 "24.4")
196 205
197;; Search ring. 206;; Search ring.
198 207
@@ -2491,6 +2500,13 @@ If there is no completion possible, say so and continue searching."
2491 (< (point) isearch-opoint))) 2500 (< (point) isearch-opoint)))
2492 "over") 2501 "over")
2493 (if isearch-wrapped "wrapped ") 2502 (if isearch-wrapped "wrapped ")
2503 (mapconcat (lambda (s)
2504 (and (symbolp s)
2505 (get s 'isearch-message-prefix)))
2506 (if (consp isearch-filter-predicates)
2507 isearch-filter-predicates
2508 (list isearch-filter-predicates))
2509 "")
2494 (if isearch-word 2510 (if isearch-word
2495 (or (and (symbolp isearch-word) 2511 (or (and (symbolp isearch-word)
2496 (get isearch-word 'isearch-message-prefix)) 2512 (get isearch-word 'isearch-message-prefix))
@@ -2622,10 +2638,7 @@ update the match data, and return point."
2622 (setq isearch-case-fold-search 2638 (setq isearch-case-fold-search
2623 (isearch-no-upper-case-p isearch-string isearch-regexp))) 2639 (isearch-no-upper-case-p isearch-string isearch-regexp)))
2624 (condition-case lossage 2640 (condition-case lossage
2625 (let ((inhibit-point-motion-hooks 2641 (let ((inhibit-point-motion-hooks search-invisible)
2626 ;; FIXME: equality comparisons on functions is asking for trouble.
2627 (and (eq isearch-filter-predicate 'isearch-filter-visible)
2628 search-invisible))
2629 (inhibit-quit nil) 2642 (inhibit-quit nil)
2630 (case-fold-search isearch-case-fold-search) 2643 (case-fold-search isearch-case-fold-search)
2631 (retry t)) 2644 (retry t))
@@ -2638,8 +2651,15 @@ update the match data, and return point."
2638 (if (or (not isearch-success) 2651 (if (or (not isearch-success)
2639 (bobp) (eobp) 2652 (bobp) (eobp)
2640 (= (match-beginning 0) (match-end 0)) 2653 (= (match-beginning 0) (match-end 0))
2641 (funcall isearch-filter-predicate 2654 ;; When one of filter predicates returns nil,
2642 (match-beginning 0) (match-end 0))) 2655 ;; retry the search. Otherwise, act according
2656 ;; to search-invisible (open overlays, etc.)
2657 (and (run-hook-with-args-until-failure
2658 'isearch-filter-predicates
2659 (match-beginning 0) (match-end 0))
2660 (or (eq search-invisible t)
2661 (not (isearch-range-invisible
2662 (match-beginning 0) (match-end 0))))))
2643 (setq retry nil))) 2663 (setq retry nil)))
2644 (setq isearch-just-started nil) 2664 (setq isearch-just-started nil)
2645 (if isearch-success 2665 (if isearch-success
@@ -2816,6 +2836,7 @@ determined by `isearch-range-invisible' unless invisible text can be
2816searched too when `search-invisible' is t." 2836searched too when `search-invisible' is t."
2817 (or (eq search-invisible t) 2837 (or (eq search-invisible t)
2818 (not (isearch-range-invisible beg end)))) 2838 (not (isearch-range-invisible beg end))))
2839(make-obsolete 'isearch-filter-visible 'search-invisible "24.4")
2819 2840
2820 2841
2821;; General utilities 2842;; General utilities
@@ -3041,8 +3062,11 @@ Attempt to do the search exactly the way the pending Isearch would."
3041 (if (or (not success) 3062 (if (or (not success)
3042 (= (point) bound) ; like (bobp) (eobp) in `isearch-search'. 3063 (= (point) bound) ; like (bobp) (eobp) in `isearch-search'.
3043 (= (match-beginning 0) (match-end 0)) 3064 (= (match-beginning 0) (match-end 0))
3044 (funcall isearch-filter-predicate 3065 (and (run-hook-with-args-until-failure
3045 (match-beginning 0) (match-end 0))) 3066 'isearch-filter-predicates
3067 (match-beginning 0) (match-end 0))
3068 (not (isearch-range-invisible
3069 (match-beginning 0) (match-end 0)))))
3046 (setq retry nil))) 3070 (setq retry nil)))
3047 success) 3071 success)
3048 (error nil))) 3072 (error nil)))
diff --git a/lisp/wdired.el b/lisp/wdired.el
index 47cd99f45ac..55665fbb6a0 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -239,8 +239,7 @@ See `wdired-mode'."
239 (dired-remember-marks (point-min) (point-max))) 239 (dired-remember-marks (point-min) (point-max)))
240 (set (make-local-variable 'wdired-old-point) (point)) 240 (set (make-local-variable 'wdired-old-point) (point))
241 (set (make-local-variable 'query-replace-skip-read-only) t) 241 (set (make-local-variable 'query-replace-skip-read-only) t)
242 (set (make-local-variable 'isearch-filter-predicate) 242 (add-hook 'isearch-filter-predicates 'wdired-isearch-filter-read-only nil t)
243 'wdired-isearch-filter-read-only)
244 (use-local-map wdired-mode-map) 243 (use-local-map wdired-mode-map)
245 (force-mode-line-update) 244 (force-mode-line-update)
246 (setq buffer-read-only nil) 245 (setq buffer-read-only nil)
@@ -268,9 +267,8 @@ or \\[wdired-abort-changes] to abort changes")))
268 267
269(defun wdired-isearch-filter-read-only (beg end) 268(defun wdired-isearch-filter-read-only (beg end)
270 "Skip matches that have a read-only property." 269 "Skip matches that have a read-only property."
271 (and (isearch-filter-visible beg end) 270 (not (text-property-not-all (min beg end) (max beg end)
272 (not (text-property-not-all (min beg end) (max beg end) 271 'read-only nil)))
273 'read-only nil))))
274 272
275;; Protect the buffer so only the filenames can be changed, and put 273;; Protect the buffer so only the filenames can be changed, and put
276;; properties so filenames (old and new) can be easily found. 274;; properties so filenames (old and new) can be easily found.