Given that the variable x contains the numeric representation of the key "Control-Z", say

(setq x ?\C-z), 

one may graphically represent its contents by issuing the command

(char-to-string x), 

producing the usual representation of "Control-Z", namely "^Z". I would like to acheive a similar effect in case x contained the numeric representation of "Meta-Z", namely

(setq x ?\M-z).

However my system represents "Meta-Z" as the number 134217850, and (char-to-string x) now causes the error (wrong-type-argument characterp 134217850). I am aware that the graphical representation of "Meta-Z" is not as standard as for "Control-Z", since the latter is part of the ASCII code while the former isn't, but anything legible, such as "M-Z" would be better than the big number 134217850.

My question is thus: which standard elisp function should I use in order to transform numerical representations of Meta characters into a legible string?

  • You could try (key-description [?\M-z]) (but it has to be a vector, not a single number). – wvxvw Nov 5 '17 at 13:43
  • @wvxvw, thanks very much! Should you decide to turn your comment into an answer, I'd be glad to accept it! – Ruy Nov 5 '17 at 17:27

Your Answer

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

Browse other questions tagged or ask your own question.