Skip to main content
2 of 2
Typo fixes
NickD
  • 33.6k
  • 3
  • 30
  • 47

First, in general, Isearch uses the minibuffer only for M-e. So your minibuffer-local-isearch-map key binding is useless here. That's the keymap used when editing after M-e.

Second, your isearch-mode-map binding means that C-h ends up deleting the char in the buffer you're searching, not deleting a char from the search string. The current buffer remains the buffer you're searching.

This is what you need to do. It defines a command that pops the last char off of the end of the search string.

(defun foo ()
  "Delete last char of the search string."
  (interactive)
  (unless (equal isearch-string "") (isearch-pop-state))
  (isearch-update))

(define-key isearch-mode-map (kbd "C-h") 'foo)
Drew
  • 79.1k
  • 10
  • 123
  • 257