2010-05-12

cleaning up the mode-line

Emacs' version on a status-bar is called the mode-line, and contains all kind of information – the current buffer name, the cursor position and a lot of other things, depending on what major and minor modes are active.

Customizing the mode-line is, unfortunately, rather hard. One day, I'll write something about that… but for now at least we may be able to improve things a little bit, by reducing mode line pollution. Mode line pollution? Well, many parts of emacs like to announce their presence and state in the mode line. With the limited space available there, this can become a bit of an issue, the (Lisp Interaction company Yas abbrev) takes quite some space:


But there are some ways to limit the space taken by modes and minor-modes. Note, these snippets should go in your .emacs, and you need to restart emacs to make them active.

First, the minor modes (note, you can see the currently activated ones with C-h m); install the handy diminish.el (or get it using the emacs-goodies-el package when using Debian/Ubuntu) and add something like the following:
(when (require 'diminish nil 'noerror)
  (eval-after-load "company"
      '(diminish 'company-mode "Cmp"))
  (eval-after-load "abbrev"
    '(diminish 'abbrev-mode "Ab"))
  (eval-after-load "yasnippet"
    '(diminish 'yas/minor-mode "Y")))

And the major-modes, for example for Emacs Lisp mode:
(add-hook 'emacs-lisp-mode-hook 
  (lambda()
    (setq mode-name "el"))) 
This looks a bit shorter:

You can of course set these names to whatever is obvious to you.

6 comments:

Wei Hu said...

It's worth mentioning that diminish.el isn't a builtin script: http://www.emacswiki.org/emacs/DiminishedModes

djcb said...

@Wei Hu: thank you, I forgot about that as I got it through the emacs-goodies-el packages. Updated.

Jean-Baptiste Bourgoin said...

Thank you !

I'm waiting the article about the mode-line's customizing ;)

Unknown said...

I'll probably integrate this into my config, and when I do, I'll recast it using defcustom. I'll post the results when I do so.

Ethan said...

Also recommended is delight, which takes the library to eval-after-load as an argument.

Ryan said...

Here's my system for diminishing via custom variable: https://github.com/DarwinAwardWinner/dotemacs#diminish