By default, when using a PC keyboard attached to a Mac, OS X treats presses of the Insert
key as presses of the Help
key that appears on the extended Mac keyboard.
How do I map that keypress to have the same result in GNU Emacs that it does when running in, say, Windows or Linux: toggling overwrite-mode
on and off? (https://www.gnu.org/software/emacs/manual/html_node/efaq/Overwrite-mode.html)
In a GUI window, Emacs treats Insert
presses as Help
key presses and shows the help, which is logical. Googling, I can't find anywhere that discusses remapping the Help
key.
In OS X's Terminal.app, as far as I can tell, the key presses aren't passed to the terminal itself at all. At a Bash prompt, Ctrl-v Insert
results in no output. Pressing another key behaves as if typing Ctrl-v <key>
with no intervening press of Insert
.
EDIT: I've gotten closer. I think.
I used Karabiner [1] to map Insert
to something more useful than Help
, since Terminal.app doesn't see Help
. I picked F13
.
[1] pqrs.org/osx/karabiner/
<item>
<name>Map Insert to F13</name>
<identifier>private.map_insert_to_f13</identifier>
<autogen>__KeyToKey__ KeyCode::PC_INSERT, KeyCode::F13</autogen>
</item>
Ctrl+v Insert
in Bash then shows ^[[25~
.
Taking inspiration from http://www.emacswiki.org/emacs/LinuxConsoleKeys I added the following to my .emacs:
(define-key input-decode-map "\e[25~" [(f13)])
(define-key key-translation-map (kbd "<f13>") (kbd "<Insert>"))
Now pressing Insert
once doesn't do anything. Pressing it twice shows
<f1> <Insert> is undefined.
Pressing Insert Down
shows
<f1> <down> is undefined.
I don't know where to go from here.