If you enjoyed this site, please consider donating $3. Any amount is appreciated. Thanks!

Emacs's Mode Line Modernization Suggestions

Xah Lee, 2008-12, 2009-07

This article gives some suggestions on improving emacs's “mode line”, so that it is more intuitive and useful.

emacs mode line

Emacs's mode line.

Here's what i think are better default:

Read-only, Modified, Status

The start of the mode line, displaying the coding system used such as “-u”, “-uuu”, and displaying the modification status like “:**”, “%%”, “%*” are quite cryptic. Having used emacs for 10 years, these are still not burned into my brain. And it's not easy to look them up what they are unless you are emacs die-hard. (example: you'll have to know its technical name being “mode line”, then you'll have to know about emacs-index-search, and in general familiar with info and emacs)

It'd better to instead say “Read Only” instead of “%*”, and show “Modified” instead of the “**”. (don't show anything when it's “--”)

Coding System Indicator

The coding system indicator should be removed. (example: “u”, “uuu”, “U(Unix)”, “u(DOS)”, “1(Unix)” (u for utf-8, U for utf-16, 1 for iso-8859-1, ...)) Because, vast majority of programers do not work with different character encoding or newline convention (those “(DOS)”, “(Unix)”) frequently, possibly only few times a year.

Also, code word is cryptic, especially today because there are hundreds of coding systems, with tens of them popularly used depending on country.

It is best to show the coding system used for the current buffer in a more dedicated place, such as a menu command, and allow users to change coding system thru menu. (As of emacs 23 (2009-07), such menu does not exist.)

For programers who deals with files with different character encoding or unix/Windows newline conventions daily and need it be displayed on the mode line, the best solution is probably a customization feature so that the full coding system is displayed in mode line.

Cursor Location

The mode line displays “nn%”, or “Top”, “Bot”, “All”, to indicate the cursor location.

The cursor location indicator is redundant when emacs is running in GUI with scroll bar. GUI scroll bar conveys the cursor location much more effectively, and also gives a sense of content length by the length of the scroll bar.

When emacs is running in a terminal, there is usually no scroll bar, so the percentage “nn%” for cursor location is good. It should not change to “Top” when cursor is at the first line, or “Bot” and “All” special cases. Because, a consistent format is much easier to understand. When user moves the cursor, she can see the percentage display change dynamically from 1% to 100%. This is a very natural feedback.

The special case brief/abbrev words “Top”, “Bot”, “All” could mean many other things. The mode line uses abbreviated words or coded words to indicate minor modes and coding system, so there is potential to confuse “Bot” and “Top” as coded words for something to new users. For example, “Top” could mean the unix process viewer program “top” is running in emacs, “Bot” could mean there is a emacs bot (robot) running in the background maybe doing some clean up, etc.

Minor Mode

Minor modes should not be displayed in mode line. It's confusing. For one reason, it by default selectively display only some of the minor modes currently on, and the selective process is esoteric, probably only few emacs developers understand. For the other reason, the concept of emacs's minor mode is not something non-expert emacs users understand. From a user point of view, most minor modes in practice are today universally known as Preference settings or Options.

Clicking On Mode Line

Clicking on the file name should not switch buffer. It could do contextual menu listing user buffers instead. (user buffer here are those not starting with “*”)

Clicking on the major mode name should pop up a contextual menu to let user switch to major modes that are familiar to majority of average programers. (example: C, C++, java, perl, php, bash, javascript, html/xml, python, text, LaTeX, elisp.) The menu can have a “More...” submenu to show all other available major modes.

Emacs today (Emacs 23, 2009-07) does not have a menu anywhere showing major modes it supports.

Mode Line vs Status Bar

The term “mode line” could be changed to “status bar” in the manuals. “Status bar” is more standard term today.

Summary

I think the mode line should be like this:

‹buffer name›   ‹major mode name›   ‹line num›   ‹R/W status›---------

The “Status” Indicator

Removing Read Only Status

The “status” can have 3 states: “Modified”, “Read Only”, or nothing. But actually, indication of Read Only status is not necessary. One method of finding out whether a buffer is read-only, is by simply typing something in the buffer. This method is universal and familiar to all. Thus, the benefit of having mode line status to indicate Read Only is for saving the labor of typing something, but at the cost of introducing a item in the mode line and the (comparatively smaller) effort to look at the mode line. The benefit/cost ratio is trivial.

Change Modified to Unsaved

So, that leaves the possible display of the word “Modified” for status. The modified or not modified status would actually be better if it is changed to indicate whether the buffer is saved as file or not. Saved or unsaved is a more useful a state to know, because when a buffer is not associated with a file, it is always modified unless it is empty, so for such buffers shown as “Modified” is rather meaningless. (here, special purpose buffers such as dired, calc, calender, etc are excluded from consideration, because being “modified” does not have normal meaning in them.)

Considering all of the above, the possible display for status section in mode line is just “Unsaved”. Technically, this means that if buffer-modified-p returns true, and if the buffer name does not start with a “*” (meaning it is a user buffer), and the buffer is not a special mode (dired), then “Unsaved” should be displayed in the modeline.

This consolidates the “**”, “%*”, “%%”, “--” codes for the modeline. When a user sees “Unsaved”, it tells the user that he may need to save it to file.

Here's a example of such actual display:

elisp_basics.html    html-mode    L19    Unsaved----------------------

Running As Root

Also, when editing as root, it'd be nice to indicate it in mode line. Possibly making the mode line's background red, or add a word “(root)” on the right. Some indication of being root is a frequently requested feature. Here's a example:

etc                 Dired        L19    ------------------------(root)

Mouse Behavior Under GUI

If running in a GUI, clicking on the buffer name should show menu list of user buffers. That is, those not starting with a “*”.

Clicking on the major mode name should show a menu of commonly used major modes, allowing user a easy way to switch. (currently, emacs has no intuitive way for user to switch a mode or know what modes are available. This is also a FAQ item.)

Clicking on “line num” should show a menu that allow user to turn on/off line number mode and cursor column position.

Clicking on the “Unsaved”, should show a menu allowing user to save file.

Clicking the rest of the mode line displaying “--------”, can show all the useful info about the current buffer. For example: modified/read status, mode settings, minor modes, encoding used. This can be done as a new split window much like describe-function would. In the result pane, it can show status of other buffer local vars that are related to text editing (such as case sensitive search, how lines are wrapped, length for truncation, margin ... ). With links or active text that lets user toggle or set new vals easily (similar to the UI of the customize function).

All these clicking should be Right Click, which is more standard behavior of clicking on things for contextual menu. (example: in Windows, Mac, Linux, system wide, and in Firefox and other browsers.)

2008-07
© 2008 by Xah Lee.