This question already has an answer here:

I tried to get the value of desktop-dirname into the title of a frame:

(setq frame-title-format '("%b Desktop: "
                           (car (last (split-string desktop-dirname "/" t)))))

The (car ...) part evaluates just fine to "Something", but I don't see it in the frame title. I see only "buffer.el Desktop:" and I don't understand why. What's missing?

marked as duplicate by Drew, Stefan, Dan Jun 22 '17 at 22:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • BTW, rather than split-string+last, I'd use (file-name-nondirectory (directory-file-name desktop-dirname)). – Stefan Jun 22 '17 at 16:28
  • Thanks, Stefan. That's right what I wanted but didn't find because of my lack of elisp-knowledge... – Markus Jun 23 '17 at 6:35

You are passing a literal list as the second arg to setq. Instead, you want to substitute the value of the (car...) sexp.

You can do that using a backquote construction, telling it to evaluate that (car...) sexp and use the result of the evaluation.

You want this:

(setq frame-title-format   `("%b Desktop: "
                             ,(car (last (split-string desktop-dirname "/" t)))))

or (equivalently) this:

(setq frame-title-format  (list "%b Desktop: "
                                (car (last (split-string desktop-dirname "/" t)))))

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