2018-12-24 20:53:44 +00:00
;;; doom-modeline.el --- A minimal and modern mode-line -*- lexical-binding: t; -*-
2018-06-11 17:13:02 +00:00
2019-01-02 08:51:26 +00:00
;; Copyright (C) 2018-2019 Vincent Zhang
2018-06-11 17:13:02 +00:00
;; Author: Vincent Zhang <seagle0128@gmail.com>
2018-07-05 08:39:41 +00:00
;; Homepage: https://github.com/seagle0128/doom-modeline
2019-01-13 13:55:50 +00:00
;; Version: 1.5.0
2018-11-11 16:48:20 +00:00
;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (shrink-path "0.2.0") (eldoc-eval "0.1") (dash "2.11.0"))
2018-07-30 07:01:47 +00:00
;; Keywords: faces mode-line
2018-06-11 17:13:02 +00:00
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;; Commentary:
;;
2018-12-11 14:20:21 +00:00
;; This package offers a fancy and fast mode-line which was from DOOM Emacs
;; (https://github.com/hlissner/doom-emacs/tree/master/modules/ui/doom-modeline),
;; but it's more powerful and much faster.
2018-11-27 13:32:00 +00:00
;; It's also integrated into Centaur Emacs (https://github.com/seagle0128/.emacs.d).
2018-06-11 17:13:02 +00:00
;;
2018-12-11 14:20:21 +00:00
;; The doom-modeline was designed for minimalism, and offers:
2018-11-27 18:48:16 +00:00
;; - A match count panel (for anzu, iedit, multiple-cursors, symbol-overlay,
;; evil-search and evil-substitute)
2018-11-27 13:32:00 +00:00
;; - An indicator for recording a macro
;; - Local python/ruby version in the major-mode
;; - A customizable mode-line height (see doom-modeline-height)
2018-12-20 17:41:39 +00:00
;; - A minor modes segment which is compatible with minions
2019-01-02 12:57:54 +00:00
;; - An error/warning count segment for flymake/flycheck
2018-11-27 13:32:00 +00:00
;; - A workspace number segment for eyebrowse
2018-12-04 18:38:36 +00:00
;; - A perspective name segment for persp-mode
2018-11-27 13:32:00 +00:00
;; - A window number segment for winum and window-numbering
;; - An indicator for evil state
;; - An indicator for god state
;; - An indicator for ryo-modal state
2018-12-05 16:08:10 +00:00
;; - An indicator for xah-fly-keys state
2018-11-27 18:48:16 +00:00
;; - An indicator for remote host
2018-11-27 13:32:00 +00:00
;; - An indicator for current input method
2018-12-20 16:35:59 +00:00
;; - An indicator for debug state
2018-12-05 19:26:27 +00:00
;; - An indicator for LSP state
2018-12-11 14:20:21 +00:00
;; - An indicator for github notifications
2019-01-03 16:21:40 +00:00
;; - An indicator for buffer position which is compatible with nyan-mode
2019-01-08 15:45:25 +00:00
;; - An indicator for party parrot
2018-12-22 16:32:33 +00:00
;; - Truncated file name, file icon, buffer state and project name in buffer
;; information segment, which is compatible with projectile and project
2018-06-11 17:13:02 +00:00
;;
2018-07-05 06:01:47 +00:00
;; Installation:
;; From melpa, `M-x package-install RET doom-modeline RET`.
;; In `init.el`,
;; (require 'doom-modeline)
;; (doom-modeline-init)
;; or
;; (use-package doom-modeline
;; :ensure t
;; :defer t
;; :hook (after-init . doom-modeline-init))
;;
2018-06-11 17:13:02 +00:00
;;; Code:
( require 'all-the-icons )
( require 'eldoc-eval )
2018-06-13 18:30:36 +00:00
( require 'shrink-path )
2018-11-10 16:35:47 +00:00
( require 'subr-x )
2019-01-11 21:34:47 +00:00
( require 'doom-version-parser )
2018-11-11 16:48:20 +00:00
( when ( >= emacs-major-version 26 )
( require 'project ) )
2018-06-11 17:13:02 +00:00
2018-12-31 09:10:26 +00:00
2018-06-26 18:38:48 +00:00
;;
;; Variables
;;
2018-12-20 16:54:12 +00:00
( defvar doom-modeline-height ( let ( ( font ( face-font 'mode-line ) ) )
2018-12-22 06:09:02 +00:00
( if ( and font ( fboundp 'font-info ) )
( * 2 ( aref ( font-info font ) 2 ) )
25 ) )
2018-06-26 18:38:48 +00:00
" How tall the mode-line should be (only respected in GUI Emacs). " )
2018-12-24 15:46:45 +00:00
( defvar doom-modeline-bar-width ( if ( eq system-type 'darwin ) 3 6 )
2018-06-26 18:38:48 +00:00
" How wide the mode-line bar should be (only respected in GUI Emacs). " )
2018-11-20 15:11:29 +00:00
( defvar doom-modeline-buffer-file-name-style 'truncate-upto-project
2018-06-26 18:38:48 +00:00
" Determines the style used by `doom-modeline-buffer-file-name' .
2018-07-02 08:28:16 +00:00
Given ~/Projects/FOSS/emacs/lisp/comint.el
2018-06-30 18:19:54 +00:00
truncate-upto-project => ~/P/F/emacs/lisp/comint.el
2018-11-20 15:11:29 +00:00
truncate-from-project => ~/Projects/FOSS/emacs/l/comint.el
2018-11-17 19:26:00 +00:00
truncate-with-project => emacs/l/comint.el
2018-11-20 15:11:29 +00:00
truncate-except-project => ~/P/F/emacs/l/comint.el
2018-06-30 18:19:54 +00:00
truncate-upto-root => ~/P/F/e/lisp/comint.el
truncate-all => ~/P/F/e/l/comint.el
relative-from-project => emacs/lisp/comint.el
relative-to-project => lisp/comint.el
2018-11-22 16:12:36 +00:00
file-name => comint.el
buffer-name => comint.el<2> ( uniquify buffer name ) " )
2018-06-26 18:38:48 +00:00
2018-08-16 16:49:02 +00:00
( defvar doom-modeline-python-executable " python "
2018-10-25 08:11:03 +00:00
" What executable of Python will be used (if nil nothing will be showed). " )
2018-11-26 15:01:03 +00:00
( defvar doom-modeline-icon ( display-graphic-p )
" Whether show `all-the-icons' or not.
Non-nil to show the icons in mode-line.
The icons may not be showed correctly in terminal and on Windows. " )
2018-08-16 16:49:02 +00:00
2018-11-26 15:53:31 +00:00
( defvar doom-modeline-major-mode-icon t
2018-12-24 16:00:02 +00:00
" Whether show the icon for major mode. It respects `doom-modeline-icon' . " )
2018-12-26 21:08:51 +00:00
( defvar doom-modeline-major-mode-color-icon nil
2018-12-24 16:00:02 +00:00
" Display color icons for `major-mode' . It respects `all-the-icons-color-icons' . " )
2018-11-22 17:13:52 +00:00
2018-12-04 19:39:07 +00:00
( defvar doom-modeline-minor-modes nil
" Whether display minor modes or not. Non-nil to display in mode-line. " )
2018-12-06 16:24:29 +00:00
( defvar doom-modeline-persp-name t
" Whether display perspective name or not. Non-nil to display in mode-line. " )
( defvar doom-modeline-lsp t
" Whether display `lsp' state or not. Non-nil to display in mode-line. " )
2018-12-24 14:26:07 +00:00
( defvar doom-modeline-github t
2018-12-23 15:54:35 +00:00
" Whether display github notifications or not. Requires `ghub' package. " )
2018-12-11 14:20:21 +00:00
( defvar doom-modeline-github-interval ( * 30 60 )
" The interval of checking github. " )
2018-12-31 14:55:23 +00:00
( defvar doom-modeline-version t
" Whether display environment version or not. " )
2018-11-22 17:13:52 +00:00
2018-11-24 04:18:41 +00:00
;;
2018-12-31 09:10:26 +00:00
;; Compatibilities
2018-11-24 04:18:41 +00:00
;;
2018-12-31 09:10:26 +00:00
( unless ( >= emacs-major-version 26 )
( with-no-warnings
;; Define `if-let*' and `when-let*' variants for 25 users.
( defalias 'if-let* #' if-let )
( defalias 'when-let* #' when-let ) ) )
2018-11-27 17:35:55 +00:00
;; Don’ t compact font caches during GC.
( if ( eq system-type 'windows-nt )
( setq inhibit-compacting-font-caches t ) )
2018-11-24 04:18:41 +00:00
;;`file-local-name' is introduced in 25.2.2.
( unless ( fboundp 'file-local-name )
( defun file-local-name ( file )
" Return the local name component of FILE.
It returns a file name which can be used directly as argument of
` process-file ', ` start-file-process ', or ` shell-command '. "
( or ( file-remote-p file 'localname ) file ) ) )
2018-10-29 15:09:40 +00:00
;;
2018-12-31 09:10:26 +00:00
;; Externals
2018-10-29 15:09:40 +00:00
;;
2018-06-30 18:19:54 +00:00
( defvar anzu--current-position )
( defvar anzu--overflow-p )
( defvar anzu--state )
( defvar anzu--total-matched )
( defvar anzu-cons-mode-line-p )
2018-10-28 14:19:55 +00:00
( defvar aw-keys )
2018-06-30 18:19:54 +00:00
( defvar evil-ex-active-highlights-alist )
( defvar evil-ex-argument )
( defvar evil-ex-range )
2018-10-29 15:09:40 +00:00
( defvar evil-local-mode )
2018-06-30 18:19:54 +00:00
( defvar evil-state )
( defvar evil-visual-beginning )
( defvar evil-visual-end )
( defvar evil-visual-selection )
( defvar flycheck-current-errors )
2019-01-02 18:28:57 +00:00
( defvar flycheck-mode-menu-map )
2019-01-02 12:57:54 +00:00
( defvar flymake--backend-state )
( defvar flymake--mode-line-format )
( defvar flymake-menu )
2018-06-30 18:19:54 +00:00
( defvar iedit-mode )
( defvar iedit-occurrences-overlays )
2018-08-22 18:24:30 +00:00
( defvar mc/mode-line )
2018-12-20 17:41:39 +00:00
( defvar minions-mode )
( defvar minions-mode-line-lighter )
2018-12-31 16:42:23 +00:00
( defvar symbol-overlay-keywords-alist )
( defvar symbol-overlay-temp-symbol )
2018-12-05 16:08:10 +00:00
( defvar text-scale-mode-amount )
( defvar winum-auto-setup-mode-line )
( defvar xah-fly-insert-state-q )
2018-07-02 11:05:53 +00:00
2018-07-11 07:23:23 +00:00
( declare-function anzu--reset-status 'anzu )
( declare-function anzu--where-is-here 'anzu )
2018-12-30 12:57:42 +00:00
( declare-function async-inject-variables 'async )
2018-10-28 14:19:55 +00:00
( declare-function avy-traverse 'avy )
( declare-function avy-tree 'avy )
2018-10-25 08:57:17 +00:00
( declare-function aw-update 'ace-window )
2018-10-28 14:19:55 +00:00
( declare-function aw-window-list 'ace-window )
2018-07-11 07:23:23 +00:00
( declare-function evil-delimited-arguments 'evil-common )
2018-10-29 15:09:40 +00:00
( declare-function evil-emacs-state-p 'evil-states )
( declare-function evil-force-normal-state 'evil-commands )
( declare-function evil-insert-state-p 'evil-states )
( declare-function evil-motion-state-p 'evil-states )
( declare-function evil-normal-state-p 'evil-states )
( declare-function evil-operator-state-p 'evil-states )
( declare-function evil-replace-state-p 'evil-states )
2018-08-13 11:00:39 +00:00
( declare-function evil-state-property 'evil-common )
2018-10-29 15:09:40 +00:00
( declare-function evil-visual-state-p 'evil-states )
2018-07-11 07:23:23 +00:00
( declare-function eyebrowse--get 'eyebrowse )
( declare-function face-remap-remove-relative 'face-remap )
( declare-function flycheck-count-errors 'flycheck )
2018-12-05 16:48:10 +00:00
( declare-function flycheck-list-errors 'flycheck )
2019-01-02 12:57:54 +00:00
( declare-function flycheck-next-error 'flycheck )
( declare-function flycheck-previous-error 'flycheck )
( declare-function flymake--backend-state-diags 'flymake )
( declare-function flymake--diag-type 'flymake )
2019-01-02 18:08:35 +00:00
( declare-function flymake--handle-report 'flymake )
2019-01-02 12:57:54 +00:00
( declare-function flymake-disabled-backends 'flymake )
( declare-function flymake-goto-next-error 'flymake )
( declare-function flymake-goto-prev-error 'flymake )
( declare-function flymake-reporting-backends 'flymake )
( declare-function flymake-running-backends 'flymake )
2019-01-02 13:50:58 +00:00
( declare-function flymake-show-diagnostics-buffer 'flymake )
2018-07-11 07:23:23 +00:00
( declare-function iedit-find-current-occurrence-overlay 'iedit-lib )
( declare-function iedit-prev-occurrence 'iedit-lib )
( declare-function image-get-display-property 'image-mode )
2018-12-05 19:26:27 +00:00
( declare-function lsp-mode-line 'lsp-mode )
2018-07-11 07:23:23 +00:00
( declare-function magit-toplevel 'magit-git )
2018-12-20 17:41:39 +00:00
( declare-function minions-minor-modes-menu 'minions )
2019-01-04 18:17:29 +00:00
( declare-function nyan-create 'nyan-mode )
2019-01-08 15:45:25 +00:00
( declare-function parrot-create 'parrot )
2018-12-05 15:09:11 +00:00
( declare-function persp-add-buffer 'persp-mode )
2018-12-11 14:20:21 +00:00
( declare-function persp-contain-buffer-p 'persp-mode )
2018-12-05 15:09:11 +00:00
( declare-function persp-remove-buffer 'persp-mode )
2018-12-05 18:12:17 +00:00
( declare-function persp-switch 'persp-mode )
2018-11-11 16:48:20 +00:00
( declare-function project-current 'project )
( declare-function project-roots 'project )
( declare-function projectile-project-root 'projectile )
2018-11-27 18:48:16 +00:00
( declare-function symbol-overlay-assoc 'symbol-overlay )
( declare-function symbol-overlay-get-list 'symbol-overlay )
( declare-function symbol-overlay-get-symbol 'symbol-overlay )
2018-12-16 10:09:26 +00:00
( declare-function undo-tree-redo 'undo-tree )
2018-11-27 14:54:35 +00:00
( declare-function undo-tree-undo 'undo-tree )
2018-07-11 07:23:23 +00:00
( declare-function window-numbering-clear-mode-line 'window-numbering )
( declare-function window-numbering-get-number-string 'window-numbering )
( declare-function window-numbering-install-mode-line 'window-numbering )
2018-10-24 10:14:08 +00:00
( declare-function winum--clear-mode-line 'winum )
( declare-function winum--install-mode-line 'winum )
2018-07-11 07:23:23 +00:00
( declare-function winum-get-number-string 'winum )
2018-07-02 11:05:53 +00:00
2018-11-27 18:48:16 +00:00
2018-06-26 18:38:48 +00:00
;;
;; Custom faces
;;
( defgroup doom-modeline nil
2018-06-30 18:19:54 +00:00
" Doom mode-line faces. "
2018-06-26 18:38:48 +00:00
:group 'faces )
( defface doom-modeline-buffer-path
' ( ( t ( :inherit ( mode-line-emphasis bold ) ) ) )
2018-06-30 18:19:54 +00:00
" Face used for the dirname part of the buffer path. " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-buffer-file
' ( ( t ( :inherit ( mode-line-buffer-id bold ) ) ) )
2018-06-30 18:19:54 +00:00
" Face used for the filename part of the mode-line buffer path. " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-buffer-modified
' ( ( t ( :inherit ( error bold ) :background nil ) ) )
2018-06-30 18:19:54 +00:00
" Face used for the 'unsaved' symbol in the mode-line. " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-buffer-major-mode
' ( ( t ( :inherit ( mode-line-emphasis bold ) ) ) )
2018-06-30 18:19:54 +00:00
" Face used for the major-mode segment in the mode-line. " )
2018-06-26 18:38:48 +00:00
2018-12-05 18:12:17 +00:00
( defface doom-modeline-buffer-minor-mode
' ( ( t ( :inherit ( mode-line-buffer-id bold ) ) ) )
" Face used for the minor-modes segment in the mode-line. " )
2018-09-24 09:55:19 +00:00
( defface doom-modeline-project-root-dir
' ( ( t ( :inherit ( mode-line-emphasis bold ) ) ) )
" Face used for the project part of the mode-line buffer path. " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-highlight
' ( ( t ( :inherit mode-line-emphasis ) ) )
2018-06-30 18:19:54 +00:00
" Face for bright segments of the mode-line. " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-panel
' ( ( t ( :inherit mode-line-highlight ) ) )
2018-12-22 15:58:36 +00:00
" Face for 'X out of Y' segments, such as `doom-modeline--anzu' ,
` doom-modeline--evil-substitute ' and ` iedit ' " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-info
` ( ( t ( :inherit ( success bold ) ) ) )
2018-06-30 18:19:54 +00:00
" Face for info-level messages in the modeline. Used by `*vc' . " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-warning
` ( ( t ( :inherit ( warning bold ) ) ) )
2018-06-30 18:19:54 +00:00
" Face for warnings in the modeline. Used by `*flycheck' " )
2018-06-26 18:38:48 +00:00
( defface doom-modeline-urgent
` ( ( t ( :inherit ( error bold ) ) ) )
2018-06-30 18:19:54 +00:00
" Face for errors in the modeline. Used by `*flycheck' " )
2018-06-26 18:38:48 +00:00
;; Bar
( defface doom-modeline-bar ' ( ( t ( :inherit highlight ) ) )
2018-06-30 18:19:54 +00:00
" The face used for the left-most bar on the mode-line of an active window. " )
2018-06-26 18:38:48 +00:00
2018-12-24 19:35:24 +00:00
( defface doom-modeline-eldoc-bar ` ( ( t ( :background , ( face-foreground 'success ) ) ) )
2018-12-22 15:58:36 +00:00
" The face used for the left-most bar on the mode-line when eldoc-eval is active. " )
2018-06-26 18:38:48 +00:00
2018-12-22 15:58:36 +00:00
( defface doom-modeline-inactive-bar ` ( ( t ( :background , ( face-foreground 'mode-line-inactive ) ) ) )
2018-06-30 18:19:54 +00:00
" The face used for the left-most bar on the mode-line of an inactive window. " )
2018-06-26 18:38:48 +00:00
2018-08-21 22:32:27 +00:00
( defface doom-modeline-evil-emacs-state ' ( ( t ( :inherit doom-modeline-warning ) ) )
" Face for the Emacs state tag in evil state indicator. " )
2018-12-04 18:38:36 +00:00
( defface doom-modeline-evil-insert-state ' ( ( t ( :inherit doom-modeline-urgent ) ) )
2018-08-21 22:32:27 +00:00
" Face for the insert state tag in evil state indicator. " )
2018-12-04 18:38:36 +00:00
( defface doom-modeline-evil-motion-state ' ( ( t :inherit doom-modeline-buffer-path ) )
2018-08-21 22:32:27 +00:00
" Face for the motion state tag in evil state indicator. " )
2018-12-04 18:38:36 +00:00
( defface doom-modeline-evil-normal-state ' ( ( t ( :inherit doom-modeline-info ) ) )
2018-08-21 22:32:27 +00:00
" Face for the normal state tag in evil state indicator. " )
2018-12-04 18:38:36 +00:00
( defface doom-modeline-evil-operator-state ' ( ( t ( :inherit doom-modeline-buffer-path ) ) )
2018-08-21 22:32:27 +00:00
" Face for the operator state tag in evil state indicator. " )
2018-12-04 18:38:36 +00:00
( defface doom-modeline-evil-visual-state ' ( ( t ( :inherit doom-modeline-buffer-file ) ) )
2018-08-21 22:32:27 +00:00
" Face for the visual state tag in evil state indicator. " )
2018-12-04 18:38:36 +00:00
( defface doom-modeline-evil-replace-state ' ( ( t ( :inherit doom-modeline-buffer-modified ) ) )
" Face for the replace state tag in evil state indicator. " )
( defface doom-modeline-persp-name ' ( ( t ( :inherit font-lock-comment-face :italic t ) ) )
" Face for the replace state tag in evil state indicator. " )
2018-12-04 20:30:01 +00:00
( defface doom-modeline-persp-buffer-not-in-persp ' ( ( t ( :inherit font-lock-doc-face :bold t ) ) )
2018-08-22 23:58:44 +00:00
" Face for the replace state tag in evil state indicator. " )
2018-06-11 17:13:02 +00:00
2018-11-21 18:46:51 +00:00
2018-06-13 18:30:36 +00:00
;;
;; Modeline library
;;
2018-06-15 06:53:45 +00:00
( eval-and-compile
( defvar doom-modeline-fn-alist ( ) )
( defvar doom-modeline-var-alist ( ) ) )
2018-06-11 17:13:02 +00:00
2018-06-19 10:23:22 +00:00
( defmacro doom-modeline-def-segment ( name &rest body )
2018-06-30 18:19:54 +00:00
" Defines a modeline segment NAME with BODY and byte compiles it. "
2018-06-13 18:30:36 +00:00
( declare ( indent defun ) ( doc-string 2 ) )
( let ( ( sym ( intern ( format " doom-modeline-segment--%s " name ) ) )
( docstring ( if ( stringp ( car body ) )
( pop body )
( format " %s modeline segment " name ) ) ) )
( cond ( ( and ( symbolp ( car body ) )
( not ( cdr body ) ) )
2018-06-27 06:32:23 +00:00
( add-to-list 'doom-modeline-var-alist ( cons name ( car body ) ) )
` ( add-to-list 'doom-modeline-var-alist ( cons ',name ', ( car body ) ) ) )
2018-06-13 18:30:36 +00:00
( t
2018-06-27 06:32:23 +00:00
( add-to-list 'doom-modeline-fn-alist ( cons name sym ) )
2018-06-13 18:30:36 +00:00
` ( progn
( fset ',sym ( lambda ( ) , docstring ,@ body ) )
2018-06-27 06:32:23 +00:00
( add-to-list 'doom-modeline-fn-alist ( cons ',name ',sym ) )
2018-06-13 18:30:36 +00:00
, ( unless ( bound-and-true-p byte-compile-current-file )
` ( let ( byte-compile-warnings )
( byte-compile #' , sym ) ) ) ) ) ) ) )
2018-09-30 10:06:32 +00:00
( defun doom-modeline--prepare-segments ( segments )
2018-06-19 10:23:22 +00:00
" Prepare mode-line `SEGMENTS' . "
2018-06-13 18:30:36 +00:00
( let ( forms it )
( dolist ( seg segments )
( cond ( ( stringp seg )
( push seg forms ) )
( ( symbolp seg )
( cond ( ( setq it ( cdr ( assq seg doom-modeline-fn-alist ) ) )
2018-09-30 10:06:32 +00:00
( push ( list :eval ( list it ) ) forms ) )
2018-06-13 18:30:36 +00:00
( ( setq it ( cdr ( assq seg doom-modeline-var-alist ) ) )
( push it forms ) )
( ( error " %s is not a defined segment " seg ) ) ) )
( ( error " %s is not a valid segment " seg ) ) ) )
( nreverse forms ) ) )
2018-08-16 03:30:23 +00:00
( defun doom-modeline-def-modeline ( name lhs &optional rhs )
2018-06-19 10:23:22 +00:00
" Defines a modeline format and byte-compiles it.
2018-11-28 18:34:58 +00:00
NAME is a symbol to identify it ( used by ` doom-modeline ' for retrieval ) .
LHS and RHS are lists of symbols of modeline segments defined with
` doom-modeline-def-segment '.
2018-06-30 18:19:54 +00:00
2018-11-28 18:34:58 +00:00
Example:
2018-08-16 03:30:23 +00:00
( doom-modeline-def-modeline 'minimal
2018-11-28 18:34:58 +00:00
' ( bar matches \" \" buffer-info )
' ( media-info major-mode ) )
2018-06-19 11:08:55 +00:00
( doom-modeline-set-modeline 'minimal t ) "
2018-06-11 17:13:02 +00:00
( let ( ( sym ( intern ( format " doom-modeline-format--%s " name ) ) )
2018-06-13 18:30:36 +00:00
( lhs-forms ( doom-modeline--prepare-segments lhs ) )
( rhs-forms ( doom-modeline--prepare-segments rhs ) ) )
2018-08-16 03:30:23 +00:00
( defalias sym
( lambda ( )
2018-10-19 21:33:18 +00:00
( let ( ( rhs-str ( format-mode-line ( cons " " rhs-forms ) ) ) )
2018-09-30 10:06:32 +00:00
( list lhs-forms
( propertize
" " 'display
` ( ( space :align-to ( - ( + right right-fringe right-margin )
, ( + 1 ( string-width rhs-str ) ) ) ) ) )
rhs-str ) ) )
2018-08-16 03:30:23 +00:00
( concat " Modeline: \n "
( format " %s \n %s "
( prin1-to-string lhs )
2018-10-17 15:42:44 +00:00
( prin1-to-string rhs ) ) ) ) ) )
2018-12-07 19:07:41 +00:00
( put 'doom-modeline-def-modeline 'lisp-indent-function 'defun )
2018-06-11 17:13:02 +00:00
( defun doom-modeline ( key )
2018-06-19 10:23:22 +00:00
" Return a mode-line configuration associated with KEY (a symbol).
2018-11-28 18:34:58 +00:00
Throws an error if it doesn 't exist. "
2018-08-13 11:00:39 +00:00
( let ( ( fn ( intern-soft ( format " doom-modeline-format--%s " key ) ) ) )
2018-06-11 17:13:02 +00:00
( when ( functionp fn )
` ( :eval ( , fn ) ) ) ) )
2018-06-19 11:08:55 +00:00
( defun doom-modeline-set-modeline ( key &optional default )
2018-06-19 10:23:22 +00:00
" Set the modeline format. Does nothing if the modeline KEY doesn't exist.
2018-11-28 18:34:58 +00:00
If DEFAULT is non-nil, set the default mode-line for all buffers. "
2018-09-10 15:00:26 +00:00
( when-let ( ( modeline ( doom-modeline key ) ) )
2018-06-11 17:13:02 +00:00
( setf ( if default
( default-value 'mode-line-format )
( buffer-local-value 'mode-line-format ( current-buffer ) ) )
2018-06-13 18:30:36 +00:00
( list " %e " modeline ) ) ) )
2018-06-11 17:13:02 +00:00
2018-10-15 12:30:22 +00:00
( defvar-local doom-modeline-project-root nil )
2018-06-13 04:23:17 +00:00
( defun doom-modeline-project-root ( )
2018-06-11 17:13:02 +00:00
" Get the path to the root of your project.
2018-06-30 18:19:54 +00:00
2018-11-13 05:24:14 +00:00
Return ` default-directory ' if no project was found. "
2018-11-24 05:02:38 +00:00
( or doom-modeline-project-root
( setq doom-modeline-project-root
2018-11-28 07:24:13 +00:00
( file-local-name
( or
2018-11-30 01:11:13 +00:00
( when ( featurep 'projectile )
( ignore-errors ( projectile-project-root ) ) )
2018-11-28 07:24:13 +00:00
( when ( featurep 'project )
2018-12-02 10:53:51 +00:00
( ignore-errors
( when-let ( ( project ( project-current ) ) )
( expand-file-name ( car ( project-roots project ) ) ) ) ) )
2018-11-28 07:24:13 +00:00
default-directory ) ) ) ) )
2018-11-13 05:24:14 +00:00
2018-11-24 05:02:38 +00:00
2018-06-11 17:13:02 +00:00
;;
2018-08-13 11:00:39 +00:00
;; Plugins
2018-06-11 17:13:02 +00:00
;;
2018-06-13 04:23:17 +00:00
( defun doom-modeline-eldoc ( text )
2018-06-26 18:38:48 +00:00
" Get eldoc TEXT for mode-line. "
2018-12-22 06:23:43 +00:00
( concat ( doom-modeline--make-xpm 'doom-modeline-eldoc-bar
doom-modeline-bar-width
doom-modeline-height )
" "
2018-06-11 17:13:02 +00:00
text ) )
;; Show eldoc in the mode-line with `eval-expression'
2018-06-13 04:23:17 +00:00
( defun doom-modeline--show-eldoc ( input )
2018-06-26 18:38:48 +00:00
" Display string INPUT in the mode-line next to minibuffer. "
2018-06-11 17:13:02 +00:00
( with-current-buffer ( eldoc-current-buffer )
( let* ( ( str ( and ( stringp input ) input ) )
2018-06-13 04:23:17 +00:00
( mode-line-format ( or ( and str ( or ( doom-modeline-eldoc str ) str ) )
2018-06-11 17:13:02 +00:00
mode-line-format ) )
mode-line-in-non-selected-windows )
( force-mode-line-update )
( sit-for eldoc-show-in-mode-line-delay ) ) ) )
2018-06-13 04:23:17 +00:00
( setq eldoc-in-minibuffer-show-fn #' doom-modeline--show-eldoc )
2018-06-11 17:13:02 +00:00
2018-07-05 08:57:53 +00:00
( eldoc-in-minibuffer-mode 1 )
2018-06-11 17:13:02 +00:00
;; anzu and evil-anzu expose current/total state that can be displayed in the
;; mode-line.
2018-08-14 09:35:36 +00:00
( defun doom-modeline-fix-anzu-count ( positions here )
" Calulate anzu counts via POSITIONS and HERE. "
( cl-loop for ( start . end ) in positions
collect t into before
when ( and ( >= here start ) ( <= here end ) )
return ( length before )
finally return 0 ) )
( advice-add #' anzu--where-is-here :override #' doom-modeline-fix-anzu-count )
;; Avoid anzu conflicts across buffers
;; (mapc #'make-variable-buffer-local
;; '(anzu--total-matched anzu--current-position anzu--state
;; anzu--cached-count anzu--cached-positions anzu--last-command
;; anzu--last-isearch-string anzu--overflow-p))
;; Ensure anzu state is cleared when searches & iedit are done
2018-11-27 15:09:30 +00:00
( with-eval-after-load 'anzu
( add-hook 'isearch-mode-end-hook #' anzu--reset-status t )
( add-hook 'iedit-mode-end-hook #' anzu--reset-status )
( advice-add #' evil-force-normal-state :after #' anzu--reset-status ) )
2018-06-11 17:13:02 +00:00
2018-06-13 04:23:17 +00:00
;; Keep `doom-modeline-current-window' up-to-date
( defvar doom-modeline-current-window ( frame-selected-window ) )
( defun doom-modeline-set-selected-window ( &rest _ )
" Set `doom-modeline-current-window' appropriately. "
2018-09-10 15:00:26 +00:00
( when-let ( ( win ( frame-selected-window ) ) )
2018-06-11 17:13:02 +00:00
( unless ( minibuffer-window-active-p win )
2018-06-13 12:43:03 +00:00
( setq doom-modeline-current-window win )
( force-mode-line-update ) ) ) )
( defun doom-modeline-unset-selected-window ( )
2018-06-26 18:38:48 +00:00
" Unset `doom-modeline-current-window' appropriately. "
2018-06-13 12:43:03 +00:00
( setq doom-modeline-current-window nil )
( force-mode-line-update ) )
2018-06-11 17:13:02 +00:00
2018-06-13 04:23:17 +00:00
( add-hook 'window-configuration-change-hook #' doom-modeline-set-selected-window )
2018-06-21 10:43:02 +00:00
( advice-add #' handle-switch-frame :after #' doom-modeline-set-selected-window )
( advice-add #' select-window :after #' doom-modeline-set-selected-window )
2018-10-27 19:16:31 +00:00
( advice-add #' make-frame :after #' doom-modeline-set-selected-window )
( advice-add #' delete-frame :after #' doom-modeline-set-selected-window )
2018-06-19 09:58:24 +00:00
( with-no-warnings
2018-08-13 11:00:39 +00:00
( cond ( ( not ( boundp 'after-focus-change-function ) )
( add-hook 'focus-in-hook #' doom-modeline-set-selected-window )
( add-hook 'focus-out-hook #' doom-modeline-unset-selected-window ) )
( ( defun doom-modeline-refresh-frame ( )
( setq doom-modeline-current-window nil )
( cl-loop for frame in ( frame-list )
if ( eq ( frame-focus-state frame ) t )
return ( setq doom-modeline-current-window ( frame-selected-window frame ) ) )
( force-mode-line-update ) )
( add-function :after after-focus-change-function #' doom-modeline-refresh-frame ) ) ) )
2018-06-11 17:13:02 +00:00
2018-06-21 14:30:41 +00:00
;; Show version string for multi-version managers like rvm, rbenv, pyenv, etc.
( defvar-local doom-modeline-env-version nil )
2019-01-11 21:34:47 +00:00
( defvar-local doom-modeline-env-command nil " A program that we're looking to extract version information from. Ex: \" ruby \" " )
( defvar-local doom-modeline-env-command-args nil " A list of arguments to pass to ` doom-modeline-env-command ` to extract the version from. Ex: '( \" --version \" ) " )
( defvar-local doom-modeline-env-parser nil " A function that returns version number from a programs --version (or similar) command. Ex: 'doom-version-parser--ruby " )
2018-06-21 14:30:41 +00:00
( add-hook 'find-file-hook #' doom-modeline-update-env )
2018-10-01 15:12:32 +00:00
( with-no-warnings
( if ( boundp 'after-focus-change-function )
2019-01-10 08:40:47 +00:00
( add-function :after after-focus-change-function
( lambda ( )
( if ( frame-focus-state )
( doom-modeline-update-env ) ) ) )
2018-10-01 15:12:32 +00:00
( add-hook 'focus-in-hook #' doom-modeline-update-env ) ) )
2018-06-21 14:30:41 +00:00
( defun doom-modeline-update-env ( )
2018-06-26 18:38:48 +00:00
" Update environment info on mode-line. "
2019-01-11 21:34:47 +00:00
( when ( and doom-modeline-version
doom-modeline-env-command
( executable-find doom-modeline-env-command )
doom-modeline-env-command-args
doom-modeline-env-parser )
( let ( ( default-directory ( doom-modeline-project-root ) ) )
( doom-version-parser--get doom-modeline-env-command
doom-modeline-env-command-args
( lambda ( prog-version )
( setq doom-modeline-env-version ( funcall doom-modeline-env-parser prog-version ) ) ) ) ) ) )
2018-07-05 06:23:23 +00:00
2018-06-11 17:13:02 +00:00
;;
2018-06-19 09:58:24 +00:00
;; Modeline helpers
2018-06-11 17:13:02 +00:00
;;
2018-12-11 17:34:16 +00:00
( defvar doom-modeline-vspc
( propertize " " 'face 'variable-pitch )
" Text style with icons in mode-line. " )
2018-10-25 08:11:03 +00:00
( defun doom-modeline-icon-octicon ( &rest args )
2018-11-22 17:13:52 +00:00
" Display octicon via ARGS. "
2018-10-25 08:11:03 +00:00
( when doom-modeline-icon
2018-12-29 15:14:20 +00:00
( apply #' all-the-icons-octicon args ) ) )
2018-06-11 17:13:02 +00:00
2018-10-25 08:11:03 +00:00
( defun doom-modeline-icon-faicon ( &rest args )
2018-11-22 17:13:52 +00:00
" Display font awesome icon via ARGS. "
2018-10-25 08:11:03 +00:00
( when doom-modeline-icon
2018-12-29 15:14:20 +00:00
( apply #' all-the-icons-faicon args ) ) )
2018-06-11 17:13:02 +00:00
2018-10-25 08:11:03 +00:00
( defun doom-modeline-icon-material ( &rest args )
2018-11-22 17:13:52 +00:00
" Display material icon via ARGS. "
2018-10-25 08:11:03 +00:00
( when doom-modeline-icon
2018-12-29 15:14:20 +00:00
( apply #' all-the-icons-material args ) ) )
2018-06-11 17:13:02 +00:00
2018-11-22 17:13:52 +00:00
( defun doom-modeline-icon-for-mode ( &rest args )
" Display icon for major mode via ARGS. "
( when doom-modeline-icon
2018-12-29 15:14:20 +00:00
( apply #' all-the-icons-icon-for-mode args ) ) )
2018-11-22 17:13:52 +00:00
2018-12-24 21:42:47 +00:00
( defun doom-modeline-icon-for-file ( &rest args )
" Display icon for major mode via ARGS. "
( when doom-modeline-icon
2018-12-29 15:14:20 +00:00
( apply #' all-the-icons-icon-for-file args ) ) )
2018-12-24 21:42:47 +00:00
2019-01-09 19:29:15 +00:00
( defun doom-modeline-icon-height ( height )
" Calculate the actual HEIGHT of the icon. "
( * ( / height 1.2 ) all-the-icons-scale-factor ) )
2018-08-16 03:30:23 +00:00
( defun doom-modeline--active ( )
2018-06-26 18:38:48 +00:00
" Whether is an active window. "
2018-06-13 04:23:17 +00:00
( eq ( selected-window ) doom-modeline-current-window ) )
2018-06-11 17:13:02 +00:00
2018-06-13 12:43:03 +00:00
( defun doom-modeline--make-xpm ( face width height )
2018-06-30 18:19:54 +00:00
" Create an XPM bitmap via FACE, WIDTH and HEIGHT. Inspired by `powerline' 's `pl/make-xpm' . "
2018-06-11 17:13:02 +00:00
( propertize
" " 'display
( let ( ( data ( make-list height ( make-list width 1 ) ) )
2018-06-19 09:58:24 +00:00
( color ( or ( face-background face nil t ) " None " ) ) )
2018-06-13 12:43:03 +00:00
( ignore-errors
( create-image
( concat
( format " /* XPM */ \n static char * percent[] = { \n \" %i %i 2 1 \" , \n \" . c %s \" , \n \" c %s \" , "
( length ( car data ) )
( length data )
color
color )
( apply #' concat
( cl-loop with idx = 0
with len = ( length data )
for dl in data
do ( cl-incf idx )
collect
( concat " \" "
( cl-loop for d in dl
if ( = d 0 ) collect ( string-to-char " " )
else collect ( string-to-char " . " ) )
( if ( eq idx len ) " \" }; " " \" , \n " ) ) ) ) )
2018-11-13 11:35:17 +00:00
'xpm t :ascent 'center ) ) ) ) )
2018-06-11 17:13:02 +00:00
2018-11-13 19:58:21 +00:00
( defun doom-modeline-buffer-file-name ( )
2018-09-24 14:54:25 +00:00
" Propertized variable `buffer-file-name' based on `doom-modeline-buffer-file-name-style' . "
2018-12-03 07:24:25 +00:00
( let* ( ( buffer-file-name ( file-local-name ( or ( buffer-file-name ( buffer-base-buffer ) ) " " ) ) )
( buffer-file-truename ( file-local-name ( or buffer-file-truename ( file-truename buffer-file-name ) " " ) ) ) )
2018-11-13 19:58:21 +00:00
( propertize
( pcase doom-modeline-buffer-file-name-style
( ` truncate-upto-project
( doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink ) )
2018-11-20 15:11:29 +00:00
( ` truncate-from-project
( doom-modeline--buffer-file-name buffer-file-name buffer-file-truename nil 'shrink ) )
2018-11-17 19:26:00 +00:00
( ` truncate-with-project
2018-11-20 15:11:29 +00:00
( doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shink 'hide ) )
( ` truncate-except-project
( doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shink ) )
2018-11-13 19:58:21 +00:00
( ` truncate-upto-root
( doom-modeline--buffer-file-name-truncate buffer-file-name buffer-file-truename ) )
( ` truncate-all
( doom-modeline--buffer-file-name-truncate buffer-file-name buffer-file-truename t ) )
( ` relative-to-project
( doom-modeline--buffer-file-name-relative buffer-file-name buffer-file-truename ) )
( ` relative-from-project
( doom-modeline--buffer-file-name-relative buffer-file-name buffer-file-truename 'include-project ) )
2018-11-22 16:12:36 +00:00
( style
( propertize
( pcase style
( ` file-name ( file-name-nondirectory buffer-file-name ) )
( ` buffer-name ( buffer-name ) ) )
'face
( let ( ( face ( or ( and ( buffer-modified-p )
'doom-modeline-buffer-modified )
( and ( doom-modeline--active )
'doom-modeline-buffer-file ) ) ) )
( when face ` ( :inherit , face ) ) ) ) ) )
2018-12-03 16:22:20 +00:00
'help-echo ( concat buffer-file-truename
2018-12-04 18:38:36 +00:00
( unless ( string= ( file-name-nondirectory buffer-file-truename )
( buffer-name ) )
2018-12-06 16:43:59 +00:00
( concat " \n " ( buffer-name ) ) )
" \n mouse-1: Previous buffer \n mouse-3: Next buffer " )
'local-map mode-line-buffer-identification-keymap ) ) )
2018-06-11 17:13:02 +00:00
2018-09-24 14:54:25 +00:00
( defun doom-modeline--buffer-file-name-truncate ( file-path true-file-path &optional truncate-tail )
2018-10-24 10:17:02 +00:00
" Propertized variable `buffer-file-name' that truncates every dir along path.
2018-07-02 08:28:16 +00:00
If TRUNCATE-TAIL is t also truncate the parent directory of the file. "
2018-09-24 14:54:25 +00:00
( let ( ( dirs ( shrink-path-prompt ( file-name-directory true-file-path ) ) )
2018-06-19 09:58:24 +00:00
( active ( doom-modeline--active ) ) )
2018-06-11 17:13:02 +00:00
( if ( null dirs )
2018-06-19 09:58:24 +00:00
( propertize " %b " 'face ( if active 'doom-modeline-buffer-file ) )
2018-06-11 17:13:02 +00:00
( let ( ( modified-faces ( if ( buffer-modified-p ) 'doom-modeline-buffer-modified ) ) )
( let ( ( dirname ( car dirs ) )
( basename ( cdr dirs ) )
2018-06-19 09:58:24 +00:00
( dir-faces ( or modified-faces ( if active 'doom-modeline-project-root-dir ) ) )
( file-faces ( or modified-faces ( if active 'doom-modeline-buffer-file ) ) ) )
2018-06-11 17:13:02 +00:00
( concat ( propertize ( concat dirname
( if truncate-tail ( substring basename 0 1 ) basename )
" / " )
'face ( if dir-faces ` ( :inherit , dir-faces ) ) )
2018-09-24 14:54:25 +00:00
( propertize ( file-name-nondirectory file-path )
2018-06-11 17:13:02 +00:00
'face ( if file-faces ` ( :inherit , file-faces ) ) ) ) ) ) ) ) )
2018-09-24 14:54:25 +00:00
( defun doom-modeline--buffer-file-name-relative ( _file-path true-file-path &optional include-project )
" Propertized variable `buffer-file-name' showing directories relative to project's root only. "
2018-06-13 04:23:17 +00:00
( let ( ( root ( doom-modeline-project-root ) )
2018-06-13 11:42:23 +00:00
( active ( doom-modeline--active ) ) )
2018-06-11 17:13:02 +00:00
( if ( null root )
2018-06-13 11:42:23 +00:00
( propertize " %b " 'face ( if active 'doom-modeline-buffer-file ) )
2018-06-11 17:13:02 +00:00
( let* ( ( modified-faces ( if ( buffer-modified-p ) 'doom-modeline-buffer-modified ) )
2018-09-24 14:54:25 +00:00
( relative-dirs ( file-relative-name ( file-name-directory true-file-path )
2018-06-11 17:13:02 +00:00
( if include-project ( concat root " ../ " ) root ) ) )
2018-06-13 11:42:23 +00:00
( relative-faces ( or modified-faces ( if active 'doom-modeline-buffer-path ) ) )
( file-faces ( or modified-faces ( if active 'doom-modeline-buffer-file ) ) ) )
2018-06-11 17:13:02 +00:00
( if ( equal " ./ " relative-dirs ) ( setq relative-dirs " " ) )
( concat ( propertize relative-dirs 'face ( if relative-faces ` ( :inherit , relative-faces ) ) )
2018-09-24 14:54:25 +00:00
( propertize ( file-name-nondirectory true-file-path )
2018-06-11 17:13:02 +00:00
'face ( if file-faces ` ( :inherit , file-faces ) ) ) ) ) ) ) )
2018-11-20 15:11:29 +00:00
( defun doom-modeline--buffer-file-name ( file-path _true-file-path &optional truncate-project-root-parent truncate-project-relative-path hide-project-root-parent )
" Propertized variable `buffer-file-name' given by FILE-PATH.
If TRUNCATE-PROJECT-ROOT-PARENT is non-nil will be saved by truncating project
root parent down fish-shell style.
2018-06-30 18:19:54 +00:00
2018-07-02 07:51:25 +00:00
Example:
2018-11-20 15:11:29 +00:00
~/Projects/FOSS/emacs/lisp/comint.el => ~/P/F/emacs/lisp/comint.el
If TRUNCATE-PROJECT-RELATIVE-PATH is non-nil will be saved by truncating project
relative path down fish-shell style.
Example:
~/Projects/FOSS/emacs/lisp/comint.el => ~/Projects/FOSS/emacs/l/comint.el
If HIDE-PROJECT-ROOT-PARENT is non-nil will hide project root parent.
Example:
~/Projects/FOSS/emacs/lisp/comint.el => emacs/lisp/comint.el "
( let ( ( project-root ( doom-modeline-project-root ) )
( active ( doom-modeline--active ) )
( modified-faces ( if ( buffer-modified-p ) 'doom-modeline-buffer-modified ) ) )
( let ( ( sp-faces ( or modified-faces ( if active 'font-lock-comment-face ) ) )
( project-faces ( or modified-faces ( if active 'font-lock-string-face ) ) )
( relative-faces ( or modified-faces ( if active 'doom-modeline-buffer-path ) ) )
( file-faces ( or modified-faces ( if active 'doom-modeline-buffer-file ) ) ) )
( let ( ( sp-props ` ( ,@ ( if sp-faces ` ( :inherit , sp-faces ) ) ,@ ( if active ' ( :weight bold ) ) ) )
( project-props ` ( ,@ ( if project-faces ` ( :inherit , project-faces ) ) ,@ ( if active ' ( :weight bold ) ) ) )
( relative-props ` ( ,@ ( if relative-faces ` ( :inherit , relative-faces ) ) ) )
( file-props ` ( ,@ ( if file-faces ` ( :inherit , file-faces ) ) ) ) )
( concat
;; project root parent
( unless hide-project-root-parent
2018-12-03 07:24:25 +00:00
( when-let ( root-path-parent
( file-name-directory ( directory-file-name project-root ) ) )
( propertize
2018-11-21 21:07:45 +00:00
( if ( and truncate-project-root-parent
( not ( string-empty-p root-path-parent ) )
2018-12-04 18:38:36 +00:00
( not ( string= root-path-parent " / " ) ) )
2018-11-20 15:11:29 +00:00
( shrink-path--dirs-internal root-path-parent t )
2018-12-03 07:24:25 +00:00
( abbreviate-file-name root-path-parent ) )
'face sp-props ) ) )
2018-11-20 15:11:29 +00:00
;; project
( propertize
( concat ( file-name-nondirectory ( directory-file-name project-root ) ) " / " )
'face project-props )
;; relative path
( propertize
( when-let ( relative-path ( file-relative-name
( or ( file-name-directory file-path ) " ./ " )
project-root ) )
2018-12-04 18:38:36 +00:00
( if ( string= relative-path " ./ " )
2018-11-20 15:11:29 +00:00
" "
( if truncate-project-relative-path
( substring ( shrink-path--dirs-internal relative-path t ) 1 )
relative-path ) ) )
'face relative-props )
;; file name
( propertize ( file-name-nondirectory file-path ) 'face file-props ) ) ) ) ) )
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
;; buffer information
2018-06-11 17:13:02 +00:00
;;
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment buffer-default-directory
2018-06-19 11:01:56 +00:00
" Displays `default-directory' . This is for special buffers like the scratch
2018-06-11 17:13:02 +00:00
buffer where knowing the current project directory is important. "
2018-06-19 11:01:56 +00:00
( let ( ( face ( if ( doom-modeline--active ) 'doom-modeline-buffer-path ) ) )
( concat ( if ( display-graphic-p ) " " )
2018-10-25 08:11:03 +00:00
( doom-modeline-icon-octicon
2018-06-19 11:01:56 +00:00
" file-directory "
:face face
:v-adjust -0.05
:height 1.25 )
( propertize ( concat " " ( abbreviate-file-name default-directory ) )
'face face ) ) ) )
2018-06-19 10:23:22 +00:00
;;
2018-11-24 09:10:11 +00:00
( defvar-local doom-modeline--buffer-file-icon nil )
( defun doom-modeline-update-buffer-file-icon ( &rest _ )
" Update file icon in mode-line. "
( setq doom-modeline--buffer-file-icon
2019-01-09 19:29:15 +00:00
( let* ( ( height ( / all-the-icons-scale-factor 1.3 ) )
( icon ( doom-modeline-icon-for-mode major-mode :height height ) ) )
2018-12-24 21:42:47 +00:00
( if ( symbolp icon )
2019-01-09 19:29:15 +00:00
( setq icon ( doom-modeline-icon-for-file ( buffer-name ) :height height ) ) )
2018-11-24 09:10:11 +00:00
( unless ( symbolp icon )
2018-12-24 16:00:02 +00:00
( propertize icon
2018-12-28 07:48:47 +00:00
'help-echo ( format " Major-mode: %s " mode-name )
2018-12-24 16:00:02 +00:00
'display ' ( raise -0.125 ) ) ) ) ) )
2019-01-04 18:08:16 +00:00
( add-hook 'find-file-hook #' doom-modeline-update-buffer-file-icon )
( add-hook 'after-revert-hook #' doom-modeline-update-buffer-file-icon )
( add-hook 'after-change-major-mode-hook #' doom-modeline-update-buffer-file-icon )
( add-hook 'clone-indirect-buffer-hook #' doom-modeline-update-buffer-file-icon )
2018-11-24 09:10:11 +00:00
2018-12-19 08:27:20 +00:00
( defun doom-modeline-buffer-file-state-icon ( icon &optional face height voffset )
" Displays an ICON with FACE, HEIGHT and VOFFSET.
Uses ` all-the-icons-material ' to fetch the icon. "
( when icon
( doom-modeline-icon-material
icon
:face ( if ( doom-modeline--active ) face )
2018-12-31 13:06:27 +00:00
:height ( or height 1.1 )
:v-adjust ( or voffset -0.225 ) ) ) )
2018-12-19 08:27:20 +00:00
2018-11-24 09:10:11 +00:00
( defvar-local doom-modeline--buffer-file-state-icon nil )
( defun doom-modeline-update-buffer-file-state-icon ( &rest _ )
" Update the buffer or file state in mode-line. "
( setq doom-modeline--buffer-file-state-icon
2018-12-19 08:27:20 +00:00
( cond ( buffer-read-only
2018-12-24 16:00:02 +00:00
( doom-modeline-buffer-file-state-icon
" lock "
2018-12-29 16:15:35 +00:00
'doom-modeline-warning ) )
2018-12-19 08:27:20 +00:00
( ( buffer-modified-p )
2018-12-24 16:00:02 +00:00
( doom-modeline-buffer-file-state-icon
" save "
2018-12-28 15:27:46 +00:00
'doom-modeline-buffer-modified ) )
2018-12-19 08:27:20 +00:00
( ( and buffer-file-name
( not ( file-exists-p buffer-file-name ) ) )
2018-12-24 16:00:02 +00:00
( doom-modeline-buffer-file-state-icon
" do_not_disturb_alt "
2018-12-29 16:15:35 +00:00
'doom-modeline-urgent ) )
2018-12-19 08:27:20 +00:00
( ( buffer-narrowed-p )
2018-12-24 16:00:02 +00:00
( doom-modeline-buffer-file-state-icon
2018-12-28 15:27:46 +00:00
" vertical_align_center "
'doom-modeline-warning ) ) ) ) )
2019-01-04 18:08:16 +00:00
( add-hook 'find-file-hook #' doom-modeline-update-buffer-file-state-icon )
( add-hook 'after-save-hook #' doom-modeline-update-buffer-file-state-icon )
( add-hook 'after-revert-hook #' doom-modeline-update-buffer-file-state-icon )
( add-hook 'read-only-mode-hook #' doom-modeline-update-buffer-file-state-icon )
( add-hook 'after-change-functions #' doom-modeline-update-buffer-file-state-icon )
( add-hook 'clone-indirect-buffer-hook #' doom-modeline-update-buffer-file-state-icon )
2018-11-24 09:10:11 +00:00
( advice-add #' undo :after #' doom-modeline-update-buffer-file-state-icon )
( advice-add #' undo-tree-undo :after #' doom-modeline-update-buffer-file-state-icon )
2018-12-12 17:01:49 +00:00
( advice-add #' undo-tree-redo :after #' doom-modeline-update-buffer-file-state-icon )
2018-11-24 09:10:11 +00:00
( advice-add #' narrow-to-region :after #' doom-modeline-update-buffer-file-state-icon )
2018-12-19 10:18:24 +00:00
( advice-add #' widen :after #' doom-modeline-update-buffer-file-state-icon )
2019-01-05 11:24:59 +00:00
;; (advice-add #'set-buffer-modified-p :after #'doom-modeline-update-buffer-file-state-icon)
2018-11-24 09:10:11 +00:00
2018-12-16 14:22:57 +00:00
( when ( >= emacs-major-version 26 )
( add-variable-watcher
'buffer-read-only
2019-01-04 14:34:45 +00:00
( lambda ( _sym val op _where )
2018-12-16 14:22:57 +00:00
( when ( eq op 'set )
2019-01-04 14:34:45 +00:00
( setq buffer-read-only val )
2019-01-09 19:29:15 +00:00
( doom-modeline-update-buffer-file-state-icon ) ) ) )
( add-variable-watcher
'all-the-icons-scale-factor
( lambda ( _sym val op _where )
( when ( eq op 'set )
( setq all-the-icons-scale-factor val )
( doom-modeline-update-buffer-file-icon )
2018-12-16 14:22:57 +00:00
( doom-modeline-update-buffer-file-state-icon ) ) ) ) )
2018-12-16 10:09:26 +00:00
2018-11-24 09:10:11 +00:00
( defvar-local doom-modeline--buffer-file-name nil )
( defun doom-modeline-update-buffer-file-name ( &rest _ )
" Update buffer file name in mode-line. "
( setq doom-modeline--buffer-file-name
( if buffer-file-name
2018-12-03 16:22:20 +00:00
( doom-modeline-buffer-file-name )
2018-12-06 16:43:59 +00:00
( propertize " %b "
'face ( if ( doom-modeline--active ) 'doom-modeline-buffer-file )
2018-12-20 16:35:59 +00:00
'help-echo " Buffer name
mouse-1: Previous buffer\nmouse-3: Next buffer "
2018-12-06 16:43:59 +00:00
'local-map mode-line-buffer-identification-keymap ) ) ) )
2019-01-04 18:08:16 +00:00
( add-hook 'find-file-hook #' doom-modeline-update-buffer-file-name )
( add-hook 'after-save-hook #' doom-modeline-update-buffer-file-name )
( add-hook 'after-revert-hook #' doom-modeline-update-buffer-file-name )
( add-hook 'after-change-functions #' doom-modeline-update-buffer-file-name )
( add-hook 'clone-indirect-buffer-hook #' doom-modeline-update-buffer-file-name )
2018-11-24 09:10:11 +00:00
( advice-add #' rename-buffer :after #' doom-modeline-update-buffer-file-name )
( advice-add #' set-visited-file-name :after #' doom-modeline-update-buffer-file-name )
2019-01-01 10:04:53 +00:00
;; (advice-add #'select-window :after #'doom-modeline-update-buffer-file-name)
2018-11-24 09:10:11 +00:00
( advice-add #' undo :after #' doom-modeline-update-buffer-file-name )
( advice-add #' undo-tree-undo :after #' doom-modeline-update-buffer-file-name )
2018-12-12 17:01:49 +00:00
( advice-add #' undo-tree-redo :after #' doom-modeline-update-buffer-file-name )
2019-01-05 11:24:59 +00:00
;; (advice-add #'set-buffer-modified-p :after #'doom-modeline-update-buffer-file-name)
2018-11-24 05:18:33 +00:00
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment buffer-info
2018-06-19 11:01:56 +00:00
" Combined information about the current buffer, including the current working
2018-06-11 17:13:02 +00:00
directory, the file name, and its state ( modified, read-only or non-existent ) . "
2018-12-24 16:00:02 +00:00
( let ( ( active ( doom-modeline--active ) ) )
( concat
;; major mode icon
( when ( and doom-modeline-icon doom-modeline-major-mode-icon )
( when-let ( ( icon ( or doom-modeline--buffer-file-icon
( doom-modeline-update-buffer-file-icon ) ) ) )
( concat
( if ( and active doom-modeline-major-mode-color-icon )
icon
( propertize icon
2019-01-09 19:29:15 +00:00
'face ` ( :height
, ( doom-modeline-icon-height 1.1 )
:family
, ( all-the-icons-icon-family icon )
:inherit ) ) )
2018-12-24 16:00:02 +00:00
doom-modeline-vspc ) ) )
;; state icon
( when doom-modeline-icon
( when-let ( ( icon ( or doom-modeline--buffer-file-state-icon
( doom-modeline-update-buffer-file-state-icon ) ) ) )
( concat
( if active
icon
( propertize icon
2019-01-09 19:29:15 +00:00
'face ` ( :height
, ( doom-modeline-icon-height 1.3 )
:family
, ( all-the-icons-icon-family icon )
:inherit ) ) )
2018-12-24 16:00:02 +00:00
doom-modeline-vspc ) ) )
;; buffer file name
( let ( ( name ( or doom-modeline--buffer-file-name
( doom-modeline-update-buffer-file-name ) ) ) )
( if active
name
( propertize name 'face 'mode-line-inactive ) ) ) ) ) )
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment buffer-info-simple
2018-06-11 17:13:02 +00:00
" Display only the current buffer's name, but with fontification. "
( propertize
" %b "
'face ( cond ( ( and buffer-file-name ( buffer-modified-p ) )
'doom-modeline-buffer-modified )
2018-06-13 04:23:17 +00:00
( ( doom-modeline--active ) 'doom-modeline-buffer-file ) ) ) )
2018-06-11 17:13:02 +00:00
;;
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment buffer-encoding
2018-06-13 11:42:23 +00:00
" Displays the encoding and eol style of the buffer the same way Atom does. "
2018-12-06 17:33:13 +00:00
( propertize
( concat ( pcase ( coding-system-eol-type buffer-file-coding-system )
( 0 " LF " )
( 1 " RLF " )
( 2 " CR " ) )
( let ( ( sys ( coding-system-plist buffer-file-coding-system ) ) )
( cond ( ( memq ( plist-get sys :category ) ' ( coding-category-undecided coding-category-utf-8 ) )
" UTF-8 " )
( t ( upcase ( symbol-name ( plist-get sys :name ) ) ) ) ) )
" " )
'help-echo 'mode-line-mule-info-help-echo
2018-12-08 18:11:23 +00:00
'mouse-face ' ( :box 1 )
2018-12-06 17:33:13 +00:00
'local-map mode-line-coding-system-map ) )
2018-06-11 17:13:02 +00:00
2018-07-05 06:23:23 +00:00
2018-12-04 19:50:50 +00:00
;;
;; remote host
;;
( doom-modeline-def-segment remote-host
" Hostname for remote buffers. "
( when default-directory
( when-let ( ( host ( file-remote-p default-directory 'host ) ) )
( concat " @ " host ) ) ) )
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
;; major-mode
;;
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment major-mode
2018-08-12 16:14:32 +00:00
" The major mode, including environment and text-scale info. "
2018-06-11 17:13:02 +00:00
( propertize
2018-09-30 07:16:24 +00:00
( concat ( format-mode-line
` ( :propertize ( " " mode-name )
help-echo " Major mode \n \
mouse-1: Display major mode menu\n \
mouse-2: Show help for major mode\n \
mouse-3: Toggle minor modes "
mouse-face mode-line-highlight
local-map , mode-line-major-mode-keymap ) )
2018-12-31 14:55:23 +00:00
( when ( and doom-modeline-version doom-modeline-env-version )
2018-08-13 11:00:39 +00:00
( format " %s " doom-modeline-env-version ) )
( and ( boundp 'text-scale-mode-amount )
2018-06-11 17:13:02 +00:00
( /= text-scale-mode-amount 0 )
2018-07-07 04:40:03 +00:00
( format
( if ( > text-scale-mode-amount 0 )
" (%+d) "
" (%-d) " )
text-scale-mode-amount ) ) )
2018-06-13 04:23:17 +00:00
'face ( if ( doom-modeline--active ) 'doom-modeline-buffer-major-mode ) ) )
2018-06-11 17:13:02 +00:00
2018-08-12 16:14:32 +00:00
;;
;; process
;;
( doom-modeline-def-segment process
" The process info. "
2018-08-30 19:51:04 +00:00
mode-line-process )
2018-08-12 16:14:32 +00:00
2018-12-04 19:50:50 +00:00
;;
;; minor modes
;;
( doom-modeline-def-segment minor-modes
( when doom-modeline-minor-modes
2018-12-20 18:28:27 +00:00
( let ( ( active ( doom-modeline--active ) ) )
( if ( bound-and-true-p minions-mode )
( concat
" "
( propertize minions-mode-line-lighter
'face ( if active 'doom-modeline-buffer-minor-mode )
'help-echo " Minions
2018-12-20 17:41:39 +00:00
mouse-1: Display minor modes menu "
2018-12-20 18:28:27 +00:00
'mouse-face 'mode-line-highlight
'local-map ( make-mode-line-mouse-map
'mouse-1 #' minions-minor-modes-menu ) )
" " )
( propertize
( concat ( format-mode-line ` ( :propertize ( " " minor-mode-alist ) ) ) " " )
'face ( if active 'doom-modeline-buffer-minor-mode ) ) ) ) ) )
2018-12-04 19:50:50 +00:00
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
;; vcs
;;
2019-01-03 13:10:18 +00:00
( defun doom-modeline-vcs-icon ( icon &optional text face voffset )
" Displays the vcs ICON with FACE and VOFFSET.
TEXT is the alternative if it is not applicable.
Uses ` all-the-icons-octicon ' to fetch the icon. "
( if doom-modeline-icon
( if icon
( doom-modeline-icon-octicon icon :face face :v-adjust ( or voffset -0.1 ) )
" " )
( if text
( propertize text 'face face )
" " ) ) )
2019-01-02 18:08:35 +00:00
( defvar-local doom-modeline--vcs-icon nil )
( defun doom-modeline--update-vcs-icon ( &rest _ )
" Update icon of vsc state in mode-line. "
( setq doom-modeline--vcs-icon
2018-06-30 18:19:54 +00:00
( when ( and vc-mode buffer-file-name )
( let* ( ( backend ( vc-backend buffer-file-name ) )
( state ( vc-state buffer-file-name backend ) ) )
2019-01-03 13:10:18 +00:00
( cond ( ( memq state ' ( edited added ) )
( doom-modeline-vcs-icon " git-compare " " * " 'doom-modeline-info -0.05 ) )
( ( eq state 'needs-merge )
( doom-modeline-vcs-icon " git-merge " " ? " 'doom-modeline-info ) )
( ( eq state 'needs-update )
( doom-modeline-vcs-icon " arrow-down " " ! " 'doom-modeline-warning ) )
( ( memq state ' ( removed conflict unregistered ) )
( doom-modeline-vcs-icon " alert " " ! " 'doom-modeline-urgent ) )
( t
( doom-modeline-vcs-icon " git-branch " " @ " 'doom-modeline-info -0.05 ) ) ) ) ) ) )
2019-01-02 18:08:35 +00:00
( add-hook 'after-revert-hook #' doom-modeline--update-vcs-icon )
( add-hook 'after-save-hook #' doom-modeline--update-vcs-icon )
( add-hook 'find-file-hook #' doom-modeline--update-vcs-icon t )
( advice-add #' vc-refresh-state :after #' doom-modeline--update-vcs-icon )
( defvar-local doom-modeline--vcs-text nil )
( defun doom-modeline--update-vcs-text ( &rest _ )
" Update text of vsc state in mode-line. "
( setq doom-modeline--vcs-text
( when ( and vc-mode buffer-file-name )
( let* ( ( backend ( vc-backend buffer-file-name ) )
( state ( vc-state buffer-file-name backend ) ) )
( propertize ( substring vc-mode ( + ( if ( eq backend 'Hg ) 2 3 ) 2 ) )
'face ( cond ( ( eq state 'needs-update )
'doom-modeline-warning )
( ( memq state ' ( removed conflict unregistered ) )
'doom-modeline-urgent )
( t 'doom-modeline-info ) ) ) ) ) ) )
( add-hook 'after-revert-hook #' doom-modeline--update-vcs-text )
( add-hook 'after-save-hook #' doom-modeline--update-vcs-text )
( add-hook 'find-file-hook #' doom-modeline--update-vcs-text t )
( advice-add #' vc-refresh-state :after #' doom-modeline--update-vcs-text )
2018-06-30 18:19:54 +00:00
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment vcs
2018-06-13 11:42:23 +00:00
" Displays the current branch, colored based on its state. "
2019-01-02 18:08:35 +00:00
( let ( ( active ( doom-modeline--active ) ) )
( when-let ( ( icon ( or doom-modeline--vcs-icon ( doom-modeline--update-vcs-icon ) ) )
( text ( or doom-modeline--vcs-text ( doom-modeline--update-vcs-text ) ) ) )
2019-01-03 18:09:32 +00:00
( concat
" "
( if active
( concat icon doom-modeline-vspc text )
( concat
( propertize icon
'face
( if doom-modeline-icon
2019-01-09 19:29:15 +00:00
` ( :height
, ( doom-modeline-icon-height 1.2 )
:family
, ( all-the-icons-icon-family icon )
:inherit )
2019-01-03 18:09:32 +00:00
'mode-line-inactive ) )
doom-modeline-vspc
( propertize text 'face 'mode-line-inactive ) ) )
" " ) ) ) )
2018-06-13 04:23:17 +00:00
;;
2019-01-02 17:41:35 +00:00
;; checker
2018-06-13 12:43:03 +00:00
;;
2019-01-02 17:41:35 +00:00
;; flycheck
2019-01-03 10:13:15 +00:00
( defun doom-modeline-checker-icon ( icon &optional text face voffset )
2019-01-03 13:10:18 +00:00
" Displays the checker ICON with FACE and VOFFSET.
2019-01-03 10:13:15 +00:00
TEXT is the alternative if it is not applicable.
2018-06-19 09:58:24 +00:00
Uses ` all-the-icons-material ' to fetch the icon. "
2019-01-03 10:13:15 +00:00
( if doom-modeline-icon
( if icon
( doom-modeline-icon-material icon :face face :height 1.1 :v-adjust ( or voffset -0.225 ) )
" " )
( if text
( propertize text 'face face )
" " ) ) )
2019-01-02 17:41:35 +00:00
( defun doom-modeline-checker-text ( text &optional face )
" Displays TEXT with FACE. "
2019-01-03 10:13:15 +00:00
( if text
( propertize text 'face face )
" " ) )
2019-01-02 17:41:35 +00:00
( defvar-local doom-modeline--flycheck-icon nil )
( defun doom-modeline-update-flycheck-icon ( &optional status )
" Update flycheck icon via STATUS. "
( setq doom-modeline--flycheck-icon
2018-12-05 16:48:10 +00:00
( propertize
( pcase status
2019-01-02 17:41:35 +00:00
( ` finished ( if flycheck-current-errors
( let-alist ( flycheck-count-errors flycheck-current-errors )
2019-01-03 10:13:15 +00:00
( doom-modeline-checker-icon " do_not_disturb_alt " " ! "
2019-01-02 19:31:11 +00:00
( cond ( . error 'doom-modeline-urgent )
( . warning 'doom-modeline-warning )
( t 'doom-modeline-info ) ) ) )
2019-01-03 10:13:15 +00:00
( doom-modeline-checker-icon " check " " * " 'doom-modeline-info ) ) )
( ` running ( doom-modeline-checker-icon " access_time " " * " 'font-lock-doc-face ) )
( ` no-checker ( doom-modeline-checker-icon " sim_card_alert " " ? " 'font-lock-doc-face ) )
( ` errored ( doom-modeline-checker-icon " sim_card_alert " " ! " 'doom-modeline-urgent ) )
( ` interrupted ( doom-modeline-checker-icon " pause " " ! " 'font-lock-doc-face ) )
( ` suspicious ( doom-modeline-checker-icon " priority_high " " ! " 'doom-modeline-urgent ) )
2019-01-02 17:41:35 +00:00
( _ " " ) )
2019-01-02 12:57:54 +00:00
'help-echo ( concat " Flycheck \n "
( pcase status
2019-01-02 13:31:01 +00:00
( 'finished
2019-01-02 18:28:57 +00:00
" mouse-1: Display minor mode menu
2019-01-02 17:41:35 +00:00
mouse-2: Show help for minor mode " )
2019-01-02 12:57:54 +00:00
( 'running " Running... " )
( 'no-checker " No Checker " )
( 'errored " Error " )
( 'interrupted " Interrupted " )
( 'suspicious " Suspicious " ) ) )
2018-12-05 16:48:10 +00:00
'mouse-face ' ( :box 1 )
2019-01-02 12:57:54 +00:00
'local-map ( let ( ( map ( make-sparse-keymap ) ) )
2019-01-07 17:23:12 +00:00
( define-key map [ mode-line down-mouse-1 ]
2019-01-02 18:28:57 +00:00
flycheck-mode-menu-map )
2019-01-02 12:57:54 +00:00
( define-key map [ mode-line mouse-2 ]
( lambda ( )
( interactive )
( describe-function 'flycheck-mode ) ) )
2019-01-02 17:41:35 +00:00
map ) ) ) )
( add-hook 'flycheck-status-changed-functions #' doom-modeline-update-flycheck-icon )
( add-hook 'flycheck-mode-hook #' doom-modeline-update-flycheck-icon )
( defvar-local doom-modeline--flycheck-text nil )
( defun doom-modeline-update-flycheck-text ( &optional status )
" Update flycheck text via STATUS. "
( setq doom-modeline--flycheck-text
( propertize
( pcase status
( ` finished ( if flycheck-current-errors
( let-alist ( flycheck-count-errors flycheck-current-errors )
2019-01-02 19:31:11 +00:00
( let ( ( error ( or . error 0 ) )
( warning ( or . warning 0 ) )
( info ( or . info 0 ) ) )
( format " %s/%s/%s "
( doom-modeline-checker-text ( number-to-string error )
'doom-modeline-urgent )
( doom-modeline-checker-text ( number-to-string warning )
'doom-modeline-warning )
( doom-modeline-checker-text ( number-to-string info )
'doom-modeline-info ) ) ) )
2019-01-02 17:41:35 +00:00
" " ) )
( ` running " " )
( ` no-checker ( doom-modeline-checker-text " - " 'font-lock-doc-face ) )
( ` errored ( doom-modeline-checker-text " Error " 'doom-modeline-urgent ) )
( ` interrupted ( doom-modeline-checker-text " Interrupted " 'font-lock-doc-face ) )
( ` suspicious ( doom-modeline-checker-text " Suspicious " 'doom-modeline-urgent ) )
( _ " " ) )
'help-echo ( pcase status
( 'finished
( concat
( if flycheck-current-errors
( let-alist ( flycheck-count-errors flycheck-current-errors )
2019-01-02 19:31:11 +00:00
( format " error: %d, warning: %d, info: %d \n " ( or . error 0 ) ( or . warning 0 ) ( or . info 0 ) ) ) )
" mouse-1: Show all errors
mouse-3: Next error
wheel-up/wheel-down: Previous/next error " ))
2019-01-02 17:41:35 +00:00
( 'running " Running... " )
( 'no-checker " No Checker " )
( 'errored " Error " )
( 'interrupted " Interrupted " )
( 'suspicious " Suspicious " ) )
'mouse-face 'mode-line-highlight
'local-map ( let ( ( map ( make-sparse-keymap ) ) )
( define-key map [ mode-line mouse-1 ]
#' flycheck-list-errors )
2019-01-02 12:57:54 +00:00
( define-key map [ mode-line mouse-3 ]
#' flycheck-next-error )
( define-key map ( vector 'mode-line
mouse-wheel-down-event )
( lambda ( event )
( interactive " e " )
( with-selected-window ( posn-window ( event-start event ) )
( flycheck-previous-error 1 ) ) ) )
( define-key map ( vector 'mode-line
mouse-wheel-up-event )
( lambda ( event )
( interactive " e " )
( with-selected-window ( posn-window ( event-start event ) )
( flycheck-next-error 1 ) ) ) )
map ) ) ) )
2019-01-02 17:41:35 +00:00
( add-hook 'flycheck-status-changed-functions #' doom-modeline-update-flycheck-text )
( add-hook 'flycheck-mode-hook #' doom-modeline-update-flycheck-text )
2018-06-13 12:43:03 +00:00
2019-01-02 12:57:54 +00:00
;; flymake
2019-01-02 17:41:35 +00:00
( defvar-local doom-modeline--flymake-icon nil )
( defun doom-modeline-update-flymake-icon ( &rest _ )
" Update flymake icon. "
2019-01-02 12:57:54 +00:00
( setq flymake--mode-line-format nil ) ; remove the lighter of minor mode
2019-01-02 17:41:35 +00:00
( setq doom-modeline--flymake-icon
( let* ( ( known ( hash-table-keys flymake--backend-state ) )
( running ( flymake-running-backends ) )
( disabled ( flymake-disabled-backends ) )
( reported ( flymake-reporting-backends ) )
( diags-by-type ( make-hash-table ) )
( all-disabled ( and disabled ( null running ) ) )
( some-waiting ( cl-set-difference running reported ) ) )
( maphash ( lambda ( _b state )
( mapc ( lambda ( diag )
( push diag
( gethash ( flymake--diag-type diag )
diags-by-type ) ) )
( flymake--backend-state-diags state ) ) )
flymake--backend-state )
( propertize
( cond
2019-01-03 10:13:15 +00:00
( some-waiting ( doom-modeline-checker-icon " access_time " " * " 'font-lock-doc-face ) )
( ( null known ) ( doom-modeline-checker-icon " sim_card_alert " " ? " 'font-lock-doc-face ) )
( all-disabled ( doom-modeline-checker-icon " sim_card_alert " " ! " 'doom-modeline-urgent ) )
2019-01-02 17:41:35 +00:00
( t ( let ( ( . error ( length ( gethash :error diags-by-type ) ) )
2019-01-02 19:31:11 +00:00
( . warning ( length ( gethash :warning diags-by-type ) ) )
( . note ( length ( gethash :note diags-by-type ) ) ) )
( if ( > ( + . error . warning . note ) 0 )
2019-01-03 10:13:15 +00:00
( doom-modeline-checker-icon " do_not_disturb_alt " " ! "
2019-01-02 19:31:11 +00:00
( cond ( ( > . error 0 ) 'doom-modeline-urgent )
( ( > . warning 0 ) 'doom-modeline-warning )
( t 'doom-modeline-info ) ) )
2019-01-03 10:13:15 +00:00
( doom-modeline-checker-icon " check " " * " 'doom-modeline-info ) ) ) ) )
2019-01-02 17:41:35 +00:00
'help-echo ( concat " Flymake \n "
( cond
( some-waiting " Running... " )
( ( null known ) " No Checker " )
( all-disabled " All Checkers Disabled " )
( t ( format " %d/%d backends running
2019-01-03 17:34:36 +00:00
mouse-1: Display minor mode menu
mouse-2: Show help for minor mode "
2019-01-02 17:41:35 +00:00
( length running ) ( length known ) ) ) ) )
'mouse-face ' ( :box 1 )
'local-map ( let ( ( map ( make-sparse-keymap ) ) )
( define-key map [ mode-line down-mouse-1 ]
flymake-menu )
( define-key map [ mode-line mouse-2 ]
( lambda ( )
( interactive )
( describe-function 'flymake-mode ) ) )
map ) ) ) ) )
( advice-add #' flymake--handle-report :after #' doom-modeline-update-flymake-icon )
( defvar-local doom-modeline--flymake-text nil )
( defun doom-modeline-update-flymake-text ( &rest _ )
" Update flymake text. "
( setq flymake--mode-line-format nil ) ; remove the lighter of minor mode
( setq doom-modeline--flymake-text
2019-01-02 12:57:54 +00:00
( let* ( ( known ( hash-table-keys flymake--backend-state ) )
( running ( flymake-running-backends ) )
( disabled ( flymake-disabled-backends ) )
( reported ( flymake-reporting-backends ) )
( diags-by-type ( make-hash-table ) )
( all-disabled ( and disabled ( null running ) ) )
( some-waiting ( cl-set-difference running reported ) ) )
( maphash ( lambda ( _b state )
( mapc ( lambda ( diag )
( push diag
( gethash ( flymake--diag-type diag )
diags-by-type ) ) )
( flymake--backend-state-diags state ) ) )
flymake--backend-state )
( let ( ( . error ( length ( gethash :error diags-by-type ) ) )
( . warning ( length ( gethash :warning diags-by-type ) ) )
( . note ( length ( gethash :note diags-by-type ) ) ) )
( propertize
( cond
2019-01-02 17:41:35 +00:00
( some-waiting " Running... " " " )
( ( null known ) ( doom-modeline-checker-text " - " 'font-lock-doc-face ) )
( all-disabled ( doom-modeline-checker-text " - " 'doom-modeline-urgent ) )
2019-01-02 19:31:11 +00:00
( t ( if ( > ( + . error . warning . note ) 0 )
( format " %s/%s/%s "
( doom-modeline-checker-text ( number-to-string . error )
'doom-modeline-urgent )
( doom-modeline-checker-text ( number-to-string . warning )
'doom-modeline-warning )
( doom-modeline-checker-text ( number-to-string . note )
'doom-modeline-info ) )
" " ) ) )
2019-01-02 17:41:35 +00:00
'help-echo ( cond
( some-waiting " Running... " )
( ( null known ) " No Checker " )
( all-disabled " All Checkers Disabled " )
( t ( format " error: %d, warning: %d, note: %d
2019-01-02 19:31:11 +00:00
mouse-1: List all problems
wheel-up/wheel-down: Previous/next problem "
2019-01-02 17:41:35 +00:00
. error . warning . note ) ) )
'mouse-face 'mode-line-highlight
2019-01-02 12:57:54 +00:00
'local-map ( let ( ( map ( make-sparse-keymap ) ) )
2019-01-02 17:41:35 +00:00
( define-key map [ mode-line mouse-1 ]
2019-01-02 13:47:14 +00:00
#' flymake-show-diagnostics-buffer )
2019-01-02 12:57:54 +00:00
( define-key map ( vector 'mode-line
mouse-wheel-down-event )
( lambda ( event )
( interactive " e " )
( with-selected-window ( posn-window ( event-start event ) )
2019-01-02 19:31:11 +00:00
( flymake-goto-prev-error 1 nil t ) ) ) )
2019-01-02 12:57:54 +00:00
( define-key map ( vector 'mode-line
mouse-wheel-up-event )
( lambda ( event )
( interactive " e " )
( with-selected-window ( posn-window ( event-start event ) )
2019-01-02 19:31:11 +00:00
( flymake-goto-next-error 1 nil t ) ) ) )
2019-01-02 12:57:54 +00:00
map ) ) ) ) ) )
2019-01-02 17:41:35 +00:00
( advice-add #' flymake--handle-report :after #' doom-modeline-update-flymake-text )
2019-01-02 14:35:02 +00:00
2019-01-02 12:57:54 +00:00
( doom-modeline-def-segment checker
" Displays color-coded error status in the current buffer with pretty
icons. "
2019-01-02 17:41:35 +00:00
( let ( ( active ( doom-modeline--active ) )
( seg ( cond ( ( and ( bound-and-true-p flymake-mode )
( bound-and-true-p flymake--backend-state ) ) ; only support 26+
` ( , doom-modeline--flymake-icon . , doom-modeline--flymake-text ) )
( ( bound-and-true-p flycheck-mode )
` ( , doom-modeline--flycheck-icon . , doom-modeline--flycheck-text ) ) ) ) )
( when-let ( ( icon ( car seg ) )
( text ( cdr seg ) ) )
( concat
( if vc-mode " " " " )
( if active
( concat icon doom-modeline-vspc text )
( concat
2019-01-03 10:13:15 +00:00
( propertize icon
'face
( if doom-modeline-icon
2019-01-09 19:29:15 +00:00
` ( :height
, ( doom-modeline-icon-height 1.3 )
:family
, ( all-the-icons-icon-family icon )
:inherit )
2019-01-03 10:13:15 +00:00
'mode-line-inactive ) )
2019-01-02 17:41:35 +00:00
doom-modeline-vspc
2019-01-03 10:13:15 +00:00
( propertize text 'face 'mode-line-inactive ) ) )
2019-01-02 17:41:35 +00:00
" " ) ) ) )
2019-01-02 12:57:54 +00:00
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
;; selection-info
;;
2018-06-13 04:23:17 +00:00
( defsubst doom-modeline-column ( pos )
2018-06-26 17:34:08 +00:00
" Get the column of the position `POS' . "
2018-06-11 17:13:02 +00:00
( save-excursion ( goto-char pos )
( current-column ) ) )
2018-06-13 12:43:03 +00:00
( defvar-local doom-modeline-enable-word-count nil
" If non-nil, a word count will be added to the selection-info modeline
segment. " )
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment selection-info
2018-06-11 17:13:02 +00:00
" Information about the current selection, such as how many characters and
lines are selected, or the NxM dimensions of a block selection. "
2018-09-17 15:58:31 +00:00
( when ( and ( or mark-active ( and ( bound-and-true-p evil-local-mode )
( eq evil-state 'visual ) ) )
( doom-modeline--active ) )
2018-06-13 12:43:03 +00:00
( cl-destructuring-bind ( beg . end )
2018-09-17 15:58:31 +00:00
( if ( and ( bound-and-true-p evil-local-mode ) ( eq evil-state 'visual ) )
2018-06-13 12:43:03 +00:00
( cons evil-visual-beginning evil-visual-end )
( cons ( region-beginning ) ( region-end ) ) )
2018-06-11 17:13:02 +00:00
( propertize
2018-06-13 12:43:03 +00:00
( let ( ( lines ( count-lines beg ( min end ( point-max ) ) ) ) )
( concat ( cond ( ( or ( bound-and-true-p rectangle-mark-mode )
2018-06-30 18:19:54 +00:00
( and ( bound-and-true-p evil-visual-selection )
( eq 'block evil-visual-selection ) ) )
2018-06-26 17:34:08 +00:00
( let ( ( cols ( abs ( - ( doom-modeline-column end )
( doom-modeline-column beg ) ) ) ) )
2018-06-13 12:43:03 +00:00
( format " %dx%dB " lines cols ) ) )
2018-06-30 18:19:54 +00:00
( ( and ( bound-and-true-p evil-visual-selection )
( eq evil-visual-selection 'line ) )
2018-06-13 12:43:03 +00:00
( format " %dL " lines ) )
( ( > lines 1 )
( format " %dC %dL " ( - end beg ) lines ) )
( ( format " %dC " ( - end beg ) ) ) )
( when doom-modeline-enable-word-count
( format " %dW " ( count-words beg end ) ) ) ) )
2018-06-11 17:13:02 +00:00
'face 'doom-modeline-highlight ) ) ) )
2018-07-11 07:23:23 +00:00
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
;; matches (anzu, evil-substitute, iedit, macro)
;;
2018-06-13 04:23:17 +00:00
( defun doom-modeline--macro-recording ( )
2018-06-11 17:13:02 +00:00
" Display current Emacs or evil macro being recorded. "
2018-06-13 04:23:17 +00:00
( when ( and ( doom-modeline--active ) ( or defining-kbd-macro executing-kbd-macro ) )
2018-06-11 17:13:02 +00:00
( let ( ( sep ( propertize " " 'face 'doom-modeline-panel ) ) )
( concat sep
( propertize ( if ( bound-and-true-p evil-this-macro )
( char-to-string evil-this-macro )
" Macro " )
'face 'doom-modeline-panel )
sep
2018-10-25 08:11:03 +00:00
( doom-modeline-icon-octicon " triangle-right "
2018-11-13 11:35:17 +00:00
:face 'doom-modeline-panel
:v-adjust -0.05 )
2018-06-13 12:43:03 +00:00
sep ) ) ) )
2018-06-11 17:13:02 +00:00
2018-06-13 04:23:17 +00:00
( defsubst doom-modeline--anzu ( )
2018-06-26 18:38:48 +00:00
" Show the match index and total number thereof.
2018-06-30 18:19:54 +00:00
2018-07-02 08:28:16 +00:00
Requires ` anzu ', also ` evil-anzu ' if using ` evil-mode ' for compatibility with
2018-06-26 18:38:48 +00:00
` evil-search '. "
2018-08-14 02:56:57 +00:00
( setq anzu-cons-mode-line-p nil )
2018-08-13 11:00:39 +00:00
( when ( and ( bound-and-true-p anzu--state )
2018-06-30 18:19:54 +00:00
( not ( bound-and-true-p iedit-mode ) ) )
2018-06-11 17:13:02 +00:00
( propertize
( let ( ( here anzu--current-position )
( total anzu--total-matched ) )
( cond ( ( eq anzu--state 'replace-query )
( format " %d replace " total ) )
( ( eq anzu--state 'replace )
( format " %d/%d " here total ) )
( anzu--overflow-p
( format " %s+ " total ) )
( t
( format " %s/%d " here total ) ) ) )
2018-06-13 04:23:17 +00:00
'face ( if ( doom-modeline--active ) 'doom-modeline-panel ) ) ) )
2018-06-11 17:13:02 +00:00
2018-06-13 04:23:17 +00:00
( defsubst doom-modeline--evil-substitute ( )
2018-06-11 17:13:02 +00:00
" Show number of matches for evil-ex substitutions and highlights in real time. "
2018-10-29 15:09:40 +00:00
( when ( and ( bound-and-true-p evil-local-mode )
2018-06-11 17:13:02 +00:00
( or ( assq 'evil-ex-substitute evil-ex-active-highlights-alist )
( assq 'evil-ex-global-match evil-ex-active-highlights-alist )
( assq 'evil-ex-buffer-match evil-ex-active-highlights-alist ) ) )
( propertize
( let ( ( range ( if evil-ex-range
( cons ( car evil-ex-range ) ( cadr evil-ex-range ) )
( cons ( line-beginning-position ) ( line-end-position ) ) ) )
( pattern ( car-safe ( evil-delimited-arguments evil-ex-argument 2 ) ) ) )
( if pattern
( format " %s matches " ( how-many pattern ( car range ) ( cdr range ) ) )
" - " ) )
2018-06-13 04:23:17 +00:00
'face ( if ( doom-modeline--active ) 'doom-modeline-panel ) ) ) )
2018-06-11 17:13:02 +00:00
2018-06-13 04:23:17 +00:00
( defun doom-modeline-themes--overlay-sort ( a b )
2018-06-30 18:19:54 +00:00
" Sort overlay A and B. "
2018-06-11 17:13:02 +00:00
( < ( overlay-start a ) ( overlay-start b ) ) )
2018-06-13 04:23:17 +00:00
( defsubst doom-modeline--iedit ( )
2018-06-11 17:13:02 +00:00
" Show the number of iedit regions matches + what match you're on. "
2018-08-13 16:30:49 +00:00
( when ( and ( bound-and-true-p iedit-mode )
( bound-and-true-p iedit-occurrences-overlays ) )
2018-06-11 17:13:02 +00:00
( propertize
( let ( ( this-oc ( or ( let ( ( inhibit-message t ) )
( iedit-find-current-occurrence-overlay ) )
( progn ( iedit-prev-occurrence )
( iedit-find-current-occurrence-overlay ) ) ) )
( length ( length iedit-occurrences-overlays ) ) )
( format " %s/%d "
( if this-oc
( - length
( length ( memq this-oc ( sort ( append iedit-occurrences-overlays nil )
2018-06-13 04:23:17 +00:00
#' doom-modeline-themes--overlay-sort ) ) )
2018-06-11 17:13:02 +00:00
-1 )
" - " )
length ) )
2018-06-13 04:23:17 +00:00
'face ( if ( doom-modeline--active ) 'doom-modeline-panel ) ) ) )
2018-06-11 17:13:02 +00:00
2018-11-27 18:48:16 +00:00
( defsubst doom-modeline--symbol-overlay ( )
" Show the number of matches for symbol overlay. "
2018-12-31 16:45:51 +00:00
( when ( and ( bound-and-true-p symbol-overlay-keywords-alist )
( not ( bound-and-true-p symbol-overlay-temp-symbol ) )
2018-12-31 16:25:12 +00:00
( not ( bound-and-true-p iedit-mode ) ) )
( let* ( ( keyword ( symbol-overlay-assoc
( ignore-errors ( symbol-overlay-get-symbol ) ) ) )
( symbol ( car keyword ) )
( before ( symbol-overlay-get-list symbol 'car ) )
( after ( symbol-overlay-get-list symbol 'cdr ) )
( count ( length before ) ) )
( if ( symbol-overlay-assoc symbol )
( propertize
( format ( concat " %d/%d " ( and ( cadr keyword ) " in scope " ) )
( + count 1 )
( + count ( length after ) ) )
'face ( if ( doom-modeline--active ) 'doom-modeline-panel ) ) ) ) ) )
2018-11-27 18:48:16 +00:00
2018-08-22 18:24:30 +00:00
( defsubst doom-modeline--multiple-cursors ( )
2018-08-23 03:24:34 +00:00
" Show the number of multiple cursors. "
2018-08-22 18:24:30 +00:00
( when ( bound-and-true-p multiple-cursors-mode )
( propertize
( concat ( car mc/mode-line )
( eval ( cadadr mc/mode-line ) )
" " )
'face ( if ( doom-modeline--active ) 'doom-modeline-panel ) ) ) )
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment matches
2018-06-11 17:13:02 +00:00
" Displays: 1. the currently recording macro, 2. A current/total for the
2018-11-28 18:34:58 +00:00
current search term ( with ` anzu ' ) , 3. The number of substitutions being conducted
with ` evil-ex-substitute ', and/or 4. The number of active ` iedit ' regions,
5. The current/total for the highlight term ( with ` symbol-overlay ' ) , 6. The number
of active ` multiple-cursors '. "
2018-06-13 04:23:17 +00:00
( let ( ( meta ( concat ( doom-modeline--macro-recording )
( doom-modeline--anzu )
( doom-modeline--evil-substitute )
2018-08-22 18:24:30 +00:00
( doom-modeline--iedit )
2018-11-27 18:48:16 +00:00
( doom-modeline--symbol-overlay )
2018-08-22 18:24:30 +00:00
( doom-modeline--multiple-cursors ) ) ) )
2018-06-11 17:13:02 +00:00
( or ( and ( not ( equal meta " " ) ) meta )
2018-12-06 16:16:19 +00:00
( if ( and buffer-file-name size-indication-mode )
( propertize " %I "
'help-echo " Buffer size \n \
mouse-1: Display Line and Column Mode Menu "
2018-12-08 18:11:23 +00:00
'mouse-face ' ( :box 1 )
2018-12-06 17:33:13 +00:00
'local-map mode-line-column-line-number-mode-map ) ) ) ) )
2018-06-11 17:13:02 +00:00
2018-07-05 06:23:23 +00:00
2018-06-13 12:43:03 +00:00
;;
;; media-info
;;
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment media-info
2018-06-11 17:13:02 +00:00
" Metadata regarding the current file, such as dimensions for images. "
2018-06-13 12:43:03 +00:00
;; TODO Include other information
2018-06-11 17:13:02 +00:00
( cond ( ( eq major-mode 'image-mode )
( cl-destructuring-bind ( width . height )
2018-10-25 08:21:25 +00:00
( when ( fboundp 'image-size )
( image-size ( image-get-display-property ) :pixels ) )
2018-06-11 17:13:02 +00:00
( format " %dx%d " width height ) ) ) ) )
2018-07-05 06:23:23 +00:00
2018-06-13 12:43:03 +00:00
;;
;; bar
;;
( defvar doom-modeline--bar-active nil )
( defvar doom-modeline--bar-inactive nil )
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment bar
2018-06-11 17:13:02 +00:00
" The bar regulates the height of the mode-line in GUI Emacs.
2018-11-28 18:34:58 +00:00
Returns \"\" to not break --no-window-system. "
2018-06-19 09:58:24 +00:00
( if ( display-graphic-p )
2018-06-13 12:43:03 +00:00
( if ( doom-modeline--active )
doom-modeline--bar-active
doom-modeline--bar-inactive )
2018-06-11 17:13:02 +00:00
" " ) )
2018-06-13 12:43:03 +00:00
( when ( >= emacs-major-version 26 )
( add-variable-watcher
'doom-modeline-height
( lambda ( _sym val op _where )
( when ( and ( eq op 'set ) ( integerp val ) )
( doom-modeline-refresh-bars doom-modeline-bar-width val ) ) ) )
2018-06-11 17:13:02 +00:00
2018-06-13 12:43:03 +00:00
( add-variable-watcher
'doom-modeline-bar-width
( lambda ( _sym val op _where )
( when ( and ( eq op 'set ) ( integerp val ) )
( doom-modeline-refresh-bars val doom-modeline-height ) ) ) ) )
2018-09-29 09:14:43 +00:00
( add-hook 'after-setting-font-hook
2019-01-04 18:08:16 +00:00
( lambda ( )
( doom-modeline-refresh-bars ) ) )
2018-09-29 09:14:43 +00:00
2018-06-13 12:43:03 +00:00
;;
;; window number
;;
2018-06-11 17:13:02 +00:00
2018-11-15 17:37:58 +00:00
;; HACK: `ace-window-display-mode' should respect the ignore buffers.
2018-10-28 14:19:55 +00:00
( defun doom-modeline-aw-update ( )
" Update ace-window-path window parameter for all windows.
Ensure all windows are labeled so the user can select a specific
one. The ignored buffers are excluded unless ` aw-ignore-on ' is nil. "
( let ( ( ignore-window-parameters t ) )
( avy-traverse
( avy-tree ( aw-window-list ) aw-keys )
( lambda ( path leaf )
( set-window-parameter
leaf 'ace-window-path
( propertize
( apply #' string ( reverse path ) )
'face 'aw-mode-line-face ) ) ) ) ) )
( advice-add #' aw-update :override #' doom-modeline-aw-update )
2018-12-29 07:46:50 +00:00
;; Remove original window number of `ace-window-display-mode'.
( add-hook 'ace-window-display-mode-hook
( lambda ( )
( setq-default mode-line-format
( assq-delete-all 'ace-window-display-mode
( default-value 'mode-line-format ) ) ) ) )
2018-06-11 17:13:02 +00:00
( advice-add #' window-numbering-install-mode-line :override #' ignore )
( advice-add #' window-numbering-clear-mode-line :override #' ignore )
2018-10-24 07:38:44 +00:00
( advice-add #' winum--install-mode-line :override #' ignore )
( advice-add #' winum--clear-mode-line :override #' ignore )
2018-06-11 17:13:02 +00:00
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment window-number
2018-07-02 11:05:53 +00:00
( let ( ( num ( cond
2018-10-24 08:23:07 +00:00
( ( bound-and-true-p ace-window-display-mode )
2018-10-25 08:57:17 +00:00
( aw-update )
2018-10-24 08:23:07 +00:00
( window-parameter ( selected-window ) 'ace-window-path ) )
2018-07-02 11:05:53 +00:00
( ( bound-and-true-p winum-mode )
2018-10-24 16:56:09 +00:00
( setq winum-auto-setup-mode-line nil )
2018-07-02 11:05:53 +00:00
( winum-get-number-string ) )
( ( bound-and-true-p window-numbering-mode )
( window-numbering-get-number-string ) )
( t " " ) ) ) )
2018-07-02 12:31:11 +00:00
( if ( < 0 ( length num ) )
2018-07-02 11:05:53 +00:00
( propertize ( format " %s " num )
'face ( if ( doom-modeline--active )
2018-09-30 13:42:41 +00:00
'doom-modeline-buffer-major-mode ) )
2018-07-02 11:05:53 +00:00
" " ) ) )
2018-06-11 17:13:02 +00:00
2018-07-11 07:23:23 +00:00
2018-06-13 12:43:03 +00:00
;;
2018-08-13 11:00:39 +00:00
;; workspace number
2018-06-13 12:43:03 +00:00
;;
2018-06-19 10:23:22 +00:00
( doom-modeline-def-segment workspace-number
2018-11-28 18:34:58 +00:00
" The current workspace name or number.
Requires ` eyebrowse-mode ' to be enabled. "
2018-06-11 17:13:02 +00:00
( if ( and ( bound-and-true-p eyebrowse-mode )
( < 1 ( length ( eyebrowse--get 'window-configs ) ) ) )
( let* ( ( num ( eyebrowse--get 'current-slot ) )
( tag ( when num ( nth 2 ( assoc num ( eyebrowse--get 'window-configs ) ) ) ) )
( str ( if ( and tag ( < 0 ( length tag ) ) )
tag
( when num ( int-to-string num ) ) ) ) )
2018-12-24 08:13:33 +00:00
( assq-delete-all 'eyebrowse-mode mode-line-misc-info )
2018-08-11 17:27:18 +00:00
( propertize ( format " %s " str ) 'face
2018-09-30 13:42:41 +00:00
( if ( doom-modeline--active ) 'doom-modeline-buffer-major-mode ) ) )
2018-06-11 17:13:02 +00:00
" " ) )
2018-07-11 07:23:23 +00:00
2018-12-04 18:38:36 +00:00
;;
;; perspective name
;;
( defvar-local doom-modeline--persp-name nil )
( defun doom-modeline-update-persp-name ( &rest _ )
" Update perspective name in mode-line. "
( setq doom-modeline--persp-name
;; Support `persp-mode', while not support `perspective'
2018-12-06 16:24:29 +00:00
( when ( and doom-modeline-persp-name
( bound-and-true-p persp-mode )
2018-12-04 18:38:36 +00:00
( fboundp 'safe-persp-name )
( fboundp 'get-current-persp ) )
( let ( ( persp ( get-current-persp ) ) )
( propertize
( format " #%s " ( safe-persp-name persp ) )
'face ( if ( and persp
( not ( persp-contain-buffer-p ( current-buffer ) persp ) ) )
'doom-modeline-persp-buffer-not-in-persp
2018-12-05 17:58:16 +00:00
'doom-modeline-persp-name )
2019-01-02 13:31:01 +00:00
'help-echo " mouse-1: Switch perspective
mouse-2: Show help for minor mode "
2018-12-08 18:11:23 +00:00
'mouse-face ' ( :box 1 )
2019-01-02 13:31:01 +00:00
'local-map ( let ( ( map ( make-sparse-keymap ) ) )
( define-key map [ mode-line mouse-1 ]
#' persp-switch )
( define-key map [ mode-line mouse-2 ]
( lambda ( )
( interactive )
( describe-function 'persp-mode ) ) )
map ) ) ) ) ) )
2018-12-04 18:38:36 +00:00
( add-hook 'find-file-hook #' doom-modeline-update-persp-name )
( add-hook 'after-revert-hook #' doom-modeline-update-persp-name )
2018-12-09 18:25:37 +00:00
( add-hook 'persp-activated-functions #' doom-modeline-update-persp-name )
2018-12-04 18:38:36 +00:00
( add-hook 'persp-renamed-functions #' doom-modeline-update-persp-name )
( advice-add #' select-window :after #' doom-modeline-update-persp-name )
2018-12-09 18:25:37 +00:00
;; (advice-add #'persp-window-switch :after #'doom-modeline-update-persp-name)
;; (advice-add #'persp-frame-switch :after #'doom-modeline-update-persp-name)
;; (advice-add #'persp-add-buffer :after #'doom-modeline-update-persp-name)
;; (advice-add #'persp-remove-buffer :after #'doom-modeline-update-persp-name)
2018-12-04 18:38:36 +00:00
( doom-modeline-def-segment persp-name
" The current perspective name. "
( if ( doom-modeline--active )
doom-modeline--persp-name
" " ) )
2018-07-10 07:22:20 +00:00
;;
2018-12-20 15:05:54 +00:00
;; misc info
2018-07-10 07:22:20 +00:00
;;
2018-12-20 15:05:54 +00:00
( doom-modeline-def-segment misc-info
" Mode line construct for miscellaneous information.
By default, this shows the information specified by ` global-mode-string '. "
( if ( doom-modeline--active )
mode-line-misc-info ) )
2018-07-10 16:18:17 +00:00
2018-07-11 07:23:23 +00:00
2018-07-10 16:18:17 +00:00
;;
;; position
;;
2018-07-11 06:44:47 +00:00
;; Be compatible with Emacs 25.
2018-12-07 19:57:38 +00:00
( defvar doom-modeline-column-zero-based
2018-12-07 19:46:12 +00:00
( if ( boundp 'column-number-indicator-zero-based )
column-number-indicator-zero-based
t )
2018-07-11 06:44:47 +00:00
" When non-nil, mode line displays column numbers zero-based.
See ` column-number-indicator-zero-based '. " )
2018-12-07 19:57:38 +00:00
( defvar doom-modeline-percent-position
2018-12-07 19:46:12 +00:00
( if ( boundp 'mode-line-percent-position )
mode-line-percent-position
' ( -3 " %p " ) )
2018-07-11 06:44:47 +00:00
" Specification of \" percentage offset \" of window through buffer.
See ` mode-line-percent-position '. " )
2018-12-07 19:46:12 +00:00
( when ( >= emacs-major-version 26 )
( add-variable-watcher
'column-number-indicator-zero-based
( lambda ( _sym val op _where )
( when ( eq op 'set )
( setq doom-modeline-column-zero-based val ) ) ) )
( add-variable-watcher
'mode-line-percent-position
( lambda ( _sym val op _where )
( when ( eq op 'set )
( setq doom-modeline-percent-position val ) ) ) ) )
2018-07-10 16:18:17 +00:00
( doom-modeline-def-segment buffer-position
" The buffer position information. "
2019-01-03 16:21:40 +00:00
( let ( ( lc ' ( line-number-mode
( column-number-mode
( doom-modeline-column-zero-based " %l:%c " " %l:%C " )
" %l " )
( column-number-mode ( doom-modeline-column-zero-based " :%c " " :%C " ) ) ) ) )
2019-01-08 21:10:53 +00:00
( if ( and ( bound-and-true-p nyan-mode )
( doom-modeline--active ) )
2019-01-03 16:21:40 +00:00
( concat " " ( nyan-create ) " "
( propertize ( format-mode-line lc )
'help-echo " Buffer position \n \
2018-12-06 16:16:19 +00:00
mouse-1: Display Line and Column Mode Menu "
2019-01-03 16:21:40 +00:00
'mouse-face ' ( :box 1 )
'local-map mode-line-column-line-number-mode-map ) )
` ( :propertize ( " "
, lc
2019-01-03 17:46:48 +00:00
( if doom-modeline-percent-position ( " " doom-modeline-percent-position ) )
2019-01-03 16:21:40 +00:00
( when ( or line-number-mode column-number-mode doom-modeline-percent-position ) " " ) )
help-echo " Buffer position \n \
mouse-1: Display Line and Column Mode Menu "
mouse-face ( :box 1 )
local-map , mode-line-column-line-number-mode-map ) ) ) )
2018-08-13 11:00:39 +00:00
2019-01-08 15:45:25 +00:00
;;
;; party parrot
;;
( doom-modeline-def-segment parrot
" The party parrot animated icon. Requires `parrot-mode' to be enabled. "
2019-01-08 21:10:53 +00:00
( when ( and ( bound-and-true-p parrot-mode )
( doom-modeline--active ) )
2019-01-08 15:45:25 +00:00
( concat " " ( parrot-create ) " " ) ) )
2018-08-11 17:22:34 +00:00
;;
;; evil-state
;;
( doom-modeline-def-segment evil-state
" The current evil state. Requires `evil-mode' to be enabled. "
( when ( bound-and-true-p evil-local-mode )
( let ( ( tag ( evil-state-property evil-state :tag t ) ) )
2018-10-29 14:47:34 +00:00
( propertize tag 'face
2018-08-11 17:22:34 +00:00
( if ( doom-modeline--active )
2018-10-29 14:47:34 +00:00
( cond ( ( evil-normal-state-p ) 'doom-modeline-evil-normal-state )
( ( evil-emacs-state-p ) 'doom-modeline-evil-emacs-state )
( ( evil-insert-state-p ) 'doom-modeline-evil-insert-state )
( ( evil-motion-state-p ) 'doom-modeline-evil-motion-state )
( ( evil-visual-state-p ) 'doom-modeline-evil-visual-state )
( ( evil-operator-state-p ) 'doom-modeline-evil-operator-state )
( ( evil-replace-state-p ) 'doom-modeline-evil-replace-state ) ) ) ) ) ) )
2018-08-11 17:22:34 +00:00
2018-07-10 07:22:20 +00:00
2018-11-21 18:46:51 +00:00
;;
;; god-state
;;
( doom-modeline-def-segment god-state
" The current god state. Requires `god-mode' to be enabled. "
( when ( bound-and-true-p god-local-mode )
2018-11-21 19:13:44 +00:00
( propertize " <G> " 'face ( if ( doom-modeline--active )
'doom-modeline-evil-normal-state ) ) ) )
;;
;; ryo-modal state
;;
2018-12-05 16:08:10 +00:00
( doom-modeline-def-segment ryo-modal ( )
2018-11-21 19:13:44 +00:00
" The current ryo-modal state. Requires `ryo-modal-mode' to be enabled. "
( when ( bound-and-true-p ryo-modal-mode )
( propertize " <R> " 'face ( if ( doom-modeline--active )
'doom-modeline-evil-normal-state ) ) ) )
2018-11-21 18:46:51 +00:00
2018-12-05 16:08:10 +00:00
;;
;; xah-fly-keys state
;;
( doom-modeline-def-segment xah-fly-keys ( )
" The current xah-fly-keys state. "
2018-12-05 17:32:15 +00:00
( when ( boundp 'xah-fly-insert-state-q )
2018-12-05 16:08:10 +00:00
( propertize ( if xah-fly-insert-state-q
" <I> "
" <C> " )
'face ( if ( doom-modeline--active )
'doom-modeline-evil-normal-state ) ) ) )
2018-09-28 08:27:52 +00:00
;;
;; input method
;;
( doom-modeline-def-segment input-method
" The current input method. "
2018-12-30 13:57:40 +00:00
( propertize
( cond
( current-input-method
( concat " " current-input-method-title " " ) )
( ( and ( bound-and-true-p evil-local-mode )
( bound-and-true-p evil-input-method ) )
( concat
" "
( nth 3 ( assoc default-input-method input-method-alist ) )
" " ) )
( t " " ) )
'face ( if ( doom-modeline--active ) 'doom-modeline-buffer-major-mode )
'help-echo ( concat
" Current input method: "
current-input-method
" \n \
2018-12-06 17:33:13 +00:00
mouse-2: Disable input method\n \
mouse-3: Describe current input method " )
2018-12-30 13:57:40 +00:00
'mouse-face 'mode-line-highlight
'local-map mode-line-input-method-map ) )
2018-11-21 19:59:39 +00:00
2018-12-05 19:26:27 +00:00
;;
;; LSP
;;
( doom-modeline-def-segment lsp
" The LSP server state. "
2018-12-06 16:24:29 +00:00
( if ( and doom-modeline-lsp
2018-12-05 19:26:27 +00:00
( bound-and-true-p lsp-mode ) )
( concat ( lsp-mode-line ) " " ) ) )
2018-12-11 14:20:21 +00:00
;;
;; github
;;
( defvar doom-modeline--github-notifications-number 0 )
2018-12-28 07:46:40 +00:00
( defun doom-modeline--github-fetch-notifications ( )
2018-12-11 14:20:21 +00:00
" Fetch github notifications. "
2019-01-02 10:27:13 +00:00
( when ( and doom-modeline-github
( fboundp 'async-start ) )
2019-01-02 12:57:54 +00:00
;; load `async' if it exists but is not loaded
2019-01-02 10:27:13 +00:00
( unless ( fboundp 'async-inject-variables )
( require 'async nil t ) )
( async-start
` ( lambda ( )
, ( async-inject-variables " \\ `load-path\\' " )
( require 'ghub nil t )
( when ( fboundp 'ghub-get )
( with-timeout ( 10 )
2019-01-04 07:37:41 +00:00
( ignore-errors
2019-01-07 18:29:46 +00:00
( if ( ghub--token ghub-default-host
( ghub--username ghub-default-host )
'ghub
t )
( ghub-get " /notifications "
nil
:query ' ( ( notifications . " true " ) )
:noerror t ) ) ) ) ) )
2019-01-02 10:27:13 +00:00
( lambda ( result )
( setq doom-modeline--github-notifications-number
( length result ) ) ) ) ) )
2018-12-23 15:54:35 +00:00
2019-01-04 14:29:07 +00:00
( defvar doom-modeline--github-timer nil )
( defun doom-modeline-github-timer ( )
" Start/Stop the timer for github fetching. "
( if ( timerp doom-modeline--github-timer )
( cancel-timer doom-modeline--github-timer ) )
( setq doom-modeline--github-timer
( and doom-modeline-github
( run-with-timer 30
doom-modeline-github-interval
#' doom-modeline--github-fetch-notifications ) ) ) )
( when ( >= emacs-major-version 26 )
( add-variable-watcher
'doom-modeline-github
( lambda ( _sym val op _where )
( when ( eq op 'set )
( setq doom-modeline-github val )
( doom-modeline-github-timer ) ) ) ) )
( doom-modeline-github-timer )
2018-12-11 14:20:21 +00:00
2018-12-23 15:54:35 +00:00
( defun doom-modeline--github-open-notifications ( )
" Open GitHub Notifications page. "
2018-12-11 14:20:21 +00:00
( interactive )
2018-12-28 07:46:40 +00:00
( browse-url " https://github.com/notifications " )
( run-with-timer 60 nil #' doom-modeline--github-fetch-notifications ) )
2018-12-11 14:20:21 +00:00
( doom-modeline-def-segment github
" The github notifications. "
( if ( and doom-modeline-github
( doom-modeline--active )
( > doom-modeline--github-notifications-number 0 ) )
( propertize
( concat ( if doom-modeline-icon " " )
2018-12-28 07:46:40 +00:00
( doom-modeline-icon-faicon " github "
:v-adjust -0.0575
:face 'doom-modeline-warning )
2018-12-11 14:20:21 +00:00
( if doom-modeline-icon doom-modeline-vspc " " )
2018-12-28 08:07:53 +00:00
( propertize ( number-to-string doom-modeline--github-notifications-number )
'face 'doom-modeline-warning )
" " )
2018-12-28 07:46:40 +00:00
'help-echo " Github
mouse-1: Show notifications
mouse-3: Fetch notifications "
2018-12-11 14:20:21 +00:00
'mouse-face ' ( :box 1 )
2018-12-28 07:46:40 +00:00
'local-map ( let ( ( map ( make-sparse-keymap ) ) )
( define-key map [ mode-line mouse-1 ]
#' doom-modeline--github-open-notifications )
( define-key map [ mode-line mouse-3 ]
( lambda ( )
( interactive )
( message " Fetching github notifications... " )
( doom-modeline--github-fetch-notifications ) ) )
map ) ) ) )
2018-12-11 14:20:21 +00:00
2018-12-20 16:35:59 +00:00
;;
;; debug state
;;
( doom-modeline-def-segment debug
" The current debug state. "
( when ( doom-modeline--active )
( concat
2018-12-21 10:53:17 +00:00
( and ( or debug-on-error debug-on-quit ) " " )
2018-12-20 16:35:59 +00:00
( when debug-on-error
( propertize
( if doom-modeline-icon
2018-12-21 10:48:22 +00:00
( doom-modeline-icon-faicon " bug " :v-adjust -0.0575 :face 'doom-modeline-urgent )
2018-12-20 16:35:59 +00:00
( propertize " ! " 'face 'doom-modeline-urgent ) )
'help-echo " Debug on Error
mouse-1: Toggle Debug on Error "
'mouse-face ' ( :box 1 )
'local-map ( make-mode-line-mouse-map 'mouse-1 #' toggle-debug-on-error ) ) )
( when debug-on-quit
( propertize
( if doom-modeline-icon
2018-12-21 10:48:22 +00:00
( doom-modeline-icon-faicon " bug " :v-adjust -0.0575 :face 'doom-modeline-warning )
2018-12-20 16:35:59 +00:00
( propertize " ! " 'face 'doom-modeline-warning ) )
'help-echo " Debug on Quit
mouse-1: Toggle Debug on Quit "
'mouse-face ' ( :box 1 )
'local-map ( make-mode-line-mouse-map 'mouse-1 #' toggle-debug-on-quit ) ) )
( and ( or debug-on-error debug-on-quit ) " " ) ) ) )
2018-06-11 17:13:02 +00:00
;;
;; Mode lines
;;
2018-08-16 03:30:23 +00:00
( doom-modeline-def-modeline 'main
2019-01-08 15:45:25 +00:00
' ( bar workspace-number window-number evil-state god-state ryo-modal xah-fly-keys matches " " buffer-info remote-host buffer-position parrot " " selection-info )
2019-01-02 12:57:54 +00:00
' ( misc-info persp-name lsp github debug minor-modes input-method buffer-encoding major-mode process vcs checker ) )
2018-06-11 17:13:02 +00:00
2018-08-16 03:30:23 +00:00
( doom-modeline-def-modeline 'minimal
2018-11-28 18:34:58 +00:00
' ( bar matches " " buffer-info )
' ( media-info major-mode ) )
2018-06-11 17:13:02 +00:00
2018-08-16 03:30:23 +00:00
( doom-modeline-def-modeline 'special
2019-01-08 15:45:25 +00:00
' ( bar window-number evil-state god-state ryo-modal xah-fly-keys matches " " buffer-info-simple buffer-position parrot " " selection-info )
2019-01-02 12:57:54 +00:00
' ( misc-info lsp debug minor-modes input-method buffer-encoding major-mode process checker ) )
2018-06-11 17:13:02 +00:00
2018-08-16 03:30:23 +00:00
( doom-modeline-def-modeline 'project
2018-12-29 07:46:50 +00:00
' ( bar " " buffer-default-directory )
2018-12-28 10:13:42 +00:00
' ( misc-info github debug " " major-mode ) )
2018-06-11 17:13:02 +00:00
2018-08-16 03:30:23 +00:00
( doom-modeline-def-modeline 'media
2018-11-28 18:34:58 +00:00
' ( bar window-number " %b " )
2018-12-20 15:05:54 +00:00
' ( misc-info media-info major-mode ) )
2018-06-11 17:13:02 +00:00
2018-12-28 10:13:42 +00:00
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
;; Hooks
2018-06-11 17:13:02 +00:00
;;
2018-06-13 12:43:03 +00:00
( defun doom-modeline-refresh-bars ( &optional width height )
2018-09-29 09:14:43 +00:00
" Refresh mode-line bars with `WIDTH' and `HEIGHT' . "
2018-06-13 12:43:03 +00:00
( setq doom-modeline--bar-active
( doom-modeline--make-xpm 'doom-modeline-bar
( or width doom-modeline-bar-width )
2018-09-29 09:14:43 +00:00
( max ( or height doom-modeline-height )
( frame-char-height ) ) )
2018-06-13 12:43:03 +00:00
doom-modeline--bar-inactive
( doom-modeline--make-xpm 'doom-modeline-inactive-bar
( or width doom-modeline-bar-width )
2018-09-29 09:14:43 +00:00
( max ( or height doom-modeline-height )
( frame-char-height ) ) ) ) )
2018-06-13 12:43:03 +00:00
2018-06-11 17:13:02 +00:00
;;;###autoload
2018-06-13 04:23:17 +00:00
( defun doom-modeline-init ( )
2018-06-19 09:58:24 +00:00
" Initialize doom mode-line. "
2018-06-13 12:43:03 +00:00
;; Create bars
( doom-modeline-refresh-bars )
( unless after-init-time
;; These buffers are already created and don't get modelines. For the love
;; of Emacs, someone give the man a modeline!
( dolist ( bname ' ( " *scratch* " " *Messages* " ) )
( with-current-buffer bname
2019-01-11 17:51:15 +00:00
( doom-modeline-set-main-modeline ) ) ) ) )
;;;###autoload
( defun doom-modeline-set-main-modeline ( )
" Set main mode-line. "
( doom-modeline-set-modeline 'main ) )
2018-06-11 17:13:02 +00:00
2018-11-29 15:23:39 +00:00
;;;###autoload
( defun doom-modeline-set-minimal-modeline ( )
2019-01-11 17:51:15 +00:00
" Set minimal mode-line. "
2018-11-29 15:23:39 +00:00
( doom-modeline-set-modeline 'minimal ) )
2018-07-02 09:36:43 +00:00
;;;###autoload
2018-06-13 04:23:17 +00:00
( defun doom-modeline-set-special-modeline ( )
2018-06-19 09:58:24 +00:00
" Set sepcial mode-line. "
2018-06-19 11:08:55 +00:00
( doom-modeline-set-modeline 'special ) )
2018-06-11 17:13:02 +00:00
2018-07-02 09:36:43 +00:00
;;;###autoload
2018-06-13 04:23:17 +00:00
( defun doom-modeline-set-media-modeline ( )
2018-06-19 09:58:24 +00:00
" Set media mode-line. "
2018-06-19 11:08:55 +00:00
( doom-modeline-set-modeline 'media ) )
2018-06-11 17:13:02 +00:00
2018-07-02 09:36:43 +00:00
;;;###autoload
2018-06-13 12:43:03 +00:00
( defun doom-modeline-set-project-modeline ( )
2018-06-19 09:58:24 +00:00
" Set project mode-line. "
2018-06-19 11:08:55 +00:00
( doom-modeline-set-modeline 'project ) )
2018-06-13 12:43:03 +00:00
2018-12-28 10:13:42 +00:00
2018-06-13 12:43:03 +00:00
;;
;; Bootstrap
;;
2018-06-19 11:08:55 +00:00
( doom-modeline-set-modeline 'main t ) ; set default modeline
2018-06-13 12:43:03 +00:00
2018-12-28 10:13:42 +00:00
( add-hook 'dashboard-mode-hook #' doom-modeline-set-project-modeline )
2018-06-13 12:43:03 +00:00
( add-hook 'image-mode-hook #' doom-modeline-set-media-modeline )
( add-hook 'circe-mode-hook #' doom-modeline-set-special-modeline )
2018-08-23 03:28:01 +00:00
;; Versions, support Python, Ruby, Perl and Golang, etc.
2018-06-19 10:06:01 +00:00
( add-hook 'python-mode-hook
( lambda ( )
2019-01-11 21:34:47 +00:00
( cond ( ( and ( fboundp 'pipenv-project-p ) ( pipenv-project-p ) ( executable-find " pipenv " ) )
( setq doom-modeline-env-parser 'doom-version-parser--python )
( setq doom-modeline-env-command " pipenv " )
( setq doom-modeline-env-command-args ' ( " run " " python " " --version " ) ) )
2018-12-27 14:32:27 +00:00
( ( and doom-modeline-python-executable
2019-01-11 21:34:47 +00:00
( executable-find doom-modeline-python-executable ) )
( setq doom-modeline-env-parser 'doom-version-parser--python )
( setq doom-modeline-env-command doom-modeline-python-executable )
( setq doom-modeline-env-command-args ' ( " --version " ) ) ) ) ) )
2018-06-19 10:06:01 +00:00
( add-hook 'ruby-mode-hook
2018-06-21 14:30:41 +00:00
( lambda ( )
2019-01-11 21:34:47 +00:00
( setq doom-modeline-env-command " ruby " )
( setq doom-modeline-env-command-args ' ( " --version " ) )
( setq doom-modeline-env-parser 'doom-version-parser--ruby ) ) )
2018-08-23 03:05:45 +00:00
( add-hook 'perl-mode-hook
( lambda ( )
2019-01-11 21:34:47 +00:00
( setq doom-modeline-env-command " perl " )
( setq doom-modeline-env-command-args ' ( " --version " ) )
( setq doom-modeline-env-parser 'doom-version-parser--perl ) ) )
2018-06-21 14:30:41 +00:00
( add-hook 'go-mode-hook
( lambda ( )
2019-01-11 21:34:47 +00:00
( setq doom-modeline-env-command " go " )
( setq doom-modeline-env-command-args ' ( " version " ) )
( setq doom-modeline-env-parser 'doom-version-parser--go ) ) )
2018-08-22 18:20:50 +00:00
( add-hook 'elixir-mode-hook
( lambda ( )
2019-01-11 21:34:47 +00:00
( setq doom-modeline-env-command " iex " )
( setq doom-modeline-env-command-args ' ( " --version " ) )
( setq doom-modeline-env-parser 'doom-version-parser--elixir ) ) )
2018-12-09 12:29:40 +00:00
( add-hook 'rust-mode-hook
( lambda ( )
2019-01-11 21:34:47 +00:00
( setq doom-modeline-env-command " rustc " )
( setq doom-modeline-env-command-args ' ( " --version " ) )
( setq doom-modeline-env-parser 'doom-version-parser--rustc ) ) )
2018-06-21 14:30:41 +00:00
2018-06-19 09:58:24 +00:00
2018-06-13 12:43:03 +00:00
;; Ensure modeline is inactive when Emacs is unfocused (and active otherwise)
( defvar doom-modeline-remap-face-cookie nil )
( defun doom-modeline-focus ( )
2018-06-19 09:58:24 +00:00
" Focus mode-line. "
2018-06-13 12:43:03 +00:00
( when doom-modeline-remap-face-cookie
( require 'face-remap )
( face-remap-remove-relative doom-modeline-remap-face-cookie ) ) )
( defun doom-modeline-unfocus ( )
2018-06-19 09:58:24 +00:00
" Unfocus mode-line. "
2018-06-13 12:43:03 +00:00
( setq doom-modeline-remap-face-cookie ( face-remap-add-relative 'mode-line 'mode-line-inactive ) ) )
2018-10-01 15:12:32 +00:00
( with-no-warnings
( if ( boundp 'after-focus-change-function )
( progn
( defun doom-modeline-focus-change ( )
( if ( frame-focus-state )
( doom-modeline-focus )
( doom-modeline-unfocus ) ) )
( add-function :after after-focus-change-function #' doom-modeline-focus-change ) )
( progn
( add-hook 'focus-in-hook #' doom-modeline-focus )
( add-hook 'focus-out-hook #' doom-modeline-unfocus ) ) ) )
2018-06-11 17:13:02 +00:00
( provide 'doom-modeline )
;;; doom-modeline.el ends here