Convert character to string in Elisp

How to convert character type to string in Emacs lisp?

I could not find the symbol-to-string function or something like that.

+54
string symbols elisp
Jan 10 2018-11-11T00:
source share
2 answers

Try using symbol-name :

 (symbol-name 'some-symbol) 
+66
Jan 10 2018-11-11T00:
source share

Given the name of the character (string), you can get the value of the character. Using Trey Jackson's solution:

 (setq ASymbol 10) => 10 (intern "ASymbol") => 'ASymbol (eg the unevaluated symbol with name "ASymbol") (symbol-value (intern "ASymbol")) => 10 

This is useful if you want to get character values ​​for which you only have names. For example, you read them from a string.

A few notes: intern returns the value of the character with the given name. If a symbol with that name does not exist, it creates a symbol with that name. You can use intern-soft to not enter a new character if the name with the specified name does not exist.

0
Jun 12 '17 at 14:48
source share



All Articles