Emacs Mode Line Problem

By Xah Lee. Date: . Last updated: .

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.

Can you tell what each of the above means?

Suggested Changes

The start of the mode line -uuu:**-F1 is quite cryptic. Having used emacs for 10 years, i still don't remember most of it without looking up. Worse, it's not easy to look them up unless you are a emacs expert. (For example, you'll have to know its technical name being “mode line”, then you'll have to know about emacs-index-search, and you must be familiar emacs's info system.)

Here's what might be a better default.

Coding System Indicator

First, let's see what some of these coded word means:

emacs calls this the “coding system”. For example: coding-system-list.

The coding system indicator should be removed.

Vast majority of programers do not frequently work with different character encoding or newline convention. Maybe once a month. Therefore, displaying encoding info in the mode line is probably not necessary.

Also, the abbreviation used is cryptic, especially today because there are hundreds of coding systems, with tens of them popularly used depending on country, but UTF-8 are becoming the most used.

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 25.1 (), such menu does not exist.)

For programers who deal 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 when it is turned on, the character encoding system is displayed in mode line by the encoding abbreviation such as “utf-8/unix” (not by letter codes).

Status for “Read-only” and “Modified State”

emacs mode line
Emacs's mode line.

The ** part is file status.

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

Many editors have the convention to use a black diamond to indicate that the file has been modified.

For read only, we can use the Unicode symbol of a lock 🔒

Cursor Location Indicator

emacs mode line
Emacs's mode line.

Emacs mode line displays one of the following {nn%, Top, Bot, All}, to indicate the location of cursor relative to whole file content.

The cursor location indicator is redundant when emacs has line number on. 〔►see Emacs: Display Line Numbers

GUI scroll bar conveys the cursor location much more effectively than a percentage, and also gives a sense of content length by the length of the scroll bar.

When line number is on, it is also better than the mode line, because it is adjacent to cursor, and is easier to see.

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} is more confusing because they 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.

Current Minor Modes

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, Python, PHP, Bash, JavaScript, HTML, text, LaTeX, Emacs Lisp, …) The menu can have a “More…” submenu to show all other available major modes.

As of emacs 25.1 (), emacs does not have a menu or command showing what major modes it supports.

Naming: 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.


I think the mode line should be like this:

‹buffer name›   ‹major mode name›   ‹line num›   ‹modified 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 of having a READ ONLY status 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.

By modern convention, many editors indicated “unsaved” status by just a black diamond adjacent to the file name displayed in the window top border. (For example, BBEdit, Mathematica.) Emacs could also adopt this convention.

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 Admin

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

etc                 Dired        L19    (admin)

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.

original modeline debate, 2008

emacs original modeline debate, 2008 https://lists.gnu.org/archive/html/help-gnu-emacs/2008-11/threads.html#00494

Modern Modeline Enhancement Packages

today, you have the following packages for enhanced modeline

Note: this does not fix the problem. The problem needs to be fixed by FSF GNU emacs. If you are inclined, file a bug to GNU Emacs. They will probably close it. But not if everyone do.

Liket it? Put $5 at patreon. Or Buy Xah Emacs Tutorial. Thanks.