In my cobbled-together init.el, my frame-title-format variable has these %-sequences in it: %%j and %%S

Does anyone recognize these specific sequences? They come up blank in my frame title. Here's the full variable def:

(setq frame-title-format
  (list (format "%s %%S: %%j " (system-name))
        '(buffer-file-name "%f" (dired-directory dired-directory "%b"))))

This evaluates to

("mySystemName %S: %j "
 (buffer-file-name "%f"
                    (dired-directory dired-directory "%b")))

and displays in my frame as, for example when visiting a help topic, as

mySystemName : *Help*
  • 2
    A single quote inhibits evaluation of what is inside the list that is quoted. See the section of the manual regarding the usage of a single quote versus a backtick and comma combination: gnu.org/software/emacs/manual/html_node/elisp/Backquote.html You may also wish to use the function list instead of a single quote ... – lawlist Jan 10 at 19:03
  • @Drew: no, his quoted list seems perfectly valid: it's not an Elisp expression to be evaluated but a mode-line-format expression where (SYM A B) uses A is SYM is non-nil and B otherwise. – Stefan Jan 10 at 21:51

First, the string is transformed by format. Looking at its Help, we discover that the instances of %% will be changed to a single %, so that we are left with %S and %j.

Now we look at the Help for frame-title-format:

This variable has the same structure as ‘mode-line-format’

So, clicking over to mode-line-format, we find the full list of %-constructs. I don't see %S or %j in this list, which must be why they appear blank.

  • Ok. I thought that might be the case, but since I saw this elisp used in several different init.el files. I wondered if I was missing some more advanced explanation. I've been digging through the Emacs source -- back to 2003, which is the earliest reference I could find that used this elisp -- to see if perhaps there was an %-construct that was removed. I haven't found either one mentioned in buffer.c. – mikekmcguire Jan 10 at 22:53
  • It's possible that these constructs are valid but not documented. I'm not able to dive into the C source to check this, as I didn't build my Emacs myself. Then again, if the constructs were valid, something would likely be showing up in the frame title... – M-Cat Jan 10 at 22:58
  • It looks like you used to use XEmacs, which allowed '%S' for the name of the frame. That didn't support '%j' though, as far as I can tell. – rpluim Jan 11 at 13:02

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.