I'm using iTerm2 and have my left option key set to +Esc. I can backwards delete words in bash with M-Del (option-Del) but in emacs, M-Del doesn't backwards delete words, it just changes the location of the cursor/point ~150 lines down in the text and then displays Mark set in the echo area.

Anyone know what's going on?

  • To what function is option-Del bound? Use C-h k to find out.
    – JeanPierre
    Feb 8 '17 at 17:40
  • When I type C-h k and then M-Del it says C-M-h runs the command mark-defun. This doesn't make sense to me, why is it registering the C and h keys when I'm pressing M-Del?
    – lsimmons
    Feb 8 '17 at 17:49
  • Sometimes a function may be bound to both C-M-<something> and M-<something>, but Emacs would translate M-<something> into C-M-<something> before calling the function. I have no idea though as to how Del can be translated into h. Could you by any chance load some init file which remaps keys? I.e. do you see the same behavior in emacs -q?
    – wvxvw
    Feb 8 '17 at 18:08
  • DEL and C-h are traditionally the same thing. In the ASCII character set, all the control characters are at the bottom of the character range, from 0 to 31. The control key on the keyboard just masked out the top 3 bits of the character you typed, leaving just a number from 0 to 31, allowing you to type any control character you wanted. Thus we use C-j for a line-feed and C-l for a form-feed and so on. Technically on modern computers you can distinguish between DEL and C-h, but Emacs predates that.
    – db48x
    Feb 8 '17 at 18:56
  • @db48x This 3 bits masking stuff is interesting. Could you provide some link documenting that? (not an emacs question anyway).
    – JeanPierre
    Feb 8 '17 at 20:33

The issue was in my iTerm2 settings. I had the Option - Delete mapped to send certain hex codes in the "Keys" tab in settings. NB, there are key mapping settings in the "Keys" and "Profiles" tabs in settings, so you could have key mappings in either place doing something with unintended effects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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