Using Unicode characters for the tab-bar mode

This commit is contained in:
Howard Abrams 2026-01-06 21:34:37 -08:00
parent ce83073865
commit bceca4ce0f

View file

@ -1118,6 +1118,48 @@ Any time I create or delete a new tab, we can call =ha-tab-bar-update-names=:
(add-hook desktop-after-read-hook #'ha-tab-bar-update-names)
#+END_SRC
*** Add Numbers ot Tab Bar Mode
Christian Tietze had a [[https://christiantietze.de/posts/2022/02/emacs-tab-bar-numbered-tabs/][great idea]] for making the tab-bar numbers more distinguished from the labels on the tabs (he has a [[https://christiantietze.de/posts/2022/12/sf-symbols-emacs-tab-numbers/][follow up essay]] about using a different font, Unicode is more portable and looks fine).
First, create a variable that contains the Unicode values for the numbers. I am using the negative versions of the circle numbers from the Unicode dingbats collection:
#+BEGIN_SRC emacs-lisp
(defvar ha/circle-numbers-alist
'((0 . "🄌")
(1 . "➊")
(2 . "➋")
(3 . "➌")
(4 . "➍")
(5 . "➎")
(6 . "➏")
(7 . "➐")
(8 . "➑")
(9 . "➒"))
"Alist of integers to strings of circled unicode numbers.")
#+END_SRC
And then use this function to replace the standard =tab-bar-tab-name-format-function=:
#+BEGIN_SRC emacs-lisp
(defun ha/tab-bar-tab-name-format-default (tab i)
(let ((current-p (eq (car tab) 'current-tab))
(tab-num (if (and tab-bar-tab-hints (< i 10))
(alist-get i ha/circle-numbers-alist) "")))
(propertize
(concat tab-num
" "
(alist-get 'name tab)
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
(if current-p 'non-selected 'selected)))
tab-bar-close-button)
"")
" ")
'face (funcall tab-bar-tab-face-function tab))))
(setq tab-bar-tab-name-format-function
#'ha/tab-bar-tab-name-format-default)
#+END_SRC
* Pretty Good Encryption
For details on using GnuPG in Emacs, see Mickey Petersens [[https://www.masteringemacs.org/article/keeping-secrets-in-emacs-gnupg-auth-sources][GnuPG Essay]].