1

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?

Drew
  • 75,699
  • 9
  • 109
  • 225
Markus
  • 471
  • 2
  • 12
  • 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 06:35

1 Answers1

1

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)))))
Drew
  • 75,699
  • 9
  • 109
  • 225