ema2159 / centaur-tabs

Emacs plugin aiming to become an aesthetic, modern looking tabs plugin
GNU General Public License v3.0
727 stars 50 forks source link

[feature request] Specify tab names #204

Open morgandavidson opened 1 year ago

morgandavidson commented 1 year ago

I have been using centaur-tabs for some time and have been quite happy with it. Thanks for providing this great package. Recently I started using denote, which is also a great package. Denote has the particularity of being based on an efficient file-naming scheme that produces long names, e.g.: 20230331T093543--name-of-the-org-file__firsttag_secondtag_thirdtag_fourthtag.org

So now that I use it I can only see one tab (max 2) on my Emacs window.

Hopefully, centaur-tabs-label-fixed-length can reduce file names. But applied to denote files, it makes the tab name unreadable. For example, with the value 9, the tab will show "20230331".

Would it be possible to have a centaur-tabs command allowing to change the name of a tab? That is only changing the tab name and keeping the file name and the buffer name unchanged. Like Tab Bars does with tab-rename.

Then some code could be used to specify tab names. e.g. specifying tab names with #+tabname::

(defun org-get-kw-value (kw)
  "Get the value of keyword KW."
  (save-excursion
    (goto-char (point-min))
    (let ((case-fold-search t))
      (re-search-forward (format "^#\\+%s:\\(.+\\)" kw) nil t)
      (when-let (kwval (match-string-no-properties 1))
        (string-trim kwval)))))

(defun my-org-hook-function ()
  "If keyword TABNAME exists, set tab-rename to its value."
  (when-let (new-tab-name (org-get-kw-value "tabname"))
    (tab-rename new-tab-name)))

(add-hook 'org-mode-hook #'my-org-hook-function)