Skip to content

Instantly share code, notes, and snippets.

@rougier
Last active June 3, 2020 09:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rougier/5000024db93234e4c266 to your computer and use it in GitHub Desktop.
Save rougier/5000024db93234e4c266 to your computer and use it in GitHub Desktop.
(defun arrow-right-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\". \",
\".. \",
\"... \",
\".... \",
\"..... \",
\"...... \",
\"....... \",
\"........ \",
\"......... \",
\"......... \",
\"........ \",
\"....... \",
\"...... \",
\"..... \",
\".... \",
\"... \",
\".. \",
\". \"};" color1 color2))
(defun arrow-left-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\" .\",
\" ..\",
\" ...\",
\" ....\",
\" .....\",
\" ......\",
\" .......\",
\" ........\",
\" .........\",
\" .........\",
\" ........\",
\" .......\",
\" ......\",
\" .....\",
\" ....\",
\" ...\",
\" ..\",
\" .\"};" color2 color1))
(defvar mode-line-show-minor-modes nil)
(let*
((color1 "#777777")
(color2 "#555555"))
(setq arrow-right-1 (create-image (arrow-right-xpm color1 color2) 'xpm t :ascent 'center))
(setq arrow-right-2 (create-image (arrow-right-xpm color2 "None") 'xpm t :ascent 'center))
(setq arrow-left-1 (create-image (arrow-left-xpm color2 color1) 'xpm t :ascent 'center))
(setq arrow-left-2 (create-image (arrow-left-xpm "None" color2) 'xpm t :ascent 'center))
(setq-default mode-line-format
(list '(:eval (concat (propertize " %* %I %b" 'face 'mode-line-color-1)
(propertize " " 'display arrow-right-1)))
'(:eval (concat (propertize " %[%m%] " 'face 'mode-line-color-2
'mouse-face 'mode-line-color-2
'local-map (make-mode-line-mouse-map
'mouse-1 (lambda () (interactive)
(setq mode-line-show-minor-modes
(not mode-line-show-minor-modes))
(redraw-modeline))))
(propertize " " 'display arrow-right-2)))
'(:eval (if mode-line-show-minor-modes mode-line-modes
global-mode-string))
;; Justify right by filling with spaces to right fringe - 16
;; (16 should be computed rahter than hardcoded)
'(:eval (propertize " " 'display '((space :align-to (- right-fringe 20)))))
'(:eval (concat (propertize " " 'display arrow-left-2)
(propertize " %6p " 'face 'mode-line-color-2)))
'(:eval (concat (propertize " " 'display arrow-left-1)
(propertize "%4l:%2c " 'face 'mode-line-color-1)))
))
(make-face 'mode-line-color-1)
(set-face-attribute 'mode-line-color-1 nil
:foreground "#fff"
:background color1)
(make-face 'mode-line-color-2)
(set-face-attribute 'mode-line-color-2 nil
:foreground "#fff"
:background color2)
(set-face-attribute 'mode-line nil
:foreground "#fff"
:background "#2b2b2b"
:box nil)
(set-face-attribute 'mode-line-inactive nil
:foreground "#fff"
:background color2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment