Webpresence of Philip Kaludercic

Emacs 28 has a global mode line

29 July, 2021

A complaint I have often heard raised amongst Emacs users is that the mode line can get cramped, quickly. Enable display-time-mode and perhaps rcirc-track-minor-mode, start compiling something and depending on your window configuration, you might not be able to see everything – and that despite information duplication! E.g. display-time-mode adds the current time to every mode line, even though there is no need for that.

One way to solve this, an idea that I head of a few times, was to add a “global mode line”. A bar at the top of an Emacs frame just for this kind of information that doesn’t belong to any specific buffer. There have been attempts at solving this, including hacking this information into the minibuffer, but nothing real – until now.

A few months ago1, support was added for just this kind of a functionality, to be released with the next version of Emacs (28.1). And all you need is this2:

(setc tab-bar-format '(tab-bar-format-global)
      tab-bar-mode t)

And it looks like this:

Emacs with a global mode line, with Modus Themes’s modus-themes-variable-pitch-ui option set to t

As indicated, it makes use of the tab-bar, a space added in 27.1 initially intended for tabs, that can just as well represent any string.

This is particularly useful for people who don’t use tabs, but if someone does, it is no problem either, one just has to adapt tab-bar-format (see it’s documentation string for more info).

As for Emacs 27.1/2 and earlier, one can try to hack together something like this:

(defun local/global-mode-line ()
  "Generate a global mode line."
  `(keymap (global . (menu-item
		      ,(format-mode-line global-mode-string)
		      ignore))))

(advice-add 'tab-bar-make-keymap-1 :override #'local/global-mode-line)

The functionality isn’t perfect, but it does some version of the job for now. Someone interested in this could try to improve it.

Either way, this is yet another much appreciated addition to the next release of Emacs, that I think many people will be looking forward to. My issue now is that I don’t even know what to do with all the space in the new global mode line.


  1. Implemented by Juri Linkov (commit), who is also the tab-bar.el author↩︎

  2. setc here is a macro that calls customize-set-variable↩︎