Groups | Search | Server Info | Login | Register
| From | Mekeor Melire <mekeor@posteo.de> |
|---|---|
| Newsgroups | comp.emacs |
| Subject | How to teach Emacs to update tab-bar instead of mode-line? |
| Date | 2025-09-23 00:27 +0200 |
| Organization | MB-NET.NET for Open-News-Network e.V. |
| Message-ID | <87ecrynmwh.fsf@posteo.de> (permalink) |
Hello!
I'm experimenting with replacing the mode-line with a more
informative tab-bar. The tab-bar would show the tabs on the
right. The title of each tab would be the name of the (most
recently) selected window's buffer. (I.e. it's not possible to see
the name of a displayed buffer until you select its window! This
is a major disadvantage.) On the left, the tab-bar would show the
information that the mode-line shows by default - except for the
buffer-name.
My code (below) mostly works but the buffer position (as in
mode-line-position) is not updated when point is moved. How can I
tell Emacs to update the tab-bar whenever it would update the
mode-line? (Note that many tab-bar functions call
(force-mode-line-update).)
You can test following code with `emacs -Q -l path/to/file.el`. It
might require version 30 of Emacs.
--8<---------------cut here---------------start------------->8---
;; -*- lexical-binding: t; -*-
;;;; Optional
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
;;;; MODE LINE
(setopt mode-line-format
nil)
;;;; TAB BAR
(require 'tab-bar)
(defun tab-bar-left ()
"Format input method, window dedication, buffer position, readonly, view."
(format-mode-line
'(""
(current-input-method-title (" " current-input-method-title))
(:eval (cond ((eq (window-dedicated-p) t) " D")
((window-dedicated-p) " d")
(t "")))
(:eval (when (derived-mode-p '( bibtex-mode conf-mode
pdf-view-mode prog-mode
text-mode))
'(""
mode-line-position
(buffer-read-only " read")
(view-mode " view")))))))
(defun tab-bar-right ()
"Format minibuffer depth."
(format-mode-line
'(:eval (when-let* ((d (minibuffer-depth)) ((< 0 d)))
(format "%s " d)))))
(setopt tab-bar-format
'( tab-bar-left
tab-bar-format-align-right
tab-bar-format-tabs
tab-bar-separator
tab-bar-right))
(setopt tab-bar-auto-width nil)
(setopt tab-bar-close-button-show nil)
(setopt tab-bar-history-mode t)
(setopt tab-bar-separator " │ ")
(setopt tab-bar-show t)
--8<---------------cut here---------------end--------------->8---
Back to comp.emacs | Previous | Next | Find similar
How to teach Emacs to update tab-bar instead of mode-line? Mekeor Melire <mekeor@posteo.de> - 2025-09-23 00:27 +0200
csiph-web