summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/bd--modeline.el
diff options
context:
space:
mode:
Diffstat (limited to '.config/emacs/modules/bd--modeline.el')
-rw-r--r--.config/emacs/modules/bd--modeline.el126
1 files changed, 126 insertions, 0 deletions
diff --git a/.config/emacs/modules/bd--modeline.el b/.config/emacs/modules/bd--modeline.el
new file mode 100644
index 0000000..b092081
--- /dev/null
+++ b/.config/emacs/modules/bd--modeline.el
@@ -0,0 +1,126 @@
+;; -*- lexical-binding: t; -*-
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Highly customized modeline. Note this currently requires ;;
+;; many of the previous modules to be loaded to function properly. ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun mode-line-fill (reserve)
+ "Return empty space, leaving RESERVE space on the right."
+ (unless reserve
+ (setq reserve 20))
+ (when (and window-system (eq 'right (get-scroll-bar-mode)))
+ (setq reserve (- reserve 3)))
+ (propertize " "
+ 'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve)))))
+
+
+;;;; remove mode-line-clutter
+(define-minor-mode minor-mode-blackout-mode
+ "Hides minor modes from the mode line."
+ t)
+
+(catch 'done
+ (mapc (lambda (x)
+ (when (and (consp x)
+ (equal (cadr x) '("" minor-mode-alist)))
+ (let ((original (copy-sequence x)))
+ (setcar x 'minor-mode-blackout-mode)
+ (setcdr x (list "" original)))
+ (throw 'done t)))
+ mode-line-modes))
+
+(global-set-key (kbd "C-c m") 'minor-mode-blackout-mode)
+
+
+;;;; time and date
+(setq display-time-format "%m/%d/%y %H:%M (%a)"
+ display-time-default-load-average nil)
+(display-time)
+
+(defvar-local bd/time-mode-line
+ '(:eval
+ (when (mode-line-window-selected-p)
+ display-time-string))
+ "displays current time and date in selected window.")
+
+
+;;;; notification-server
+(use-package ednc
+ :init
+ (defun get-num-notifications ()
+ "Return number of active notifcations as a string."
+ (format "%s" (length (ednc-notifications))))
+
+ (defvar-local bd/notify-mode-line
+ '(:eval (when (and (ednc-notifications) (mode-line-window-selected-p))
+ (format " %s %s" (all-the-icons-material "notifications_active")
+ (propertize (get-num-notifications) 'face 'error))))
+ "Formats the notification number.")
+ (ednc-mode))
+
+
+;;;; buffer name
+(defun modeline-buffer-name ()
+ "Return 'buffer-name' with proper spacing and icon."
+ (format " %s %s" (all-the-icons-icon-for-file (buffer-name)) (buffer-name)))
+
+(defvar-local bd/buffer-identification-mode-line
+ '(:eval (format "%s" (modeline-buffer-name)))
+ "Formats the modeline-buffer-name.")
+
+
+;;;; git
+(defun git-vc-modeline ()
+ (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
+ (concat
+ (propertize (format " %s" (all-the-icons-octicon "git-branch"))
+ 'face `(:height 1 :family ,(all-the-icons-octicon-family))
+ 'display '(raise 0))
+ (propertize (format " %s" branch))
+ (propertize " "))))
+
+(defvar-local bd/vc-mode-line
+ '(:eval (when (and vc-mode (not (eq major-mode 'magit-status-mode))) ; temp fix to avoid bug which occurs in magit buffer
+ (format "%s"
+ (propertize (git-vc-modeline) 'face 'shadow))))
+ "Formats the checked out git repository.")
+
+
+;;;; emms
+(defvar-local bd/emms-mode-line
+ '(:eval (when (and (mode-line-window-selected-p) emms-mode-line-string)
+ (format "%s %s" emms-mode-line-string
+ emms-playing-time-string)))
+ "Formats the currently playing emms track.")
+
+
+(dolist (construct '(bd/time-mode-line
+ bd/notify-mode-line
+ bd/buffer-identification-mode-line
+ bd/vc-mode-line
+ bd/emms-mode-line))
+ (put construct 'risky-local-variable t))
+
+
+(setq-default mode-line-format
+ (list
+ mode-line-front-space
+ ;; mode-line-mule-info
+ ;; mode-line-frame-identification
+ bd/buffer-identification-mode-line
+ " "
+ mode-line-modes
+ " "
+ ;; mode-line-position
+ mode-line-modified
+ bd/notify-mode-line
+ bd/vc-mode-line
+ " "
+ bd/emms-mode-line
+ (mode-line-fill 21)
+ bd/time-mode-line))
+
+
+(provide 'bd--modeline)