Windows 10, Emacs 25.1.

Suppose I open file D:/temp/test/myfile.txt. But in the in the mode line show only file name (myfile.txt).

But I need to show FULL path to file: D:/temp/test/myfile.txt

This path can show on mode line OR in the frame title. How I can do this?


The function (buffer-file-name) returns full path of the file you are visiting.

To use in frame title:

    (setq frame-title-format
          '("" invocation-name ": "
             (if (buffer-file-name)
                 (abbreviate-file-name (buffer-file-name))

To use it in the mode-line you can do the same, but for mode-line-format variable. If you need more help see C-h v mode-line-format

You can also use %f, like (setq-default frame-title-format "%b (%f)")

For a more thorough explanation see here and here

  • +1 for mentioning C-h v mode-line-format. I would only add that that same docstring explains the meaning of identifiers like %b, %f, and many more, which apply to both mode-line-format and frame-title-format. From C-h v frame-title-format: This variable has the same structure as ‘mode-line-format’, except that the %c, %C, and %l constructs are ignored. It is used only on frames for which no explicit name has been set (see ‘modify-frame-parameters’). – Kaushal Modi Jun 8 '17 at 16:52

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.