Search code examples
stringlistemacselisp

How to convert list to string in Emacs Lisp


How can I convert a list to string so I can call insert or message with it? I need to display c-offsets-alist but I got Wrong type argument: char-or-string-p for insert or Wrong type argument: stringp for message.


Solution

  • I am not sure of what you are trying to achieve, but format converts "stuff" to strings. For instance:

    (format "%s" your-list)
    

    will return a representation of your list. message uses format internally, so

    (message "%s" your-list)
    

    will print it. Alternatively, use %S instead of %s to print the list in Lisp syntax.