1. I wonder if I can disable the 'failing overwrapped' warning in the minibuffer and directly wrap around instead if I do a search?

Does anyone know how to facilitate this?

  1. Also there is a slight delay in highlighting occurrences of the search-for expression, can I decrease this as well?

  2. Finally, how can I invoke custom function upon a key combination, only if Isearch is active?

Specifically, I want to invoke

  (defun contrib/isearchp-remove-failed-part-or-last-char ()
    "Remove failed part of search string, or last char if successful.
Do nothing if search string is empty to start with."
    (if (equal isearch-string "")
      (if isearch-success
        (while (isearch-fail-pos) (isearch-pop-state)))

if I hit <backspace> during Isearch.

  • You asked three questions here: (1) how to "disable 'failing overwrapped'", directly wrapping, (2) how to reduce the delay, and (3) *"how can I invoke...". Please remove two of them - move them to separate questions. Thx.
    – Drew
    Commented Oct 7, 2019 at 17:34
  • And after removing 2 of the questions, please edit the question title, to make it specific.
    – Drew
    Commented Oct 7, 2019 at 17:37

1 Answer 1


For quick direction change and wrap around you can use the following:

(defun isearch-repeat-forward+ ()
  (unless isearch-forward
    (goto-char isearch-other-end))
  (unless isearch-success

(defun isearch-repeat-backward+ ()
  (when (and isearch-forward isearch-other-end)
    (goto-char isearch-other-end))
  (unless isearch-success

(define-key isearch-mode-map (kbd "C-s") 'isearch-repeat-forward+)
(define-key isearch-mode-map (kbd "C-r") 'isearch-repeat-backward+)

By binding the keys in isearch-mode-map those bindings are only used when isearch is active, you can do the same with your contrib/isearchp-remove-failed-part-or-last-char command.

As for the delay question, you need to search for the variable for this setting. You can use apropos-user-option, apropos-documentation or just describe-variable (+ maybe using a completion framework of your choice) to find isearch-lazy-highlight-initial-delay which is obsoleted by lazy-highlight-initial-delay (as you can read in the docstring).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.