emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best practices for adding information to global-mode-string


From: Daniel Martín
Subject: Best practices for adding information to global-mode-string
Date: Sat, 22 Aug 2020 16:45:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)

As you probably know, Emacs provides global-mode-string to show
additional ongoing information in the mode line. For example, the
following commands included in Emacs add information to
global-mode-string:

- display-time-mode: Displays time, unread mails, and system load.
- display-battery-mode: Displays battery information.
- org-clock-in: Shows information about the current clocked-in task.

However, it's not totally clear to me how the different modes that add
information to global-mode-string should format things so that they
appear correctly in every case (that is, with appropriate spaces to
avoid text overlapping).

For instance, display-time-mode does not seem to add any spaces to its
format string by default. This probably makes it a "bad citizen" if it's
loaded after an extension that already added things to
global-mode-string. display-battery-mode doesn't add spaces either, but
at least it encloses the battery information in square brackets, which
helps visually separating the different mode line constructs a bit
better. org-clock-in prepends a space to its format string, which seems
very convenient.

Is there a suggested pattern that should be used here, or extensions
should simply expose a format variable to let users customize the text
and fix things when there's overlap with text from another extension? I
think the approach used by org-clock-in is a valid one, but every
extension should be following it to be really useful.

I haven't seen any information about this in the ELisp manual, so maybe
it's a good idea to extend the manual a bit with some suggestions for
extension developers.

Thanks.

--
Daniel Martín



reply via email to

[Prev in Thread] Current Thread [Next in Thread]