4

When I am using incremental search, a backspace erases the character from the matched string in the buffer, instead of erasing the character from the search string I am typing. I saw that this is not the case with another emacs user... is there something I have messed up that is causing this issue?

I did rebind my backspace and delete keys, just to be consistent across terminals/keyboards:

;; Lock DEL and backspace key behavior
(global-set-key (kbd "<delete>") 'delete-char)
(global-set-key (kbd "<backspace>") 'delete-backward-char)

Any suggestions?

FYI, I generally correct my search string using M-e <

Juancho
  • 5,455
  • 16
  • 20
deejay
  • 193
  • 7

1 Answers1

5

You'll want to change

(global-set-key (kbd "<backspace>") 'delete-backward-char)

either to

(global-set-key (kbd "DEL") 'delete-backward-char)

or to nothing at all. The definition you use prevents Emacs from remapping backspace to DEL, and the Isearch behavior you want is bound to DEL.

Stefan
  • 26,404
  • 3
  • 48
  • 85
  • That's going to fail on terminals where Backspace sends ^H and Delete sends ^?. Granted this isn't common anymore. – Gilles 'SO- stop being evil' Dec 12 '14 at 21:41
  • 1
    @Gilles: This is another issue, solved with normal-erase-is-backspace-mode. – Stefan Dec 12 '14 at 21:44
  • @Stefan Thanks... I'll try. But I couldn't understand... why such a confusion between DEL and bksp keys? Shouldn't the behavior be consistent across modes? – deejay Dec 17 '14 at 07:03
  • @Stefan: Okay... It's fixed now! Thanks for the solution! However, using any of the arrow keys in a search string still makes cursor movements on the matched string... any way to sort this out? It could be useful in cases where my correction lies some characters before my current position... – deejay Dec 17 '14 at 07:06
  • Removing (global-set-key (kbd "<backspace>") 'delete-backward-char) worked. Kept the DEL key binding because DEL was behaving funny otherwise. – deejay Dec 17 '14 at 12:25
  • If you want to use cursor keys to to more complex editing than just removing the last char, then use M-e which will temporarily suspend Isearch and put you in a normal minibuffer where you can use all the usual editing commands, except for C-s which will jump you right back to the Isearch. – Stefan Dec 17 '14 at 13:43