3

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://stackoverflow.com/a/2338352/1001165, 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.

Community
  • 1
  • 1
Tim D
  • 1,645
  • 1
  • 25
  • 46
  • i'm pretty sure that is correct. after you start emacs, what is the value of the `frame-title-format` variable? – jtahlborn Mar 20 '12 at 14:34
  • 1
    frame-title-format is set to `(multiple-frames "%b" ("" invocation-name "@" system-name))`. – Tim D Mar 23 '12 at 14:39
  • The key is to find the right .emacs file. Not sure how it happened, by I had .emacs in two locations... – Tim D Mar 23 '12 at 14:55

4 Answers4

5

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 at [1]. Besides, if you are modifying any buffer, the " • " will show to indicate that you are modifying.

Hope to helped.

[1]. http://www.emacswiki.org/emacs/FrameTitle

ideasman42
  • 42,413
  • 44
  • 197
  • 320
NgaNguyenDuy
  • 1,306
  • 17
  • 13
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.

Ernest A
  • 7,526
  • 8
  • 34
  • 40
  • The underscore actually seems to be a DOS thing; at least, my Windows-based Emacs works fine with `~/.emacs`... – SamB Mar 23 '12 at 03:29
  • When I hit `C-J` in the scratch buffer as you suggested, another line is added: `"%b - emacs"` – Tim D Mar 23 '12 at 14:33
  • 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. :-( – Tim D Mar 23 '12 at 14:54
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.

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
frankieandshadow
  • 561
  • 6
  • 14
  • Unless the capital E in `Emacs` makes a difference, you are just pointing out the code I wrote into the original post. – Tim D Feb 24 '15 at 14:09
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
kindahero
  • 5,817
  • 3
  • 25
  • 32