Moody configuration

Moody is a pretty yet simple mode-line package of emacs. However, it doesn’t come with any examples of configuration.

I’ll explain how does moody works with my config. It looks like this:

Basically each construct is (:eval (moody-tab STRING WIDTH UP/DOWN)). And that’s all. moody-tab will turn your string into a “tab”, which is something like this:

By default, a tab will have the same background color of your page (I mean (face-attribute 'default :background)). WIDTH is the number of space padding around STRING. As for UP/DOWN, 'down means the longer side is down. and 'up means the longer side is up.

BTW, as the time of this article, STRING cannot be nil. If it does moody-tab will raise an error and your tab will not appear on the mode-line.

As for coloring, moody use two face: modeline and modeline-inactive. You can use

(set-face-attribute 'mode-line nil :background "some-color")
(set-face-attribute 'mode-line-inactive nil :background "some-inactive-color")

to set them up.

If you use spacemacs-theme as I do. They don’t support moody right now, but we can steal it’s color for powerline.

Basically you create a fake powerline face and use that to set mode-line face:

(defface powerline-active1 nil "fake powerline theme")
(set-face-attribute 'mode-line nil :background (face-attribute 'powerline-active1 :background))

It works well for me.

Here is my complete config of moody:

Once it’s defined, I call moon/setup-moody to, well, set up.

I know the setq and setq-default is a bit werid, but it works :P

(defun moon/setup-moody ()
  "Setup mode-line using moody."
  (interactive)
  (setq mode-line-format '(" "
                           (:eval (winum-get-number-string))
                           " "
                           (:eval (eyebrowse-mode-line-indicator))
                           " %I "
                           (:eval (moon-edit-lighter))
                           (:eval (moon-root-lighter))
                           ;; moody-mode-line-buffer-identification
                           (:eval (moody-tab "%b"))
                           " "
                           minions-mode-line-modes
                           (:eval (moody-tab (make-lighter| (concat (flycheck-lighter 'error "☠%s")
                                                                    (flycheck-lighter 'warning "⚠%s")
                                                                    (flycheck-lighter 'info "𝌆%s")) "" "OK") nil 'up))
                           " "
                           (:eval (nyan-create))
                           " "
                           ;; moody-vc-mode
                           (:eval (moody-tab (if vc-mode (substring-no-properties vc-mode 1) "NO VC")))
                           mode-line-misc-info
                           mode-line-end-spaces))
  (setq-default mode-line-format mode-line-format))