Change mode-line names of major/minor modes
Alex Kost 5515f2e865 README: Fix a link to "delight" and to "Why" section | %!s(int64=4) %!d(string=hai) anos | |
---|---|---|
.gitignore | %!s(int64=8) %!d(string=hai) anos | |
README.org | %!s(int64=4) %!d(string=hai) anos | |
dim.el | %!s(int64=8) %!d(string=hai) anos |
file:https://img.shields.io/badge/license-GPL_3-orange.svg file:http://melpa.org/packages/dim-badge.svg file:http://stable.melpa.org/packages/dim-badge.svg
This Emacs package can be used to change the names of major and minor modes that are displayed in the mode-line. This is an alternative to delight package (see Why? section below).
This package can be installed from MELPA (with M-x package-install
or
=M-x list-packages=).
For the manual installation, clone the repo and add the directory to =load-path=:
(add-to-list 'load-path "/path/to/dim-dir")
(when (require 'dim nil t)
(dim-major-names ...)
(dim-minor-names ...))
There are 4 functions, that you can use in your =.emacs=:
So you can change the names by one, like this:
(dim-major-name 'scheme-mode "λ")
(dim-major-name 'help-mode "🄷")
(dim-minor-name 'isearch-mode " 🔎")
(dim-minor-name 'view-mode " 👀" 'view)
Or you can set multiple names at once, like this:
(dim-major-names
'((emacs-lisp-mode "EL")
(inferior-emacs-lisp-mode "EL>")
(calendar-mode "📆")))
(dim-minor-names
'((visual-line-mode " ↩")
(auto-fill-function " ↵")
(eldoc-mode "" eldoc)
(whitespace-mode " _" whitespace)
(paredit-mode " ()" paredit)))
I prefer the latter variant as I like to keep all names in one place.
As you can see, the functions for major modes take a mode symbol (which
can be found by M-: major-mode
) and a new mode-line name.
The functions for minor modes also take a mode symbol (from
=minor-mode-alist= variable) and a new name, and optionally a feature or
file name where the minor mode comes from. It is passed to
=eval-after-load= function. If the feature or file name is not
specified, the mode name is changed immediately, but of course only if
the mode is already available, so the package feature shouldn't be
specified only for the modes that are available right away on emacs
start (like isearch-mode
or visual-line-mode
).
Note that mode-name should not necessarily be a string, it can be any mode-line construct supported by emacs. For example, you can configure mode-name to display images instead of text (see issue 8 for details).
So why this package, if we already have several packages for similar purposes?
The most well-known package is diminish. It is great, but it is only
for minor modes, also diminish
function can be called only when a
minor mode is available, so you have to wrap it into eval-after-load=
(or you can use =:diminish
keyword in use-package). For minor modes,
there is also rich-minority package, which allows to hide and highlight
mode-line names.
For major modes, there is cyphejor package, which allows to make complex
rules for changing parts of mode names. It can be also used for
automatic abbreviation of these parts. In contrast, dim
is very
simple and straight-forward: you just assign a new mode-line string to a
mode name (symbol) and that's it.
As for the delight package, the main reason is: I don't like that it
mixes minor and major modes (they are set by delight
function and
stored in delighted-modes
variable). They are essentially different
things and should be treated independently. Also delight
is
"developed" on the wiki, which is not convenient for using and
contributing. And finally, I don't like some parts of the code (like
adding delight-major-mode
to after-change-major-mode-hook
inside
=delight= function — it should be a top-level form!).
But I say many thanks to the author of delight
package as the code of
=dim= is heavily based on it.