Subject: Re: bug#4709: 23.1; keyboard-translate not working with emacs daemon

From: Stefan Monnier <[email-masked]>
Date: Thu, 15 Oct 2009 16:28:01 -0400

> | [. . . keyboard-translate is an obsolete feature . . .]
> OK.

Actually, it hasn't been declared obsolete.  But the typical uses for it
(to work around `backspace' sending a C-h) are.  I've already several
times been tempted to declare it obsolete, but haven't resolved myself
to it yet.

> The answer was surprising to me:
>   C-d (translated from <delete>) runs the command delete-char, which is
>   an interactive built-in function in `C source code'.
>   It is bound to <deletechar>, C-d.
> I don't know who translates my "delete" to C-d.  But, I've just
> found that it does what C-d does.

It's done via function-key-map by normal-erase-is-backspace-mode.

> I've also found that my BACKSPACE key seems to be what Emacs
> calls DEL:
>   DEL (translated from <backspace>) runs the command
>   backward-delete-char-untabify, which is an interactive compiled Lisp
>   function.
>   It is bound to DEL.
> (By the way, I obtained these results on "/usr/bin/emacs23 -q", so
>  they are not affected by my ~/.emacs .)

Yes, these results look just fine to me.

> | The invocation below:
> |    (define-key key-translation-map [?\C-h] [?\C-?])
> | should do the trick.
> Thank you very much for finding that out!  That's much
> better than keyboard-translate:

Other than the fact that it works globally, I'm not sure that it is
better, but it should hopefully work about as well.

> As you can see, the emacs daemon seems to ignore it
> in your ~/.emacs and you still have to manually
> evaluate it on an emacsclient.

That doesn't sound right.  Can you check that the relevant code from
your .emacs is indeed executed?  E.g. add a (message "I'm here") and/or
a (setq my-test 'passed) right after the define-key.

        Stefan