I am trying to build a URL from several components, format function seems to do what I want. However, it prints the url instead of assigning it to a variable.

How do I do in Emacs equivalent of (format nil "String") from Common Lisp.

  • 2
    I'm voting to close this question as off-topic because it is based on a misunderstanding by the OP.
    – Drew
    Commented Dec 29, 2016 at 0:48

1 Answer 1


#'format actually returns the formatted value; it doesn't print it out. However, many ways of evaluating code do print the returned value -- e.g., #'eval-last-sexp.

Here's some code (run in ielm) that saves the result to a variable, then checks that variable:

ELISP> (setq myvar (format "some %s here" "text"))
"some text here"
ELISP> myvar
"some text here"
ELISP> (string-equal myvar "some text here")
  • I didn't notice I had princ in front of my format. Looks like I need a break. Commented Dec 28, 2016 at 23:59

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.