diff --git a/ha-config.org b/ha-config.org index 5f08af0..cb6038a 100644 --- a/ha-config.org +++ b/ha-config.org @@ -1119,22 +1119,59 @@ 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). +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, but since I need the portability of Unicode for Linux, I may need to synthesize both). + +#+BEGIN_SRC emacs-lisp + (defface ha/tab-bar-numbers + (if (ha-running-on-macos?) + '((t + :inherit tab-bar-tab-face + :family "SF Compact" + :weight light)) + ;; On Linux, we use the dingbat unicode with default font: + '((t + :inherit tab-bar-tab-face + :weight light))) + "Face for tab numbers in both active and inactive tabs.") +#+END_SRC 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 . "βž’")) + (if (ha-running-on-macos?) + '((0 . "τ€ƒˆ") + (1 . "τ€ƒŠ") + (2 . "τ€ƒŒ") + (3 . "τ€ƒŽ") + (4 . "τ€˜™") + (5 . "τ€ƒ’") + (6 . "τ€‘΅") + (7 . "τ€ƒ–") + (8 . "τ€ƒ˜") + (9 . "τ€‘·") + (10 . "τ€ƒˆ")) + ;; Keeping these around for the Mac just in case. + ;; '((0 . "β“Ώ") + ;; (1 . "❢") + ;; (2 . "❷") + ;; (3 . "❸") + ;; (4 . "❹") + ;; (5 . "❺") + ;; (6 . "❻") + ;; (7 . "❼") + ;; (8 . "❽") + ;; (9 . "❾")) + '((0 . "πŸ„Œ") + (1 . "➊") + (2 . "βž‹") + (3 . "➌") + (4 . "➍") + (5 . "➎") + (6 . "➏") + (7 . "➐") + (8 . "βž‘") + (9 . "βž’"))) "Alist of integers to strings of circled unicode numbers.") #+END_SRC @@ -1142,6 +1179,8 @@ And then use this function to replace the standard =tab-bar-tab-name-format-fun #+BEGIN_SRC emacs-lisp (defun ha/tab-bar-tab-name-format-default (tab i) + "Replacement for `tab-bar-tab-name-format-function'. + Places a special symbol for the initial digit." (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) ""))) @@ -1157,6 +1196,28 @@ And then use this function to replace the standard =tab-bar-tab-name-format-fun " ") 'face (funcall tab-bar-tab-face-function tab)))) + (defun ha/tab-bar-tab-name-format-default (tab i) + "Replacement for `tab-bar-tab-name-format-function'. + Places a special symbol for the initial digit." + (let ((current-p (eq (car tab) 'current-tab))) + (concat + ;; First, add the tab number with a custom face + (propertize + (if (and tab-bar-tab-hints (< i 10)) (alist-get i ha/circle-numbers-alist) "") + 'face 'ha/tab-bar-numbers) + ;; Add tab name with the face returned by tab-bar-tab-face-function + (propertize + (concat + " " ; Add initial space + (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 diff --git a/ha-theme.org b/ha-theme.org index 3bf1d75..f2bda06 100644 --- a/ha-theme.org +++ b/ha-theme.org @@ -311,7 +311,6 @@ Can we *see* our colors? #+END_SRC * Dark Theme - Let’s make a /theme/: #+BEGIN_SRC emacs-lisp @@ -334,7 +333,7 @@ Let’s make a /theme/: `(tab-bar ((t :foreground ,default-fg :background ,default-bg))) `(tab-line ((t :foreground ,default-fg :background ,default-bg))) `(tab-bar-tab ((t (:inherit variable-pitch :background ,active)))) - `(tab-bar-tab-inactive ((t (:inherit variable-pitch :background ,inactive)))) + `(tab-bar-tab-inactive ((t (:inherit variable-pitch :background ,default-bg)))) `(doom-modeline-buffer-path ((t (:foreground ,almond)))) `(doom-modeline-buffer-file ((t (:foreground "white" :weight bold)))) @@ -457,7 +456,24 @@ Let’s make a /theme/: `(elfeed-search-tag-face ((t (:foreground ,slate)))))) #+END_SRC + [[file:ha-theme-results.png]] + +To update a feature live with all attributes, do something like: + +#+BEGIN_SRC emacs-lisp :tangle no + (set-face-attribute 'tab-bar-tab-inactive nil + :inherit variable-pitch + :background "#462200") +#+END_SRC + +Or, you can use the helper functions to change a feature directly: + +#+BEGIN_SRC emacs-lisp :tangle no + (set-face-background 'tab-bar-tab-inactive "#462200") +#+END_SRC + + * Technical Artifacts :noexport: Let's =provide= a name so we can =require= this file: