Skip to content

Instantly share code, notes, and snippets.

@arnested
Last active July 5, 2022 13:30
Show Gist options
  • Save arnested/afd421c89a68b874e1c0 to your computer and use it in GitHub Desktop.
Save arnested/afd421c89a68b874e1c0 to your computer and use it in GitHub Desktop.
Using Font Awesome in the Emacs mode line

Font Awesome icons in Emacs mode-line

I installed Font Awesome and uses it to make my Emacs mode line look cool:

  • Use the align-left icon for auto-fill-mode.
  • Use the thumbs-up and thumbs-down icons for flymake status (we need to reimplement flymake-report-status to make this happen).
  • Use the tags icon for gtags-mode.

Requirements: diminish.el - I installed it from MELPA.

Since I don't specify the font anywhere this probably only works because Font Awesome is the only font providing those Unicode slots.

Is there away to specify font for individual characters in the mode line?

(when (display-graphic-p)
;; Use align-left icon for `auto-fill-mode'.
(eval-after-load 'diminish-autoloads
'(eval-after-load 'simple
'(diminish 'auto-fill-function (concat " " [#xF036]))))
;; Use thumbs-up / thumbs-down for flymake status.
;; We need to reimplement `flymake-report-status' to make this happen.
(eval-after-load 'flymake
'(defun flymake-report-status (e-w &optional status)
"Show status in mode line."
(when e-w
(setq flymake-mode-line-e-w e-w))
(when status
(setq flymake-mode-line-status status))
(let* ((mode-line " "))
(if (> (length flymake-mode-line-e-w) 0)
(setq mode-line (concat mode-line [#xF165] flymake-mode-line-e-w))
(setq mode-line (concat mode-line [#xF164])))
(setq mode-line (concat mode-line flymake-mode-line-status))
(setq flymake-mode-line mode-line)
(force-mode-line-update))))
;; Use the tags icon for `gtags-mode'.
(add-hook 'gtags-mode-hook '(lambda ()
(diminish 'gtags-mode (concat " " [#xF02C]))))
;; Use the Druplicon icon for `drupal-mode' (and color it Drupal
;; blue :-).
(add-hook 'drupal-mode-hook '(lambda ()
(diminish 'drupal-mode (propertize (concat " " [#xF1A9]) 'face '(:foreground "#0077C0")))))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment