Discussion:
Buffer name variable
(too old to reply)
Stefano
2007-04-09 19:43:50 UTC
Permalink
Hi!
Is there a variable which holds the buffer name in GNU emacs? I know,
seems a terribly basic question... but I haven't been able to find it.
If there is one, I'd like to set it in the last lines of the file with
a ";; Local Variables"-like line. For now, I'm using the line "''
eval: (rename-buffer "foo")", but setting a variable would be more
"clean" and would avoid using "eval", which triggers a security alert
on most systems.
Thanks in advance.
Stefano
steve gonedes
2021-04-25 15:43:17 UTC
Permalink
Post by Stefano
Hi!
Is there a variable which holds the buffer name in GNU emacs?
There are some functions.

(current-buffer) => returns buffer device
(buffer-name) => the name of buffer as a string.
(buffer-name (current-buffer)) => the name of the current buffer.

and
buffer-file-name => the filename of current buffer.


If you really want to dig in; the emacs lisp manual has all this and
more under the buffer section in the info pages.
Post by Stefano
I know,
seems a terribly basic question... but I haven't been able to find it.
If there is one, I'd like to set it in the last lines of the file with
a ";; Local Variables"-like line. For now, I'm using the line "''
eval: (rename-buffer "foo")", but setting a variable would be more
"clean" and would avoid using "eval", which triggers a security alert
on most systems.
Thanks in advance.
Stefano
have you tried get-buffer-create. There is a way to do what you want,
but it is some elisp code... I don't have it on this machine. let me
know I'll dig it up.

You could set a variable in your dot-emacs or use a hook. you do not
need to use eval in the local variables line. like i said it's on the
other machine...

Loading...