;;; -*- lexical-binding: t; -*- ;;; Commentary: ;;; Note this currently requires many of the previous modules to be loaded ;;; to function properly. ;;; Code: (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 ,") 'minor-mode-blackout-mode) (defvar-local bd/buffer-identification-mode-line '(:eval (format "%s" (buffer-name))) "Formats the modeline-buffer-name.") (defvar-local bd/modeline-buffer-file-state-icon '(:eval (cond (buffer-read-only (propertize "L" 'face `(:foreground ,(ef-themes-get-color-value 'warning)))) ((and buffer-file-name (buffer-modified-p)) (propertize "S" 'face `(:foreground ,(ef-themes-get-color-value 'warning)))) ((and buffer-file-name ;; Avoid freezing while connection is lost (not (file-remote-p buffer-file-name)) (not (file-exists-p buffer-file-name))) (propertize "?" 'face `(:foreground ,(ef-themes-get-color-value 'err)))) (t ""))) "Formats the file modification status.") ;;;; pos (defvar-local bd/line-position '(:eval (when (mode-line-window-selected-p) mode-line-position))) ;; show column number (column-number-mode) ;;;; git (defun git-vc-modeline () (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-"))) (concat (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.") (dolist (construct '(bd/time-mode-line bd/buffer-identification-mode-line bd/vc-mode-line bd/line-position)) (put construct 'risky-local-variable t)) ;; set elements; move modeline to top (setq-default header-line-format (list mode-line-front-space ;; mode-line-mule-info ;; mode-line-frame-identification bd/buffer-identification-mode-line " " mode-line-modes bd/modeline-buffer-file-state-icon bd/vc-mode-line " " (mode-line-fill 16) bd/line-position " ")) (setq-default mode-line-format nil) (provide 'bd--modeline) ;;; bd-modeline ends here