Commit dc6c0eda authored by Stefan Monnier's avatar Stefan Monnier

Revert introduction of isearch-filter-predicates.

Rely on add-function instead.
* lisp/loadup.el: Preload nadvice.
* lisp/isearch.el (isearch-filter-predicates): Rename it back to
isearch-filter-predicate.
(isearch-message-prefix): Use advice-function-mapc and advice
properties to get the isearch-message-prefix.
(isearch-search, isearch-lazy-highlight-search): Revert to funcall
instead of run-hook-with-args-until-failure.
(isearch-filter-visible): Not obsolete any more.
* lisp/replace.el (perform-replace): Revert to funcall
instead of run-hook-with-args-until-failure.
* lisp/wdired.el (wdired-change-to-wdired-mode): Use add-function.
* lisp/dired-aux.el (dired-isearch-filenames-mode): Rename from
dired-isearch-filenames-toggle; make it into a proper minor mode.
Use add/remove-function.
(dired-isearch-filenames-setup, dired-isearch-filenames-end):
Call the minor-mode rather than add/remove-hook.
(dired-isearch-filter-filenames):
Remove isearch-message-prefix property.
* lisp/info.el (Info--search-loop): New function, extracted from Info-search.
Funcall isearch-filter-predicate instead of
run-hook-with-args-until-failure isearch-filter-predicates.
(Info-search): Use it.
(Info-mode): Use isearch-filter-predicate instead of
isearch-filter-predicates.
* src/lisp.mk (lisp): Add nadvice.elc.
* lib-src/makefile.w32-in (lisp2): Add nadvice.elc.

