You can set the title of your Emacs window to the name of the file being edited. Add the following code to your .emacs file. Note, I run Emacs from within Cygwin where the HOME environment variable uses double backslashes as path separators, and the buffer-file-name uses slashes as path separators. The regular expression replacement below performs the conversion from backslashes to slashes.
(setq frame-title-format
'(:eval
(if buffer-file-name
(replace-regexp-in-string
(replace-regexp-in-string "\\\\" "/" (getenv "HOME")) "~"
(concat (file-name-directory buffer-file-name) "%b"))
(buffer-name)
)))
Try expand-file-name.
ReplyDeleteActually, I want the opposite of expand-file-name. The code displays ~/file instead of /home/user/file.
ReplyDelete