Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show path to file in the Emacs mode-line?

Tags:

emacs

elisp

In the mode-line appears the name of the buffer I am working with (argf.rb):

enter image description here

For a buffer visiting a file, is it possible to display the absolute file name (i.e., include the path)?

like image 456
SuperManEver Avatar asked Apr 23 '15 07:04

SuperManEver


1 Answers

First, what you see is buffer name, not file name. Try to open two files with the same names (in different directories) and see what I mean.

Second, yes, I am sure it is possible - just customize mode-line-format.

Third, it might not be such a great idea - the mode line is already quite crowded and the long path will just not fit. I know it sounds great now, but you will hate it the next day.

Instead, put the path into the title bar:

(setq frame-title-format
      '(buffer-file-name "%b - %f" ; File buffer
        (dired-directory dired-directory ; Dired buffer
         (revert-buffer-function "%b" ; Buffer Menu
          ("%b - Dir: " default-directory))))) ; Plain buffer
like image 194
sds Avatar answered Nov 09 '22 13:11

sds