-1

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.

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

#'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")
t
1
  • I didn't notice I had princ in front of my format. Looks like I need a break. – ruby_object Dec 28 '16 at 23:59

Your Answer

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

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