ryrd
ryrd

Reputation: 189

How to show time in percentage in mode-line in emacs

If time is 08:00, emacs should display 33.3% in modeline

and show 80.0% when time is 19:12.

How can I do this in .emacs? thanks very much.

algorithm is current-time/24.

Upvotes: 0

Views: 619

Answers (2)

angus
angus

Reputation: 2367

As @phils says, you can override the custom setting “Display Time String Forms”. In particular:

Go to the “Display Time” customization group and change the value of the “Display Time String Forms” setting to:

((format "%.1f%%"
   (* 100 (/ (+ (* (string-to-number 24-hours) 3600)
                (* (string-to-number minutes) 60)
                (string-to-number seconds))
             86400.0)))
)

Upvotes: 3

phils
phils

Reputation: 73324

If you want display-time-mode to display the time in this way, you should look into the display-time-string-forms variable, which will enable you to perform any arbitrary processing. I don't think any of the simpler customisations provide for this particular approach.

Upvotes: 0

Related Questions