README.org

January 21, 2020 ยท View on GitHub

[[http://www.gnu.org/licenses/gpl-3.0.txt][file:https://img.shields.io/badge/license-GPL_3-orange.svg]] [[http://melpa.org/#/dim][file:http://melpa.org/packages/dim-badge.svg]] [[http://stable.melpa.org/#/dim][file:http://stable.melpa.org/packages/dim-badge.svg]]

** About

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 [[https://elpa.gnu.org/packages/delight.html][delight]] package (see Why? section below).

** Installation

*** Automatic

This package can be installed from [[http://melpa.org/][MELPA]] (with =M-x package-install= or =M-x list-packages=).

*** Manual

For the manual installation, clone the repo and add the directory to =load-path=:

#+BEGIN_SRC emacs-lisp (add-to-list 'load-path "/path/to/dim-dir") (when (require 'dim nil t) (dim-major-names ...) (dim-minor-names ...)) #+END_SRC

** Usage

There are 4 functions, that you can use in your =.emacs=:

  • dim-major-name
  • dim-major-names
  • dim-minor-name
  • dim-minor-names

So you can change the names by one, like this:

#+BEGIN_SRC emacs-lisp (dim-major-name 'scheme-mode "ฮป") (dim-major-name 'help-mode "๐Ÿ„ท") (dim-minor-name 'isearch-mode " ๐Ÿ”Ž") (dim-minor-name 'view-mode " ๐Ÿ‘€" 'view) #+END_SRC

Or you can set multiple names at once, like this: #+BEGIN_SRC emacs-lisp (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))) #+END_SRC

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 [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Data.html][mode-line construct]] supported by emacs. For example, you can configure mode-name to display images instead of text (see [[https://github.com/alezost/dim.el/issues/8#issuecomment-368342568][issue 8]] for details).

** Why?

So why this package, if we already have several packages for similar purposes?

The most well-known package is [[http://www.emacswiki.org/emacs/DiminishedModes][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 [[https://github.com/jwiegley/use-package][use-package]]). For minor modes, there is also [[https://github.com/Malabarba/rich-minority][rich-minority]] package, which allows to hide and highlight mode-line names.

For major modes, there is [[https://github.com/mrkkrp/cyphejor][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 [[http://www.emacswiki.org/emacs/DelightedModes][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.