I tried the following methods in my custom mode-line, but they all failed.

(setq mode-line-format
       ;; TODO: concatenate the long string.
       ;; global-mode-string
       ;; (t org-mode-line-string org-timer-mode-line-string)
       ;; (t org-timer-mode-line-string) ; org-timer default time 25, (Pomodoro time management technique)
       ;; (:eval org-clock-mode-line-timer)
       ;; face (:foreground "cyan" :weight 'bold)
  • 1
    If I remember correctly, the org-clock should appear on the mode line out of the box. Could you try it with emacs -Q? Or are you clocking in in an unconventional way (maybe with a 3rd party package) which would inhibit (or simply not trigger) the insertion of the time into the mode line? – T. Verron Jun 2 '15 at 8:19
  • 1
    I know it can be used out of box, but I need to add it in my custom mode-line-format, so I ask this question. – stardiviner Jun 2 '15 at 8:52
  • great idea, Maybe I should inspect the org-clock indicator in mode-line-format with emacs -Q. So I can find out what Org-mode do. UPDATE: this failed. – stardiviner Jun 2 '15 at 8:54
  • 1
    Apparently, the functions you should have a look at are org-clock-update-mode-line and its child org-clock-get-clock-string, in org-clock.el. – T. Verron Jun 2 '15 at 8:57
  • Ah, and the variable org-mode-line-string is the indicator you're looking for. – T. Verron Jun 2 '15 at 8:58

Thanks @T.Verron 's coments hint, then I got this. And it work.

(setq mode-line-format
       (t org-mode-line-string)
       face (:foreground "cyan" :weight 'bold)))

(add-hook 'org-clock-out-hook
          '(lambda ()
             (setq org-mode-line-string nil)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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