Context. I frequently use

  1. org-mode timers
  2. The org-mode clock (which just displays the clock in the org-mode mode-line)
  3. A custom "target time" clock, which shows a point in time (either a few minutes or a few hours from now) that I'm trying to get something done by

Here's the way it looks now as an example:

12:40PM 0.57 is the current time, <0:00:42> is the active timer, and 12:48PM is the "target time" I'm trying to get my current task done by.

Problem. This mode-line disappears or gets mangled all of the time (particularly, I think, when I switch buffers around?). I would like it to be displayed universally no matter which emacs buffer I'm in. I've tried setting

(setq global-mode-string '("" display-time-string org-mode-line-string org-timer-mode-line-string " " est-target))  

where est-target is my "target time" (as described in (3)), but it doesn't always work (even when I bind it to key and press it on the current buffer).

Does anyone know how to lock this mode-line in place?

1 Answer 1


You can set the mode line to be fixed with

(setq-default mode-line-format "FOO")

It will always show "FOO" and nothing else.

I assume that if you do

(setq-default mode-line-format  '("" display-time-string org-mode-line-string org-timer-mode-line-string " " est-target))

and enable things appropriately (e.g. you have to call (display-time) to have display-time-string show anything) you will get what you want.

BUT: the mode line contains all sorts of useful information that you would lose this way.

There is another possibility and that is the header line: it is used occasionally, but not nearly as much as the mode line, so it should be safer to muck around with it. Basically do the same thing but with header-line-format:

(setq-default header-line-format '("" display-time-string org-mode-line-string org-timer-mode-line-string " " est-target))

Maybe that will not be interfered with as much.

Note BTW, that both mode-line-format and header-line-format become buffer-local when set, so using setq only sets the buffer-local-variable. setq-default sets the global value, which is used to initialize the buffer-local variable. Modifying the buffer-local variable by adding things to it but not clobbering it completely should then behave more or less as you expect.

But I have not tested any of this to any extent, so no guarantees: if it breaks, you get to keep the pieces. I would experiment on a session of emacs created for the purpose, not on my main session.

  • This gets me some progress. I'm actualy using Spacemacs, and it turns out that editing header-line in this way messes heavily with the way Spacemacs computes the mode-line.
    – George
    Feb 8, 2021 at 22:43
  • As I said: you get to keep the pieces :-) I don't know anything aout Spacemacs.
    – NickD
    Feb 8, 2021 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.