Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I find out the name of the current buffer, window, or frame in Emacs?

share|improve this question
up vote 3 down vote accepted

If you need that in a script, evaluate:

(frame-parameter nil 'name)
share|improve this answer
This always returns "F1", no matter which buffer I am in. – Zubair Dec 2 '10 at 6:50
Strange, it works for me, it behaves exactly like (buffer-name) (+1 for that). – cYrus Dec 2 '10 at 14:40
I'm on GNU 23.2, It may be Emacsen version dependent whether frame-parameter works or not? – Zubair Dec 2 '10 at 15:36
Same version here: GNU Emacs 23.2.1 on Debian Linux. But (frame-parameter nil 'name) returns the name of the frame (the one you see in the task bar of your desktop environment, for example) that can be changed. For the buffer name, you should use (buffer-name). – cYrus Dec 2 '10 at 16:16

C-x C-b (list-buffers) will display a list of buffers. The current buffer has a . to the left of its name. I believe windows and frames do not have names, so there is nothing to find out there.

share|improve this answer

I have since found out that (buffer-name) from within an elisp script will return the name of the current buffer

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .