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 <

2
  • 1
    Start emacs with emacs -q, evaluate that code snippet, and try again. Does it still happen?
    – Malabarba
    Dec 11, 2014 at 9:55
  • @Malabarba... Yup... So now I'm sure of what was messing my config... Thanks!
    – deejay
    Dec 17, 2014 at 7:01

1 Answer 1

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.

6
  • That's going to fail on terminals where Backspace sends ^H and Delete sends ^?. Granted this isn't common anymore. Dec 12, 2014 at 21:41
  • 1
    @Gilles: This is another issue, solved with normal-erase-is-backspace-mode.
    – Stefan
    Dec 12, 2014 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, 2014 at 7: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, 2014 at 7: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, 2014 at 12:25

Your Answer

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

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