Fixes: debbugs:14714
parent 98a428c1
2013-08-05 Stefan Monnier <monnier@iro.umontreal.ca>
* makefile.w32-in (lisp2): Add nadvice.elc.
2013-08-05 Eli Zaretskii <eliz@gnu.org>
* update-game-score.c (read_score): Try reading a character before
......
......@@ -251,6 +251,7 @@ lisp2 = \
$(lispsource)register.elc \
$(lispsource)replace.elc \
$(lispsource)simple.elc \
$(lispsource)emacs-lisp/nadvice.elc \
$(lispsource)minibuffer.elc \
$(lispsource)startup.elc \
$(lispsource)subr.elc \
......
2013-08-05 Stefan Monnier <monnier@iro.umontreal.ca>
Revert introduction of isearch-filter-predicates (bug#14714).
Rely on add-function instead.
* isearch.el (isearch-filter-predicates): Rename it back to
isearch-filter-predicate.
(isearch-message-prefix): Use advice-function-mapc and advice
properties to get the isearch-message-prefix.
(isearch-search, isearch-lazy-highlight-search): Revert to funcall
instead of run-hook-with-args-until-failure.
(isearch-filter-visible): Not obsolete any more.
* loadup.el: Preload nadvice.
* replace.el (perform-replace): Revert to funcall
instead of run-hook-with-args-until-failure.
* wdired.el (wdired-change-to-wdired-mode): Use add-function.
* dired-aux.el (dired-isearch-filenames-mode): Rename from
dired-isearch-filenames-toggle; make it into a proper minor mode.
Use add/remove-function.
(dired-isearch-filenames-setup, dired-isearch-filenames-end):
Call the minor-mode rather than add/remove-hook.
(dired-isearch-filter-filenames):
Remove isearch-message-prefix property.
* info.el (Info--search-loop): New function, extracted from Info-search.
Funcall isearch-filter-predicate instead of
run-hook-with-args-until-failure isearch-filter-predicates.
(Info-search): Use it.
(Info-mode): Use isearch-filter-predicate instead of
isearch-filter-predicates.
2013-08-05 Dmitry Antipov <dmantipov@yandex.ru>
Do not call to `selected-window' where it is assumed by default.
......
......@@ -2491,18 +2491,21 @@ a file name. Otherwise, it searches the whole buffer without restrictions."
:group 'dired
:version "23.1")
(defun dired-isearch-filenames-toggle ()
(define-minor-mode dired-isearch-filenames-mode
"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-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))
nil nil nil
(if dired-isearch-filenames-mode
(add-function :before-while (local 'isearch-filter-predicate)
#'dired-isearch-filter-filenames
'((isearch-message-prefix . "filename ")))
(remove-function (local 'isearch-filter-predicate)
#'dired-isearch-filter-filenames))
(when isearch-mode
(setq isearch-success t isearch-adjusted t)
(isearch-update)))
;;;###autoload
(defun dired-isearch-filenames-setup ()
......@@ -2511,15 +2514,14 @@ 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)))
(define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-toggle)
(add-hook 'isearch-filter-predicates 'dired-isearch-filter-filenames nil t)
(define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-mode)
(dired-isearch-filenames-mode 1)
(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-sff" nil)
(remove-hook 'isearch-filter-predicates 'dired-isearch-filter-filenames t)
(dired-isearch-filenames-mode -1)
(remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
(defun dired-isearch-filter-filenames (beg end)
......@@ -2531,8 +2533,6 @@ name (has the text property `dired-filename')."
'dired-filename nil)
t))
(put 'dired-isearch-filter-filenames 'isearch-message-prefix "filename ")
;;;###autoload
(defun dired-isearch-filenames ()
"Search for a string using Isearch only in file names in the Dired buffer."
......
......@@ -3849,22 +3849,7 @@ Ask means pop up a menu for the user to select one of copy, move or link."
;;; Start of automatically extracted autoloads.
;;;### (autoloads (dired-show-file-type dired-do-query-replace-regexp
;;;;;; dired-do-search dired-do-isearch-regexp dired-do-isearch
;;;;;; dired-isearch-filenames-regexp dired-isearch-filenames dired-isearch-filenames-setup
;;;;;; dired-hide-all dired-hide-subdir dired-tree-down dired-tree-up
;;;;;; dired-kill-subdir dired-mark-subdir-files dired-goto-subdir
;;;;;; dired-prev-subdir dired-insert-subdir dired-maybe-insert-subdir
;;;;;; dired-downcase dired-upcase dired-do-symlink-regexp dired-do-hardlink-regexp
;;;;;; dired-do-copy-regexp dired-do-rename-regexp dired-do-rename
;;;;;; dired-do-hardlink dired-do-symlink dired-do-copy dired-create-directory
;;;;;; dired-rename-file dired-copy-file dired-relist-file dired-remove-file
;;;;;; dired-add-file dired-do-redisplay dired-do-load dired-do-byte-compile
;;;;;; dired-do-compress dired-query dired-compress-file dired-do-kill-lines
;;;;;; 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" "8f5af3aa4eee1b3448525896fa6f39a3")
;;;### (autoloads nil "dired-aux" "dired-aux.el" "555c067fcab27f5a377536db407803ab")
;;; Generated autoloads from dired-aux.el
(autoload 'dired-diff "dired-aux" "\
......
......@@ -1905,6 +1905,30 @@ the Top node in FILENAME."
(defvar Info-search-case-fold nil
"The value of `case-fold-search' from previous `Info-search' command.")
(defun Info--search-loop (regexp bound backward)
(when backward
;; Hide Info file header for backward search.
(narrow-to-region (save-excursion
(goto-char (point-min))
(search-forward "\n\^_")
(1- (point)))
(point-max)))
(let ((give-up nil)
(found nil)
(beg-found nil))
(while (not (or give-up
(and found
(funcall isearch-filter-predicate
beg-found found))))
(let ((search-spaces-regexp Info-search-whitespace-regexp))
(if (funcall
(if backward #'re-search-backward #'re-search-forward)
regexp bound t)
(setq found (point) beg-found (if backward (match-end 0)
(match-beginning 0)))
(setq give-up t found nil))))
found))
(defun Info-search (regexp &optional bound _noerror _count direction)
"Search for REGEXP, starting from point, and select node it's found in.
If DIRECTION is `backward', search in the reverse direction."
......@@ -1920,55 +1944,35 @@ If DIRECTION is `backward', search in the reverse direction."
(when (equal regexp "")
(setq regexp (car Info-search-history)))
(when regexp
(let (found beg-found give-up
(backward (eq direction 'backward))
(onode Info-current-node)
(ofile Info-current-file)
(opoint (point))
(opoint-min (point-min))
(opoint-max (point-max))
(ostart (window-start))
(osubfile Info-current-subfile))
(setq Info-search-case-fold case-fold-search)
(save-excursion
(save-restriction
(widen)
(when backward
;; Hide Info file header for backward search
(narrow-to-region (save-excursion
(goto-char (point-min))
(search-forward "\n\^_")
(1- (point)))
(point-max)))
(while (and (not give-up)
(or (null 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)
(re-search-forward regexp bound t))
(setq found (point) beg-found (if backward (match-end 0)
(match-beginning 0)))
(setq give-up t))))))
(when (and isearch-mode Info-isearch-search
(not Info-isearch-initial-node)
(not bound)
(or give-up (and found (not (and (> found opoint-min)
(< found opoint-max))))))
(setq Info-search-case-fold case-fold-search)
(let* ((backward (eq direction 'backward))
(onode Info-current-node)
(ofile Info-current-file)
(opoint (point))
(opoint-min (point-min))
(opoint-max (point-max))
(ostart (window-start))
(osubfile Info-current-subfile)
(found
(save-excursion
(save-restriction
(widen)
(Info--search-loop regexp bound backward)))))
(unless (or (not isearch-mode) (not Info-isearch-search)
Info-isearch-initial-node
bound
(and found (> found opoint-min) (< found opoint-max)))
(signal 'search-failed (list regexp "end of node")))
;; If no subfiles, give error now.
(if give-up
(if (null Info-current-subfile)
(if isearch-mode
(signal 'search-failed (list regexp "end of manual"))
(let ((search-spaces-regexp Info-search-whitespace-regexp))
(if backward
(re-search-backward regexp)
(re-search-forward regexp))))
(setq found nil)))
(unless (or found Info-current-subfile)
(if isearch-mode
(signal 'search-failed (list regexp "end of manual"))
(let ((search-spaces-regexp Info-search-whitespace-regexp))
(if backward
(re-search-backward regexp)
(re-search-forward regexp)))))
(if (and bound (not found))
(signal 'search-failed (list regexp)))
......@@ -2009,29 +2013,9 @@ If DIRECTION is `backward', search in the reverse direction."
(while list
(message "Searching subfile %s..." (cdr (car list)))
(Info-read-subfile (car (car list)))
(when backward
;; Hide Info file header for backward search
(narrow-to-region (save-excursion
(goto-char (point-min))
(search-forward "\n\^_")
(1- (point)))
(point-max))
(goto-char (point-max)))
(when backward (goto-char (point-max)))
(setq list (cdr list))
(setq give-up nil found nil)
(while (and (not give-up)
(or (null 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)
(re-search-forward regexp nil t))
(setq found (point) beg-found (if backward (match-end 0)
(match-beginning 0)))
(setq give-up t))))
(if give-up
(setq found nil))
(setq found (Info--search-loop regexp nil backward))
(if found
(setq list nil)))
(if found
......@@ -4288,8 +4272,7 @@ Advanced commands:
'Info-isearch-wrap)
(set (make-local-variable 'isearch-push-state-function)
'Info-isearch-push-state)
(set (make-local-variable 'isearch-filter-predicates)
'(Info-isearch-filter))
(set (make-local-variable 'isearch-filter-predicate) #'Info-isearch-filter)
(set (make-local-variable 'revert-buffer-function)
'Info-revert-buffer-function)
(Info-set-mode-line)
......
......@@ -187,21 +187,15 @@ 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-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 displayed in the search message.")
(define-obsolete-variable-alias 'isearch-filter-predicate
'isearch-filter-predicates
"24.4")
(defvar isearch-filter-predicate #'isearch-filter-visible
"Predicate that filter 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.
If you use `add-function' to modify this variable, you can use the
`isearch-message-prefix' advice property to specify the prefix string
displayed in the search message.")
;; Search ring.
......@@ -2614,13 +2608,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))
"")
(let ((prefix ""))
(advice-function-mapc
(lambda (_ props)
(let ((np (cdr (assq 'isearch-message-prefix props))))
(if np (setq prefix (concat np prefix)))))
isearch-filter-predicate)
prefix)
(if isearch-word
(or (and (symbolp isearch-word)
(get isearch-word 'isearch-message-prefix))
......@@ -2766,15 +2760,8 @@ update the match data, and return point."
(if (or (not isearch-success)
(bobp) (eobp)
(= (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))))))
(funcall isearch-filter-predicate
(match-beginning 0) (match-end 0)))
(setq retry nil)))
(setq isearch-just-started nil)
(if isearch-success
......@@ -2951,7 +2938,6 @@ 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 'isearch-invisible "24.4")
;; General utilities
......@@ -3177,11 +3163,8 @@ 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))
(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)))))
(funcall isearch-filter-predicate
(match-beginning 0) (match-end 0)))
(setq retry nil)))
success)
(error nil)))
......
......@@ -139,6 +139,7 @@
;; In case loaddefs hasn't been generated yet.
(file-error (load "ldefs-boot.el")))
(load "emacs-lisp/nadvice")
(load "minibuffer")
(load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
(load "simple")
......
......@@ -252,7 +252,7 @@ or capitalized.)
Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
ignore hidden matches if `search-invisible' is nil, and ignore more
matches using a non-nil `isearch-filter-predicates'.
matches using `isearch-filter-predicate'.
If `replace-lax-whitespace' is non-nil, a space or spaces in the string
to be replaced will match a sequence of whitespace chars defined by the
......@@ -306,7 +306,7 @@ capitalized.)
Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
ignore hidden matches if `search-invisible' is nil, and ignore more
matches using a non-nil `isearch-filter-predicates'.
matches using `isearch-filter-predicate'.
If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
to be replaced will match a sequence of whitespace chars defined by the
......@@ -390,7 +390,7 @@ are non-nil and REGEXP has no uppercase letters.
Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
ignore hidden matches if `search-invisible' is nil, and ignore more
matches using a non-nil `isearch-filter-predicates'.
matches using `isearch-filter-predicate'.
If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
to be replaced will match a sequence of whitespace chars defined by the
......@@ -484,7 +484,7 @@ then its replacement is upcased or capitalized.)
Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
ignore hidden matches if `search-invisible' is nil, and ignore more
matches using a non-nil `isearch-filter-predicates'.
matches using `isearch-filter-predicate'.
If `replace-lax-whitespace' is non-nil, a space or spaces in the string
to be replaced will match a sequence of whitespace chars defined by the
......@@ -530,7 +530,7 @@ are non-nil and REGEXP has no uppercase letters.
Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
ignore hidden matches if `search-invisible' is nil, and ignore more
matches using a non-nil `isearch-filter-predicates'.
matches using `isearch-filter-predicate'.
If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
to be replaced will match a sequence of whitespace chars defined by the
......@@ -2087,9 +2087,8 @@ make, or the user didn't cancel the call."
'read-only nil))))
(setq skip-read-only-count (1+ skip-read-only-count)))
;; Optionally filter out matches.
((not (run-hook-with-args-until-failure
'isearch-filter-predicates
(nth 0 real-match-data) (nth 1 real-match-data)))
((not (funcall isearch-filter-predicate
(nth 0 real-match-data) (nth 1 real-match-data)))
(setq skip-filtered-count (1+ skip-filtered-count)))
;; Optionally ignore invisible matches.
((not (or (eq search-invisible t)
......
......@@ -239,7 +239,8 @@ 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)
(add-hook 'isearch-filter-predicates 'wdired-isearch-filter-read-only nil t)
(add-function :after-while (local 'isearch-filter-predicate)
#'wdired-isearch-filter-read-only)
(use-local-map wdired-mode-map)
(force-mode-line-update)
(setq buffer-read-only nil)
......
2013-08-05 Stefan Monnier <monnier@iro.umontreal.ca>
* lisp.mk (lisp): Add nadvice.elc.
2013-08-05 Dmitry Antipov <dmantipov@yandex.ru>
New macro to iterate over live buffers similar to frames.
......
......@@ -710,7 +710,7 @@ affects all frames on the same terminal device. */)
type[SBYTES (tty_type)] = 0;
}
t = init_tty (name, type, 0); /* Errors are not fatal. */
t = init_tty (name, type, 0); /* Errors are not fatal. */
}
f = make_terminal_frame (t);
......
......@@ -71,6 +71,7 @@ lisp = \
$(lispsource)/faces.elc \
$(lispsource)/button.elc \
$(lispsource)/startup.elc \
$(lispsource)/emacs-lisp/nadvice.elc \
$(lispsource)/minibuffer.elc \
$(lispsource)/abbrev.elc \
$(lispsource)/simple.elc \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment