4

my emacs' version: GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9) of 2014-05-21 on buildvm-07.phx2.fedoraproject.org

I hope Emacs's title display the absolute path of the current file. I wrote the following contents (from internet):

;;;Emacs title bar to reflect file name
(defun frame-title-string ()
   "Return the file name of current buffer, using ~ if under home directory"
(let
  ((fname (or
             (buffer-file-name (current-buffer))
             (buffer-name))))
 ;;let body
  (when (string-match (getenv "HOME") fname)
    (setq fname (replace-match "~" t t fname))        )
  fname))

 ;;; Title = 'system-name File: foo.bar'
(setq frame-title-format '("" system-name "  File: "(:eval (frame-title-string))))

before reinstalling FC20 + Emacs, the above content was able to work correctly. Now it does not work except that I open .emacs and eval frame-title-format manually, I do not know why I must manually eval it?

6
  • If the code works when you evaluate it manually, the problem is most likely located elsewhere. Do you get an error when you start Emacs? Is there other code in your init file that could cause this etc? A good way to find the problem is to cut down your init file to a bare minimum. If it works, then extended it until the problem reappears, that way you could narrow down the problem. Sep 1, 2014 at 11:36
  • there is no any error when starting Emacs. For excluding the impact of the other code, my .emacs only has the above code now, but I got the same result. Sep 1, 2014 at 13:17
  • Are you sure the init file is read? (You could add (message "I'm here") to it and check the *Messages* buffer afterwards. Also, there might be a system init file installed on the system that overrides your setting? Sep 1, 2014 at 14:05
  • yes, I added (message "come here here here") after (setq frame-title-format ...) and it was appeared in *Messages*. Now I want to force eval (setq frame-title-format ...) in .emacs, what should I do? Thanks Sep 1, 2014 at 14:20
  • 1
    I have not found why it has not works, but this answer works! Sep 1, 2014 at 14:58

4 Answers 4

1

I was affected by the same problem. On CentOS 7 and Fedora 21 systems, I found that /usr/share/emacs/site-lisp/default.el overrides frame-title-format (and nothing else). Presumably Fedora 20 has the same issue. The same file contains instructions for disabling this ("Setting inhibit-default-init non-nil in ~/.emacs") which worked for me.

The answer that @abelard20008 refers to does the same thing.

1

Having the same issue after upgrading to GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-12-07

The solution was to set icon-title-format too.

;; No hostname in frame title
;; Without setting the `icon-title-format`. The window title will revert
;; back to its original value after loosing its focus.
(setq frame-title-format '("" invocation-name " - " "%b"))
(setq icon-title-format '("" invocation-name " - " "%b"))

Credit: https://stackoverflow.com/a/17532502/6000005

0

Sounds some other code you are loading is setting the frame name. Note from the doc string of frame-title-format:

It is used only on frames for which no explicit name has been set (see `modify-frame-parameters').

To find the code that does this, bisect your init file recursively.

0

I solved it by adding this to my .emacs:

(add-hook 'after-init-hook (lambda ()
                 (setq frame-title-format "%b")
))

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.