diff options
| author | Artur Malabarba | 2015-10-21 17:27:23 +0100 |
|---|---|---|
| committer | Artur Malabarba | 2015-10-21 17:35:58 +0100 |
| commit | e5ece3229d7992f4dcaca93d778c7352d1ba775f (patch) | |
| tree | efeb9e60b0d161fd4cc5e2844881a5c69d7dfe8e | |
| parent | 19fada58e2a982024ae31272cc054af80961eb37 (diff) | |
| download | emacs-e5ece3229d7992f4dcaca93d778c7352d1ba775f.tar.gz emacs-e5ece3229d7992f4dcaca93d778c7352d1ba775f.zip | |
* lisp/isearch.el (isearch-search-fun-default): Simplify logic
(isearch--lax-regexp-function-p): New function.
| -rw-r--r-- | lisp/isearch.el | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 61ae42e16f8..6b99da91ec4 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -1725,6 +1725,13 @@ the beginning or the end of the string need not match a symbol boundary." | |||
| 1725 | (let ((search-spaces-regexp search-whitespace-regexp)) | 1725 | (let ((search-spaces-regexp search-whitespace-regexp)) |
| 1726 | (re-search-backward regexp bound noerror count))) | 1726 | (re-search-backward regexp bound noerror count))) |
| 1727 | 1727 | ||
| 1728 | (dolist (old '(re-search-forward-lax-whitespace search-backward-lax-whitespace | ||
| 1729 | search-forward-lax-whitespace re-search-backward-lax-whitespace)) | ||
| 1730 | (make-obsolete old | ||
| 1731 | "instead, use (let ((search-spaces-regexp search-whitespace-regexp)) | ||
| 1732 | (re-search-... ...))" | ||
| 1733 | "25.1")) | ||
| 1734 | |||
| 1728 | 1735 | ||
| 1729 | (defun isearch-query-replace (&optional arg regexp-flag) | 1736 | (defun isearch-query-replace (&optional arg regexp-flag) |
| 1730 | "Start `query-replace' with string to replace from last search string. | 1737 | "Start `query-replace' with string to replace from last search string. |
| @@ -2609,40 +2616,34 @@ search for the first occurrence of STRING or its translation.") | |||
| 2609 | Can be changed via `isearch-search-fun-function' for special needs." | 2616 | Can be changed via `isearch-search-fun-function' for special needs." |
| 2610 | (funcall (or isearch-search-fun-function 'isearch-search-fun-default))) | 2617 | (funcall (or isearch-search-fun-function 'isearch-search-fun-default))) |
| 2611 | 2618 | ||
| 2619 | (defun isearch--lax-regexp-function-p () | ||
| 2620 | "Non-nil if next regexp-function call should be lax." | ||
| 2621 | (not (or isearch-nonincremental | ||
| 2622 | (null (car isearch-cmds)) | ||
| 2623 | (eq (length isearch-string) | ||
| 2624 | (length (isearch--state-string | ||
| 2625 | (car isearch-cmds))))))) | ||
| 2626 | |||
| 2612 | (defun isearch-search-fun-default () | 2627 | (defun isearch-search-fun-default () |
| 2613 | "Return default functions to use for the search." | 2628 | "Return default functions to use for the search." |
| 2614 | (cond | 2629 | (lambda (string &optional bound noerror count) |
| 2615 | (isearch-regexp-function | 2630 | ;; Use lax versions to not fail at the end of the word while |
| 2616 | (lambda (string &optional bound noerror count) | 2631 | ;; the user adds and removes characters in the search string |
| 2617 | ;; Use lax versions to not fail at the end of the word while | 2632 | ;; (or when using nonincremental word isearch) |
| 2618 | ;; the user adds and removes characters in the search string | 2633 | (let ((search-spaces-regexp (when (cond |
| 2619 | ;; (or when using nonincremental word isearch) | 2634 | (isearch-regexp isearch-regexp-lax-whitespace) |
| 2620 | (let ((lax (not (or isearch-nonincremental | 2635 | (t isearch-lax-whitespace)) |
| 2621 | (null (car isearch-cmds)) | 2636 | search-whitespace-regexp))) |
| 2622 | (eq (length isearch-string) | 2637 | (funcall |
| 2623 | (length (isearch--state-string | 2638 | (if isearch-forward #'re-search-forward #'re-search-backward) |
| 2624 | (car isearch-cmds))))))) | 2639 | (cond (isearch-regexp-function |
| 2625 | (search-spaces-regexp (when isearch-lax-whitespace | 2640 | (let ((lax (isearch--lax-regexp-function-p))) |
| 2626 | search-whitespace-regexp))) | 2641 | (if (functionp isearch-regexp-function) |
| 2627 | (funcall | 2642 | (funcall isearch-regexp-function string lax) |
| 2628 | (if isearch-forward #'re-search-forward #'re-search-backward) | 2643 | (word-search-regexp string lax)))) |
| 2629 | (if (functionp isearch-regexp-function) | 2644 | (isearch-regexp string) |
| 2630 | (funcall isearch-regexp-function string lax) | 2645 | (t (regexp-quote string))) |
| 2631 | (word-search-regexp string lax)) | 2646 | bound noerror count)))) |
| 2632 | bound noerror count)))) | ||
| 2633 | ((and isearch-regexp isearch-regexp-lax-whitespace | ||
| 2634 | search-whitespace-regexp) | ||
| 2635 | (if isearch-forward | ||
| 2636 | 're-search-forward-lax-whitespace | ||
| 2637 | 're-search-backward-lax-whitespace)) | ||
| 2638 | (isearch-regexp | ||
| 2639 | (if isearch-forward 're-search-forward 're-search-backward)) | ||
| 2640 | ((and isearch-lax-whitespace search-whitespace-regexp) | ||
| 2641 | (if isearch-forward | ||
| 2642 | 'search-forward-lax-whitespace | ||
| 2643 | 'search-backward-lax-whitespace)) | ||
| 2644 | (t | ||
| 2645 | (if isearch-forward 'search-forward 'search-backward)))) | ||
| 2646 | 2647 | ||
| 2647 | (defun isearch-search-string (string bound noerror) | 2648 | (defun isearch-search-string (string bound noerror) |
| 2648 | "Search for the first occurrence of STRING or its translation. | 2649 | "Search for the first occurrence of STRING or its translation. |