(defvar isearch-forward nil) ; Searching in the forward direction.
(defvar isearch-regexp nil) ; Searching for a regexp.
-(defvar isearch-word nil
+(defvar isearch-regexp-function nil
"Regexp-based search mode for words/symbols.
-If t, do incremental search for a sequence of words, ignoring punctuation.
-If the value is a function (e.g. `isearch-symbol-regexp'), it is called to
-convert the search string to a regexp used by regexp search functions.
-The property `isearch-message-prefix' put on this function specifies the
-prefix string displayed in the search message.")
+If the value is a function (e.g. `isearch-symbol-regexp'), it is
+called to convert a plain search string to a regexp used by
+regexp search functions.
+The symbol property `isearch-message-prefix' put on this function
+specifies the prefix string displayed in the search message.")
+;; We still support setting this to t for backwards compatibility.
+(define-obsolete-variable-alias 'isearch-word
+ 'isearch-regexp-function "25.1")
(defvar isearch-lax-whitespace t
"If non-nil, a space will match a sequence of whitespace chars.
(put 'character-fold-to-regexp 'isearch-message-prefix "char-fold ")
(defvar character-fold-search)
-(defun isearch-mode (forward &optional regexp op-fun recursive-edit word)
+(defun isearch-mode (forward &optional regexp op-fun recursive-edit regexp-function)
"Start Isearch minor mode.
It is called by the function `isearch-forward' and other related functions.
To behave this way it enters a recursive-edit and exits it when done
isearching.
-The arg WORD, if t, does incremental search for a sequence of words,
-ignoring punctuation. If the value is a function, it is called to
-convert the search string to a regexp used by regexp search functions."
+The arg REGEXP-FUNCTION, if non-nil, should be a function. It is
+used to set the value of `isearch-regexp-function'."
;; Initialize global vars.
(setq isearch-forward forward
isearch-regexp regexp
- isearch-word (or word (and character-fold-search
- (not regexp)
- 'character-fold-to-regexp))
+ isearch-regexp-function (or regexp-function
+ (and character-fold-search
+ (not regexp)
+ 'character-fold-to-regexp))
isearch-op-fun op-fun
isearch-last-case-fold-search isearch-case-fold-search
isearch-case-fold-search case-fold-search
(if isearch-resume-in-command-history
(let ((command `(isearch-resume ,isearch-string ,isearch-regexp
- ,isearch-word ,isearch-forward
+ ,isearch-regexp-function ,isearch-forward
,isearch-message
',isearch-case-fold-search)))
(unless (equal (car command-history) command)
(success isearch-success)
(forward isearch-forward)
(other-end isearch-other-end)
- (word isearch-word)
+ (word isearch-regexp-function)
(error isearch-error)
(wrapped isearch-wrapped)
(barrier isearch-barrier)
isearch-success (isearch--state-success cmd)
isearch-forward (isearch--state-forward cmd)
isearch-other-end (isearch--state-other-end cmd)
- isearch-word (isearch--state-word cmd)
+ isearch-regexp-function (isearch--state-word cmd)
isearch-error (isearch--state-error cmd)
isearch-wrapped (isearch--state-wrapped cmd)
isearch-barrier (isearch--state-barrier cmd)
"Exit Isearch mode, run BODY, and reinvoke the pending search.
You can update the global isearch variables by setting new values to
`isearch-new-string', `isearch-new-message', `isearch-new-forward',
-`isearch-new-word', `isearch-new-case-fold'."
+`isearch-new-regexp-function', `isearch-new-case-fold'."
;; This code is very hairy for several reasons, explained in the code.
;; Mainly, isearch-mode must be terminated while editing and then restarted.
;; If there were a way to catch any change of buffer from the minibuffer,
(isearch-new-string isearch-string)
(isearch-new-message isearch-message)
(isearch-new-forward isearch-forward)
- (isearch-new-word isearch-word)
+ (isearch-new-regexp-function isearch-regexp-function)
(isearch-new-case-fold isearch-case-fold-search)
(isearch-regexp isearch-regexp)
isearch-regexp
isearch-op-fun
nil
- isearch-word)
+ isearch-regexp-function)
;; Copy new local values to isearch globals
(setq isearch-string isearch-new-string
isearch-message isearch-new-message
isearch-forward isearch-new-forward
- isearch-word isearch-new-word
+ isearch-regexp-function isearch-new-regexp-function
isearch-case-fold-search isearch-new-case-fold))
;; Empty isearch-string means use default.
;; The status stack is left unchanged.
(interactive)
(setq isearch-regexp (not isearch-regexp))
- (if isearch-regexp (setq isearch-word nil))
+ (if isearch-regexp (setq isearch-regexp-function nil))
(setq isearch-success t isearch-adjusted t)
(isearch-update))
"Toggle word searching on or off."
;; The status stack is left unchanged.
(interactive)
- (setq isearch-word (if (eq isearch-word t) nil t))
- (if isearch-word (setq isearch-regexp nil))
+ (setq isearch-regexp-function
+ (if (memq isearch-regexp-function '(t word-search-regexp))
+ nil #'word-search-regexp))
+ (when isearch-regexp-function (setq isearch-regexp nil))
(setq isearch-success t isearch-adjusted t)
(isearch-update))
(defun isearch-toggle-symbol ()
"Toggle symbol searching on or off."
(interactive)
- (setq isearch-word (unless (eq isearch-word 'isearch-symbol-regexp)
- 'isearch-symbol-regexp))
- (if isearch-word (setq isearch-regexp nil))
+ (setq isearch-regexp-function
+ (unless (eq isearch-regexp-function #'isearch-symbol-regexp)
+ 'isearch-symbol-regexp))
+ (when isearch-regexp-function (setq isearch-regexp nil))
(setq isearch-success t isearch-adjusted t)
(isearch-update))
(defun isearch-toggle-character-fold ()
"Toggle character folding in searching on or off."
(interactive)
- (setq isearch-word (unless (eq isearch-word #'character-fold-to-regexp)
- #'character-fold-to-regexp))
- (if isearch-word (setq isearch-regexp nil))
+ (setq isearch-regexp-function
+ (unless (eq isearch-regexp-function #'character-fold-to-regexp)
+ #'character-fold-to-regexp))
+ (when isearch-regexp-function (setq isearch-regexp nil))
(setq isearch-success t isearch-adjusted t)
(isearch-update))
(query-replace-read-to
isearch-string
(concat "Query replace"
- (isearch--describe-word-mode (or delimited isearch-word) t)
+ (isearch--describe-regexp-mode (or delimited isearch-regexp-function) t)
(if isearch-regexp " regexp" "")
(if backward " backward" "")
(if (and transient-mark-mode mark-active) " in region" ""))
isearch-regexp)
- t isearch-regexp (or delimited isearch-word) nil nil
+ t isearch-regexp (or delimited isearch-regexp-function) nil nil
(if (and transient-mark-mode mark-active) (region-beginning))
(if (and transient-mark-mode mark-active) (region-end))
backward))
(interactive
(let* ((perform-collect (consp current-prefix-arg))
(regexp (cond
- ((functionp isearch-word)
- (funcall isearch-word isearch-string))
- (isearch-word (word-search-regexp isearch-string))
+ ((functionp isearch-regexp-function)
+ (funcall isearch-regexp-function isearch-string))
+ (isearch-regexp-function (word-search-regexp isearch-string))
(isearch-regexp isearch-string)
(t (regexp-quote isearch-string)))))
(list regexp
(isearch-done nil t)
(isearch-clean-overlays))
(require 'hi-lock nil t)
- (let ((regexp (cond ((functionp isearch-word)
- (funcall isearch-word isearch-string))
- (isearch-word (word-search-regexp isearch-string))
+ (let ((regexp (cond ((functionp isearch-regexp-function)
+ (funcall isearch-regexp-function isearch-string))
+ (isearch-regexp-function (word-search-regexp isearch-string))
(isearch-regexp isearch-string)
((if (and (eq isearch-case-fold-search t)
search-upper-case)
(setq case-fold-search
(isearch-no-upper-case-p isearch-string isearch-regexp)))
(looking-at (cond
- ((functionp isearch-word)
- (funcall isearch-word isearch-string t))
- (isearch-word (word-search-regexp isearch-string t))
+ ((functionp isearch-regexp-function)
+ (funcall isearch-regexp-function isearch-string t))
+ (isearch-regexp-function (word-search-regexp isearch-string t))
(isearch-regexp isearch-string)
(t (regexp-quote isearch-string)))))
(error nil))
(isearch-message-suffix c-q-hack)))
(if c-q-hack m (let ((message-log-max nil)) (message "%s" m)))))
-(defun isearch--describe-word-mode (word-mode &optional space-before)
- "Make a string for describing WORD-MODE.
-If SPACE-BEFORE is non-nil, put a space before, instead of after,
+(defun isearch--describe-regexp-mode (regexp-function &optional space-before)
+ "Make a string for describing REGEXP-FUNCTION.
+If SPACE-BEFORE is non-nil, put a space before, instead of after,
the word mode."
(let ((description
- (cond ((and (symbolp word-mode)
- (get word-mode 'isearch-message-prefix))
- (get word-mode 'isearch-message-prefix))
- (word-mode "word ")
+ (cond ((and (symbolp regexp-function)
+ (get regexp-function 'isearch-message-prefix))
+ (get regexp-function 'isearch-message-prefix))
+ (regexp-function "word ")
(t ""))))
(if space-before
;; Move space from the end to the beginning.
(replace-regexp-in-string "\\(.*\\) \\'" " \\1" description)
description)))
+(define-obsolete-function-alias 'isearch--describe-word-mode
+ 'isearch--describe-regexp-mode "25.1")
(defun isearch-message-prefix (&optional ellipsis nonincremental)
;; If about to search, and previous search regexp was invalid,
(if np (setq prefix (concat np prefix)))))
isearch-filter-predicate)
prefix)
- (isearch--describe-word-mode isearch-word)
+ (isearch--describe-regexp-mode isearch-regexp-function)
(if isearch-regexp "regexp " "")
(cond
(multi-isearch-file-list "multi-file ")
(defun isearch-search-fun-default ()
"Return default functions to use for the search."
(cond
- (isearch-word
+ (isearch-regexp-function
(lambda (string &optional bound noerror count)
;; Use lax versions to not fail at the end of the word while
;; the user adds and removes characters in the search string
(car isearch-cmds))))))))
(funcall
(if isearch-forward #'re-search-forward #'re-search-backward)
- (if (functionp isearch-word)
- (funcall isearch-word string lax)
+ (if (functionp isearch-regexp-function)
+ (funcall isearch-regexp-function string lax)
(word-search-regexp string lax))
bound noerror count))))
((and isearch-regexp isearch-regexp-lax-whitespace
((and (not isearch-regexp)
(string-match "\\`Regular expression too big" isearch-error))
(cond
- (isearch-word
+ (isearch-regexp-function
(setq isearch-error "Too many words"))
((and isearch-lax-whitespace search-whitespace-regexp)
(setq isearch-error "Too many spaces for whitespace matching"))))))
;; - `isearch-string' is expected to contain the current search
;; string as entered by the user;
;; - the type of the current search is expected to be given by
-;; `isearch-word' and `isearch-regexp';
+;; `isearch-regexp-function' and `isearch-regexp';
;; - the direction of the current search is expected to be given by
;; `isearch-forward';
;; - the variable `isearch-error' is expected to be true
(defvar isearch-lazy-highlight-regexp nil)
(defvar isearch-lazy-highlight-lax-whitespace nil)
(defvar isearch-lazy-highlight-regexp-lax-whitespace nil)
-(defvar isearch-lazy-highlight-word nil)
+(defvar isearch-lazy-highlight-regexp-function nil)
+(define-obsolete-variable-alias 'isearch-lazy-highlight-word
+ 'isearch-lazy-highlight-regexp-function "25.1")
(defvar isearch-lazy-highlight-forward nil)
(defvar isearch-lazy-highlight-error nil)
isearch-case-fold-search))
(not (eq isearch-lazy-highlight-regexp
isearch-regexp))
- (not (eq isearch-lazy-highlight-word
- isearch-word))
+ (not (eq isearch-lazy-highlight-regexp-function
+ isearch-regexp-function))
(not (eq isearch-lazy-highlight-lax-whitespace
isearch-lax-whitespace))
(not (eq isearch-lazy-highlight-regexp-lax-whitespace
isearch-lazy-highlight-regexp isearch-regexp
isearch-lazy-highlight-lax-whitespace isearch-lax-whitespace
isearch-lazy-highlight-regexp-lax-whitespace isearch-regexp-lax-whitespace
- isearch-lazy-highlight-word isearch-word
+ isearch-lazy-highlight-regexp-function isearch-regexp-function
isearch-lazy-highlight-forward isearch-forward)
(unless (equal isearch-string "")
(setq isearch-lazy-highlight-timer
(condition-case nil
(let ((case-fold-search isearch-lazy-highlight-case-fold-search)
(isearch-regexp isearch-lazy-highlight-regexp)
- (isearch-word isearch-lazy-highlight-word)
+ (isearch-regexp-function isearch-lazy-highlight-regexp-function)
(isearch-lax-whitespace
isearch-lazy-highlight-lax-whitespace)
(isearch-regexp-lax-whitespace