Emacs Mode Line Problem
This article gives some suggestions on improving emacs's “mode line”, so that it is more intuitive and useful.
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. (e.g. 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:
- “u” = utf-8
- “U” = utf-16
- “1” = iso-8859-1
- “(DOS)” = Windows newline convention. 〔see Emacs: Newline Representations ^M ^J ^L〕
- “(Unix)” = unix newline convention.
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”
The **
part is file status.
**
means the file's been modified.%*
means read-only.--
means saved. (that is, not modified.)
It'd better to just say Read Only
instead of %%
or %*
, and show Modified
instead of the **
. (don't show anything when it is --
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 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 Init: Show 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. (e.g. C, C++, Java, Perl, Python, PHP, Bash, JavaScript, HTML, text, LaTeX, Emacs Lisp, etc.) 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.
Summary
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. (e.g. 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
- https://github.com/Malabarba/smart-mode-line
- https://github.com/TheBB/spaceline/tree/master
- https://github.com/jonathanchu/emacs-powerline
- https://github.com/milkypostman/powerline
- https://github.com/dbordak/telephone-line
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.
Emacs Modernization
- Emacs Modernization: Simple Changes Emacs Should Adopt
- Why Emacs Keys are Painful
- Emacs: Problems of the Scratch Buffer
- Emacs Modernization: Meta Key Notation
- Emacs Menu Usability Problem
- Emacs Mode Line Problem
- Emacs cua-mode Problems
- Emacs: Inconsistency of Search Features
- Problems of grep in Emacs
- Emacs: Usability Problems of Mode Documentation
- Problems of Emacs Manual
- Emacs Manual Sucks by Examples
- Emacs: kill-buffer Induces Buffer Accumulation
- Emacs Spell Checker Problems
- Emacs: Form Feed ^L Problem
- Emacs: Single Key to Delete Whole Line
- Emacs HTML Mode Sucks
- Emacs Does Not Support Viewing Images Files In Windows
- Emacs Should Adopt HTML as Texinfo Replacement
- Emacs Should Support HTML Mail
- Problems of Emacs's “man” Command
- Emacs Lisp Mode Syntax Coloring Problem
- Emacs AutoHotkey Mode Problems
- Elisp: Syntax Table Sucks
- Emacs: Make elisp-index-search use Current Symbol
- Emacs GNU Texinfo Problems; Invalid HTML
- A Record of Frustration in IT Industry; Disappearing FSF URLs, 2006
- Emacs Manual Node Persistency Issues
- Emacs: dired-do-query-replace-regex Replace ALL (fixed)
- Problems of Emacs Supporting Obsolete Systems
- Elisp: Function to Copy/Delete a Dir Recursively (fixed)
- Thoughts on Common Lisp Scheme Lisp Based Emacs
- Text Editors Popularity and Market Research
- Text Editor's Cursor Movement Behavior (emacs, vi, Notepad++)
- Emacs: Usability Problems of Letter-Case Changing Commands
- Emacs Select Word Command Problem
- Emacs: Search Current Word 🚀
- Emacs fill-paragraph Problem