display-time: Add option to customize help-echo format

This option controls the format of the help-echo when hovering
over the time display in mode line.  (Bug#80143)
* lisp/time.el (display-time-help-echo-format): Add option.
(display-time-string-forms): Use it.

* etc/NEWS (Time): Announce the new option.
This commit is contained in:
Jacob S. Gordon 2026-01-26 16:20:00 -05:00 committed by Eli Zaretskii
parent cd152ea611
commit 049eefa611
2 changed files with 20 additions and 1 deletions

View file

@ -3338,6 +3338,11 @@ each refresh. The sort direction can be controlled by using a cons cell
of a format string and a boolean. Alternatively, a sorting function can
be provided directly.
---
*** New user option 'display-time-help-echo-format'.
This option controls the format of the help echo when hovering over the
time.
** Fill
+++

View file

@ -177,6 +177,18 @@ depend on `display-time-day-and-date' and `display-time-24hr-format'."
:type '(choice (const :tag "Default" nil)
string))
(defcustom display-time-help-echo-format "%a %b %e, %Y"
"Format for the help echo when hovering over the time in the mode line.
Use the function `customize-variable' to choose a common format, and/or
see the function `format-time-string' for an explanation of the syntax."
:version "31.1"
:type `(choice
,@(mapcar #'(lambda (fmt)
(list 'const
':tag (format-time-string fmt 0 "UTC") fmt))
'("%a %b %e, %Y" "%F (%a)" "%a %D"))
(string :tag "Format string")))
(defcustom display-time-string-forms
'((if (and (not display-time-format) display-time-day-and-date)
(format-time-string "%a %b %e " now)
@ -186,7 +198,9 @@ depend on `display-time-day-and-date' and `display-time-24hr-format'."
(if display-time-24hr-format "%H:%M" "%-I:%M%p"))
now)
'face 'display-time-date-and-time
'help-echo (format-time-string "%a %b %e, %Y" now))
'help-echo (format-time-string (if (stringp display-time-help-echo-format)
display-time-help-echo-format
"%a %b %e, %Y") now))
load
(if mail
;; Build the string every time to act on customization.