I'm using denote, which produces quite long file names. E.g. 20230410T021830--title-i-gave-to-the-org-file__tag1_tag2_tab3_tag4.org. I also use tabs to navigate between buffers (mainly org files).

The issue is that denotes file names are so long that only one tab (or maximum 2 tabs) can be displayed on a window.

So I was wondering how it could be possible to change the tab name without changing the file name.

I use centaur-tab but the provided solution might refer to any other package (tabbar, moody, etc.)

  • emacs.stackexchange.com/questions/tagged/tabs
    – Drew
    Commented Apr 15, 2023 at 15:01
  • @Drew, thx for the tag edit. Though about the title edit, my question isn't limited to tabbar. It concerns any implementation of tabs in Emacs.
    – crocefisso
    Commented Apr 15, 2023 at 15:03
  • I think your question is about the tabbar, not TAB characters. If not, please clarify what you're asking. Browser-like tabs are completely different animals from TAB characters (aka Control-I chars).
    – Drew
    Commented Apr 15, 2023 at 16:08
  • Indeed my question is not about TAB characters (which is why you did well to remove the tabs tag. However, it is not limited to tabbar, which is an implementation of browser-like tabs in Emacs, there are other implementations.
    – crocefisso
    Commented Apr 15, 2023 at 16:20

4 Answers 4


Is there a way to specify names of tabs without changing the file names currently edited in this tabs?

What you see in the Tab Bar as tab labels text is usually the name of the currently edited buffer.

It is sure a bit confusing coincidence that the tab label text, the name of the buffer and the name of the in this buffer edited file are the same caused by the fact that the buffer name is set to the file name on loading a file into a buffer and the fact that the tab label text is set to the name of the current buffer.

An exception from this rule is when you explicit change the name of the tab using M-x tab-rename (which changes also the tabs explicit-name setting (explicit-name . t) to t . In this case the tab label will show always the name you set it to, no matter what buffer you are viewing in the tab.

Knowing this above you stop to worry that changing the tabs label text will also change the file name, because changing the text shown in the tab label has no impact on the edited file name.

To say it with your own words from your comment to your own answer:

The standard behavior is that tab names rely on buffer names, and buffer names rely on file names. Though tab names can be decorrelated from buffer names and buffer names from file names.

To summarize what is stated above you have two different options for changing the text shown as tabs label:

  1. changing the name of the buffer using M-x rename-buffer

  2. changing the name of the tab using M-x tab-rename

Changing the name of the buffer (1.) has the advantage that the tab keeps the ability to change its label when you choose to work on another buffer mirroring this change.

Changing the name of the tab (2.) has the advantage that you can specify a kind of grouping name for all the buffers you work on in this tab and the tab name won't change if you switch to editing another buffer.

To make the changes in the names to persist between Emacs sessions use (desktop-save-mode 1) in your Emacs initialization file.

In order to deepen your understanding of what is shown in the tab you can use: M-x eval-expression -> Eval : (assq 'explicit-name (tab-bar--current-tab)) to check the setting of the current tabs explicit-name which will be (explicit-name . t) with an explicit set and shown name or (explicit-name) otherwise.

P.S. Credits go to Maxim Kim for mentioning how to rename tabs in his answer.

  • See the updated answer which is now considering the Maxim Kim's answer.
    – oOosys
    Commented Apr 16, 2023 at 11:52

Am I missing something obvious? There is M-x tab-rename RET:

enter image description here

Furthermore, in Mastering Emacs there is a chapter about Tab based workflows that includes an interesting example about putting org-related buffers into a separate tab-group: https://www.masteringemacs.org/article/demystifying-emacs-window-manager

Search for Tab-Based Workflows there: enter image description here

  • Thanks for this answer. Currently, I use centaur-tabs, and tab-rename doesn't seem to have any effect on tabs. I will try to use tab-bar-mode to see how the solution you mentioned works.
    – crocefisso
    Commented Apr 16, 2023 at 7:59

Given a file named myfile.org, by default when myfile.org is open, myfile.org is displayed as its tab name.

It is because by default tab names inherit buffer names and buffer names inherit file names.

So if you want to have a tab called mytab while keeping myfile.org as its associated file name, you have two options:

  1. To change the buffer name associated with myfile.org (M-x rename-buffer RET mytab)
  2. To change the tab name associated with myfile.org (M-x tab-rename RET mytab)

The first option will work for any Emacs tab management implementation.

The second won't. For example, it will work with Tab Bar Mode, but not with centaur-tabs.

In both cases, mytab association to myfile.org will be lost when your Emacs session is over. So, when you restart Emacs, myfile.org tab name will be back to myfile.org.

Here is some code that will allow you to specify a tab name only once: With #+buffername: mytab in myfile.org's header, you'll have mytab as a tab name each time you open myfile.org.

This code is relatvie option 1, but you can replace rename-buffer by tab-rename in it if you prefer option 2 (also replace "buffername" by "tabname" to use #+tabname: mytab).

  • 1
    Nice to see that you have in between dissolved your confusion (as I have dissolved mine too). See my answer which tries to say just that.
    – oOosys
    Commented Apr 16, 2023 at 14:07
  • It seems that you don't need any programming to achieve what you are after if you save the desktop configuration and reload it on next Emacs start.
    – oOosys
    Commented Apr 16, 2023 at 14:08

Generally, you can specify the buffer name (and consequently the tab name) of a given org file by putting the following snippet at the bottom of this file:

* Local Variables :noexport:
# Local Variables:
# eval: (rename-buffer "foo")
# End:

Besides, the new optional denote-rename-buffer.el provides a minor mode to automatically rename the buffer of an existing file, such that it reflects the file’s TITLE field. Users must enable denote-rename-buffer-mode.

See Denote buffers can have shorter names and Automatically rename Denote buffers

Your Answer

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

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