I want to string-join a list of strings, one of which is returned by a function call.

Like this:

(defun foobar () "foobar")
(string-join '("foo" (foobar) "bar") "|")

That results in Wrong type argument: characterp, foobar and not in "foo|foobar|bar" as expected.

What's the elegant way to do that?

  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Commented Jan 17, 2021 at 0:49
  • 1
    Does this answer your question? How to evaluate the variables before adding them to a list?
    – Drew
    Commented Jan 17, 2021 at 19:04
  • There are multiple questions that deal with the same thing: quoting some sexp and expecting some part of the quoted sexp to be evaluate. It would be great if Someone (TM) created a general Q & A for that, as a Community question. Many, many questions like this one have been closed as dups of the one I cited, but that Q is not stated in as general a way as it could be.
    – Drew
    Commented Jan 17, 2021 at 19:06

1 Answer 1


A quoted list doesn't evaluate its args, so it consists of a string, a list containing a symbol and another string. You can selectively evaluate it using backquote and unquote:

`("foo" ,(foobar) "bar") ;=> ("foo" "foobar" "bar")
(string-join `("foo" ,(foobar) "bar") "|") ;=> "foo|foobar|bar"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.