Gnu emacs window title default
Asked Answered
S

4

5

I'm using Gnu emacs in Windows XP, and the default window title reads "emacs@ACH1797VM2" rather than the buffer title, which is what I want and which is the correct default behavior, as far as I know.

After reading https://mcmap.net/q/1053353/-change-x11-window-title-after-emacs-started, I put the following line at the end of my ~/.emacs file, but there's no change in the behavior.

(setq frame-title-format "%b - emacs")

I can change the window title just fine with

M-x set-frame-name NewName RET

but I want it to change automatically to match the buffer name.

Seafaring answered 20/3, 2012 at 14:2 Comment(3)
i'm pretty sure that is correct. after you start emacs, what is the value of the frame-title-format variable?Singlephase
frame-title-format is set to (multiple-frames "%b" ("" invocation-name "@" system-name)).Seafaring
The key is to find the right .emacs file. Not sure how it happened, by I had .emacs in two locations...Seafaring
C
4

I'd say the line is correct. You can copy & paste the expression into the *scratch* buffer and hit C-J. If the window title changes, then it should change too when you add the line in your .init.el. There's also the possibility that your init file is not in the right place or it's not named correctly... if I recall correctly in Windows it doesn't start with a dot, but with an underscore.

Continually answered 20/3, 2012 at 22:42 Comment(3)
The underscore actually seems to be a DOS thing; at least, my Windows-based Emacs works fine with ~/.emacs...Catwalk
When I hit C-J in the scratch buffer as you suggested, another line is added: "%b - emacs"Seafaring
Thanks for your help. I got it figured out. The problem was that there are two locations for HOME, and I modified the wrong .emacs file. :-(Seafaring
G
6

You can try this, add to your .emacs:

(setq frame-title-format
      '((:eval (if (buffer-file-name)
                   (abbreviate-file-name (buffer-file-name))
                 "%b"))
        (:eval (if (buffer-modified-p)
                   " •"))
        " Emacs")
      )

%b -- print buffer name . You can see more options here. Besides, if you are modifying any buffer, the " • " will show to indicate that you are modifying and that there are unsaved changes.

Hope to helped.

Grand answered 14/10, 2015 at 21:23 Comment(0)
C
4

I'd say the line is correct. You can copy & paste the expression into the *scratch* buffer and hit C-J. If the window title changes, then it should change too when you add the line in your .init.el. There's also the possibility that your init file is not in the right place or it's not named correctly... if I recall correctly in Windows it doesn't start with a dot, but with an underscore.

Continually answered 20/3, 2012 at 22:42 Comment(3)
The underscore actually seems to be a DOS thing; at least, my Windows-based Emacs works fine with ~/.emacs...Catwalk
When I hit C-J in the scratch buffer as you suggested, another line is added: "%b - emacs"Seafaring
Thanks for your help. I got it figured out. The problem was that there are two locations for HOME, and I modified the wrong .emacs file. :-(Seafaring
B
3

I rather think this means the title at the top of the window, not the bit in the grey bar inside Emacs. It's useful to change this so that you can distinguish between different windows when going Alt+TAB or in the task bar.

I found this, which works for me to show the name of the buffer in which the cursor is focused:

(setq frame-title-format "%b - Emacs")

Link.

Baltimore answered 23/2, 2015 at 11:26 Comment(1)
Unless the capital E in Emacs makes a difference, you are just pointing out the code I wrote into the original post.Seafaring
S
1

This is what lying around in my .emacs. not sure it has any effect.

(setq-default frame-title-format '(buffer-file-name "%f" "%b")) ; I already know this is Emacs
Spielman answered 21/3, 2012 at 2:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.