I would like to append some information (that changes over time) to the mode line format and then use it in the title.

My thought being is that once a minute I would set the frame-title-format to be that of the mode-line-format + pomodoro count.

Something along the lines of:

(defun runOnceAMinute ()
   (setq frame-title-format (concat mode-line-format my/PomodoroCount))

But I can't quite figure out how.

I would need to update the string that I append. E.g the pomodoro-count would increment after each pomodoro.

I got it to work by editing mode-line-format variable and using the eval construct:

("%e" ......... "[Pomodorors: " (:eval (number-to-string my/pomCount)) "]") 

This is not Drew's original answer, but Drew mentioned it in his comment.

  • 1
    mode-line-format has been simplified in recent years to (more or less) just a smallish list of other variables; so you would typically modify one of those child variables (or some further descendant), rather than mode-line-format itself. See C-h v mode-line-format, and then similarly C-h v for any of the component variables you want to learn about.
    – phils
    Jul 9, 2015 at 23:13
  • That's pretty close to what I want. I edited the mode line: (..... "HI" ) and this shows up. But if I want to print an integer, it doesn't show up? (.... (number-to-string my/count)) any ideas why? Jul 13, 2015 at 15:55
  • 1
    Read C-h v mode-line-format carefully: it describes the behaviour of the various different constructs that you can use, and it's a bit complicated. For more details, see the manual: C-h i g (elisp) Mode Line Format
    – phils
    Jul 13, 2015 at 22:10
  • I read the docu, but can't seem to make sense of how to append an integer to the list? Jul 13, 2015 at 22:15
  • I use doom-modeline,add pomodoro segment like this: (defun my-eval-string (string) "Evaluate elisp code stored in a string." (eval (car (read-from-string string)))) ;; pomodoro (doom-modeline-def-segment pomodoro "pomodoro segment" (my-eval-string "pomodoro-mode-line-string")) Dec 20, 2018 at 7:41

2 Answers 2


Append it to global-mode-string. If your mode-line format string to append is my-string then:

(setq global-mode-string
      (cond ((consp global-mode-string)
             (add-to-list 'global-mode-string my-string 'APPEND))
            ((not global-mode-string)
             (list my-string))
            ((stringp global-mode-string)
             (list global-mode-string my-string))))

[If you instead wanted to prepend it to global-mode-string then you would remove the 'APPEND optional argument and reverse the order of the last list: (list my-string global-mode-string).]

  • FWIW, nowadays there's also mode-line-misc-info (which has global-mode-string as a member by default).
    – phils
    Jul 9, 2015 at 23:05
  • 1
    @phils: Yes, there is. Doesn't change my answer, but there's room for plenty of other answers. ;-) There are multiple ways to skin this cat.
    – Drew
    Jul 10, 2015 at 0:24
  • Hello, this is very close to what I want :-). I think I didn't ask the question correctly. Once I've added the pomodoro count, how do I update that number? Each time I call that function, it adds more stuff to the mode line. Jul 13, 2015 at 15:54
  • Then instead of adding a constant string to global-mode-string, use (:eval.... That is really a different question.
    – Drew
    Jul 13, 2015 at 16:38
  • @Drew, I tried (..... (:eval (number-to-string my/pc))) with my/pc being an integer that I set before hand. But the number does not show in mode line? Jul 13, 2015 at 22:18
(setq-default mode-line-misc-info "My Text Goes Here")

Should append the data above to your mode line.

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.