Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 6.86 KB | None | 0 0
  1. (setq-default mode-line-format
  2.               '("%e" (:eval (powerline-render (list
  3.                                                 (powerline-raw mode-line-front-space)
  4.                                                 (powerline-raw mode-line-mule-info)
  5.                                                 (powerline-raw mode-line-client)
  6.                                                 (powerline-raw (custom-modeline-modified))
  7.                                                 (powerline-raw mode-line-frame-identification)
  8.                                                 (powerline-raw (custom-modeline-file-icon))
  9.                                                 (powerline-raw mode-line-buffer-identification)
  10.                                                 (powerline-raw "   ")
  11.                                                 (powerline-raw (custom-modeline-region-info))
  12.                                                 (powerline-raw (propertize (char-to-string (glyph-char powerline-utf-8-separator-left)) 'face `(:background "#007bb3")))
  13.                                                 (powerline-raw "  ")
  14.                                                 (powerline-raw (custom-modeline-icon-vc))
  15.                                                 (powerline-raw "  ")
  16.                                                 (powerline-raw mode-line-modes)
  17.                                                 (powerline-raw mode-line-misc-info)
  18.                                                 (powerline-raw mode-line-end-spaces))))))
  19.                                                
  20. (require 'all-the-icons)
  21.  
  22. (defun custom-modeline-modified ()
  23.   (let* ((config-alist
  24.             '(("*" all-the-icons-faicon-family  all-the-icons-faicon  "chain-broken" :height 1.2 :v-adjust -0.0)
  25.               ("-" all-the-icons-faicon-family  all-the-icons-faicon  "link"         :height 1.2 :v-adjust -0.0)
  26.               ("%" all-the-icons-octicon-family all-the-icons-octicon "lock"         :height 1.2 :v-adjust  0.1)))
  27.          (result
  28.             (cdr (assoc (format-mode-line "%*") config-alist))))
  29.       (propertize (apply (cadr result) (cddr result))
  30.                   'face       `(:family ,(funcall (car result)))
  31.                   'mouse-face `mode-line-highlight
  32.                   'local-map  (if (string= "%" (format-mode-line "%*"))
  33.                                   `(keymap (mode-line keymap (mouse-1 . mode-line-toggle-read-only)))
  34.                                 `(keymap (mode-line keymap (mouse-1 . mode-line-toggle-modified))))
  35.                   'help-echo  (if (string= "%" (format-mode-line "%*"))
  36.                                   `mode-line-read-only-help-echo
  37.                                 `mode-line-modified-help-echo))))
  38.  
  39. (defun custom-modeline-region-info ()
  40.   (let ((words (count-words (point-min) (point-max))))
  41.     (concat
  42.       (propertize (format "  %s words " words)
  43.                   'face `(:background "#007bb3" :height 0.9))
  44.       (propertize (format "  %s " (all-the-icons-octicon "pencil") words)
  45.                   'face `(:family ,(all-the-icons-octicon-family) :background "#007bb3")
  46.                   'display '(raise -0.0))
  47.       (propertize " %l:%c "
  48.                   'face `(:background "#007bb3" :height 0.9))
  49.       (propertize "%p"
  50.                   'help-echo  "Size indication mode
  51. mouse-1: Display Line and Column Mode Menu"
  52.                   'mouse-face `mode-line-highlight
  53.                   'local-map  `(keymap (mode-line keymap (down-mouse-1 keymap (column-number-mode menu-item "Display Column Numbers" column-number-mode :help "Toggle displaying column numbers in the mode-line" :button (:toggle . column-number-mode)) (line-number-mode menu-item "Display Line Numbers" line-number-mode :help "Toggle displaying line numbers in the mode-line" :button (:toggle . line-number-mode)) (size-indication-mode menu-item "Display Size Indication" size-indication-mode :help "Toggle displaying a size indication in the mode-line" :button (:toggle . size-indication-mode)) "Toggle Line and Column Number Display")))
  54.                   'face `(:background "#007bb3" :height 0.9))
  55.       (propertize "  "
  56.                   'face `(:background "#007bb3" :height 0.9)))))
  57. ;; mode-line-position
  58.                  
  59. (defun -custom-modeline-github-vc ()
  60.   (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
  61.     (concat
  62.      (propertize (format " %s" (all-the-icons-alltheicon "git")) 'face `(:height 0.9) 'display '(raise -0.1))
  63.      " · "
  64.      (propertize (format "%s" (all-the-icons-octicon "git-branch"))
  65.                  'face `(:height 1.0 :family ,(all-the-icons-octicon-family))
  66.                  'display '(raise -0.1))
  67.      (propertize (format " %s" branch) 'face `(:height 0.9)))))
  68. (defun -custom-modeline-svn-vc ()
  69.   (let ((revision (cadr (split-string vc-mode "-"))))
  70.     (concat
  71.      (propertize (format " %s" (all-the-icons-faicon "cloud")) 'face `(:height 1.2) 'display '(raise -0.1))
  72.      (propertize (format " · %s" revision) 'face `(:height 0.9)))))
  73. (defun custom-modeline-icon-vc ()
  74.   (when vc-mode
  75.     (cond
  76.       ((string-match "Git[:-]" vc-mode) (-custom-modeline-github-vc))
  77.       ((string-match "SVN-" vc-mode) (-custom-modeline-svn-vc))
  78.       (t (format "%s" vc-mode)))))
  79.  
  80. (defun custom-modeline-file-icon ()
  81.   (if (buffer-file-name)
  82.       (concat (propertize (all-the-icons-icon-for-file (buffer-file-name))
  83.                           'face       `(:bold t :foreground "#007bb3" :background nil :height 1.0)
  84.                           'display    '(raise -0.1)
  85.                           'local-map  `(keymap (header-line keymap (mouse-3 . mode-line-next-buffer) (down-mouse-3 . ignore) (mouse-1 . mode-line-previous-buffer) (down-mouse-1 . ignore)) (mode-line keymap (mouse-3 . mode-line-next-buffer) (mouse-1 . mode-line-previous-buffer)))
  86.                           'mouse-face `mode-line-highlight
  87.                           'help-echo  "Buffer name
  88. mouse-1: Previous buffer
  89. mouse-3: Next buffer") " ")
  90.     ""))
  91.  
  92. (setq-default mode-line-format (cons
  93.                          (propertize "\u200b" 'display '((raise -0.3) (height 1.8)))
  94.                          '("%e" mode-line-front-space
  95.                                 mode-line-mule-info
  96.                                 mode-line-client
  97.                                 (:eval (custom-modeline-modified))
  98.                                 mode-line-frame-identification
  99.                                 (:eval (custom-modeline-file-icon))
  100.                                 mode-line-buffer-identification
  101.                                 "  "
  102.                                 (:eval (custom-modeline-region-info))
  103.                                 "  "
  104.                                 (:eval (custom-modeline-icon-vc))
  105.                                 "  "
  106.                                 mode-line-modes
  107.                                 mode-line-misc-info
  108.                                 mode-line-end-spaces)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement