Created
November 13, 2014 20:08
-
-
Save GongYiLiao/22e77f2fb2e65320ec77 to your computer and use it in GitHub Desktop.
a failed attempt to build major-mode-specific powerline in emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; fancy status line | |
(require 'powerline) | |
;; make poweline ### autoload | |
(defpowerline powerline-mule-info | |
(format-mode-line mode-line-mule-info)) | |
;; | |
(defface powerline-filemode-active | |
'((t (:background "OliveDrab3" :foreground "grey22" :inherit mode-line))) | |
"Powerline face 3." | |
:group 'powerline) | |
(defface powerline-filemode-inactive | |
'((t (:background "grey85" :inherit mode-line-inactive))) | |
"Powerline face 3 on left." | |
:group 'powerline) | |
;; | |
(defface powerline-majmode-active | |
'((t (:background "navy" :foreground "white" :bold t :inherit mode-line))) | |
"Powerline face for major mode, active" | |
:group 'powerline) | |
(defface powerline-majmode-inactive | |
'((t (:background "SkyBlue3" :foreground "grey95" :bold t :inherit mode-line-inactive))) | |
"Powerline face for major mode, inactive" | |
:group 'powerline) | |
(defface powerline-elisp-majmode-active | |
'((t (:background "brown" :foreground "white" :bold t :inherit mode-line))) | |
"Powerline face for major mode, active" | |
:group 'powerline) | |
(defface powerline-elisp-majmode-inactive | |
'((t (:background "firebrick" :foreground "grey95" :bold t :inherit mode-line-inactive))) | |
"Powerline face for major mode, inactive" | |
:group 'powerline) | |
;; | |
(defface powerline-minmode-active | |
'((t (:background "grey22" :foreground "grey85" :inherit mode-line))) | |
"Powerline face 3." | |
:group 'powerline) | |
(defface powerline-minmode-inactive | |
'((t (:background "grey11" :inherit mode-line-inactive))) | |
"Powerline face 3." | |
:group 'powerline) | |
;; | |
(defface powerline-midbar-active | |
'((t (:background "grey50" :foreground "grey95" :inherit mode-line))) | |
"Powerline face 4." | |
:group 'powerline) | |
(defface powerline-midbar-inactive | |
'((t (:background "grey20" :inherit mode-line-inactive))) | |
"Powerline face 4." | |
:group 'powerline) | |
;; cursor position | |
(defface powerline-positab-active | |
'((t (:background "tomato4" :foreground "grey95" :bold t :inherit mode-line))) | |
"Powerline face for cursor position tab, active" | |
:group 'powerline) | |
(defface powerline-positab-inactive | |
'((t (:background "chocolate" :foreground "grey80" :bold t :inherit mode-line-inactive))) | |
"Powerline face for cursor position tab, inactive" | |
:group 'powerline) | |
(defun powerline-layout (proglang) | |
"Setup a default mode-line." | |
(interactive) | |
(let | |
((mode-line-format-pl | |
'("%e" | |
(:eval | |
(let* ((active (powerline-selected-window-active)) | |
(face-file-tab (if active 'powerline-filemode-active 'powerline-filemode-inactive)) | |
(face-majmode-tab (if active (quote (concat ("powerline-" proglang "-majmode-active"))) | |
(quote (concat ("powerline-" proglang "-majmode-inactive"))))) | |
;; (face-majmode-tab (if active 'powerline-majmode-active 'powerline-majmode-inactive)) | |
(face-minmode-tab (if active 'powerline-minmode-active 'powerline-minmode-inactive)) | |
(face-midbar-tab (if active 'powerline-midbar-active 'powerline-midbar-inactive)) | |
(face-cursor-tab (if active 'powerline-positab-active 'powerline-positab-inactive)) | |
(lhs (list | |
(powerline-mule-info face-file-tab 'l) | |
(powerline-raw "%*" face-file-tab 'l) | |
(powerline-buffer-size face-file-tab 'l) | |
(powerline-buffer-id face-file-tab 'l) | |
(powerline-raw " " face-file-tab 'l) | |
(powerline-arrow-right face-file-tab face-majmode-tab) | |
(powerline-major-mode face-majmode-tab 'l) | |
(powerline-raw " " face-majmode-tab 'l) | |
(powerline-arrow-right face-majmode-tab face-minmode-tab) | |
(powerline-process face-minmode-tab) | |
(powerline-minor-modes face-minmode-tab 'l) | |
(powerline-narrow face-minmode-tab 'l) | |
(powerline-raw " " face-minmode-tab) | |
(powerline-arrow-right face-minmode-tab face-midbar-tab) | |
(powerline-vc face-midbar-tab))) | |
(rhs (list | |
(powerline-raw global-mode-string face-midbar-tab 'r) | |
(powerline-arrow-left face-midbar-tab face-cursor-tab) | |
(powerline-raw " %l:%c" face-cursor-tab 'r) | |
(powerline-arrow-left face-cursor-tab nil) | |
(powerline-raw " %6p" nil 'r) | |
(powerline-hud face-midbar-tab face-minmode-tab)))) | |
(concat (powerline-render lhs) | |
(powerline-fill face-midbar-tab (powerline-width rhs)) | |
(powerline-render rhs))))))) | |
mode-line-format-pl)) | |
;; build up my theme | |
;; (fset 'powerline-gongyi 'powerline-gongyi-theme) | |
(add-hook 'emacs-lisp-mode-hook | |
'(lambda () | |
(setq mode-line-format (powerline-layout "elisp")))) | |
(provide 'powerline-theme-gongyi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment