X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a644fa367504c4587c1b9e5fc20b7af79e6e99a0..c3ed7cea0a43ab86c9d3b1627878055844bc8656:/lisp/isearch.el diff --git a/lisp/isearch.el b/lisp/isearch.el index 2efa4c7e8e..b2223e7b30 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -224,7 +224,7 @@ Default value, nil, means edit the string instead." (autoload 'character-fold-to-regexp "character-fold") -(defcustom search-default-mode #'character-fold-to-regexp +(defcustom search-default-mode nil "Default mode to use when starting isearch. Value is nil, t, or a function. @@ -840,7 +840,6 @@ See the command `isearch-forward-symbol' for more information." (isearch-update))))) -(defvar cursor-sensor-inhibit) ;; isearch-mode only sets up incremental search for the minor mode. ;; All the work is done by the isearch-mode commands. @@ -973,8 +972,6 @@ The last thing is to trigger a new round of lazy highlighting." (setq cursor-sensor-inhibit (delq 'isearch cursor-sensor-inhibit)))) (setq isearch--current-buffer (current-buffer)) (make-local-variable 'cursor-sensor-inhibit) - (unless (boundp 'cursor-sensor-inhibit) - (setq cursor-sensor-inhibit nil)) ;; Suspend things like cursor-intangible during Isearch so we can search ;; even within intangible text. (push 'isearch cursor-sensor-inhibit)) @@ -1528,7 +1525,9 @@ The command then executes BODY and updates the isearch prompt." (if docstring (concat "\n" docstring) "")) (interactive) ,@(when function - `((setq isearch-regexp-function #',function) + `((setq isearch-regexp-function + (unless (eq isearch-regexp-function #',function) + #',function)) (setq isearch-regexp nil))) ,@body (setq isearch-success t isearch-adjusted t) @@ -2572,16 +2571,30 @@ the word mode." (when (eq regexp-function t) (setq regexp-function #'word-search-regexp)) (let ((description - ;; Don't use a description on the default search mode. - (cond ((equal regexp-function search-default-mode) "") - (regexp-function - (and (symbolp regexp-function) - (or (get regexp-function 'isearch-message-prefix) - ""))) - (isearch-regexp "regexp ") - ;; We're in literal mode. If the default mode is not - ;; literal, then describe it. - ((functionp search-default-mode) "literal ")))) + (cond + ;; 1. Do not use a description on the default search mode, + ;; but only if the default search mode is non-nil. + ((or (and search-default-mode + (equal search-default-mode regexp-function)) + ;; Special case where `search-default-mode' is t + ;; (defaults to regexp searches). + (and (eq search-default-mode t) + (eq search-default-mode isearch-regexp))) "") + ;; 2. Use the `isearch-message-prefix' set for + ;; `regexp-function' if available. + (regexp-function + (and (symbolp regexp-function) + (or (get regexp-function 'isearch-message-prefix) + ""))) + ;; 3. Else if `isearch-regexp' is non-nil, set description + ;; to "regexp ". + (isearch-regexp "regexp ") + ;; 4. Else if we're in literal mode (and if the default + ;; mode is also not literal), describe it. + ((functionp search-default-mode) "literal ") + ;; 5. And finally, if none of the above is true, set the + ;; description to an empty string. + (t "")))) (if space-before ;; Move space from the end to the beginning. (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description) @@ -2649,8 +2662,9 @@ the word mode." "Non-default value overrides the behavior of `isearch-search-fun-default'. This variable's value should be a function, which will be called with no arguments, and should return a function that takes three -arguments: STRING, BOUND, and NOERROR. See `re-search-forward' -for the meaning of BOUND and NOERROR arguments. +arguments: STRING, BOUND, and NOERROR. STRING is the string to +be searched for. See `re-search-forward' for the meaning of +BOUND and NOERROR arguments. This returned function will be used by `isearch-search-string' to search for the first occurrence of STRING.")