Subject: Re: bug#70139: [PATCH] Improve key-translate to support removing translations

From: Stefan Monnier <[email-masked]>
Date: Sun, 07 Apr 2024 10:45:28 -0400

> +            (lambda (form) (keymap--compile-check from (and to to)) form)))
                                                          ^^^^^^^^^^^
                                                          ??

>    (keymap--check from)
> -  (keymap--check to)
> -  (or (char-table-p keyboard-translate-table)
> -      (setq keyboard-translate-table
> -            (make-char-table 'keyboard-translate-table nil)))
> -  (aset keyboard-translate-table
> -        (aref (key-parse from) 0)
> -        (aref (key-parse to) 0)))
> +  (when to
> +    (keymap--check to))
> +  (let ((from-key (key-parse from))
> +        (to-key (and to (key-parse to))))
> +    (when (> (length from-key) 1)
> +      (error "FROM key %s is not a single key" from))
> +    (when (and to (> (length to-key) 1))
> +      (error "TO key %s is not a single key" to))

I'd check `=` while at it (if length is 0 the error is caught by
`aref`, but it's a less helpful error).

        Stefan