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-05-16 15:32:27 +00:00
|
|
|
;; Version: 2.2.1
|
2019-04-23 12:10:55 +00:00
|
|
|
;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (shrink-path "0.2.0") (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:
|
|
|
|
;;
|
2019-03-07 10:52:07 +00:00
|
|
|
;; This package offers a fancy and fast mode-line inspired by minimalism design.
|
2018-06-11 17:13:02 +00:00
|
|
|
;;
|
2019-03-07 10:52:07 +00:00
|
|
|
;; It's integrated into Doom Emacs (https://github.com/hlissner/doom-emacs) and
|
|
|
|
;; Centaur Emacs (https://github.com/seagle0128/.emacs.d).
|
|
|
|
;;
|
|
|
|
;; The doom-modeline 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
|
2019-01-13 16:48:54 +00:00
|
|
|
;; - Current environment version (e.g. python, ruby, go, etc.) in the major-mode
|
2018-11-27 13:32:00 +00:00
|
|
|
;; - 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
|
2019-04-22 15:35:52 +00:00
|
|
|
;; - An indicator for modal editing state, including evil, god, ryo and
|
|
|
|
;; xah-fly-keys, etc.
|
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
|
2019-03-11 17:01:47 +00:00
|
|
|
;; - An indicator for LSP state with lsp-mode or eglot
|
2018-12-11 14:20:21 +00:00
|
|
|
;; - An indicator for github notifications
|
2019-02-28 16:58:47 +00:00
|
|
|
;; - An indicator for unread emails with mu4e-alert
|
2019-03-04 10:10:02 +00:00
|
|
|
;; - An indicator for irc notifications with circe
|
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
|
2019-05-09 19:24:36 +00:00
|
|
|
;; - An indicator for PDF page number with pdf-tools
|
2019-02-28 16:58:47 +00:00
|
|
|
;; - An indicator for battery status with fancy-battery
|
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
|
2019-05-09 19:24:36 +00:00
|
|
|
;; - New mode-line for Info-mode buffers
|
|
|
|
;; - New package mode-line for paradox
|
|
|
|
;; - New mode-line for helm buffers
|
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)
|
2019-01-17 16:38:51 +00:00
|
|
|
;; (doom-modeline-mode 1)
|
2018-07-05 06:01:47 +00:00
|
|
|
;; or
|
|
|
|
;; (use-package doom-modeline
|
|
|
|
;; :ensure t
|
2019-01-17 16:38:51 +00:00
|
|
|
;; :hook (after-init . doom-modeline-mode))
|
2018-07-05 06:01:47 +00:00
|
|
|
;;
|
2018-06-11 17:13:02 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2019-01-17 15:42:33 +00:00
|
|
|
(require 'doom-modeline-core)
|
|
|
|
(require 'doom-modeline-segments)
|
2019-01-15 16:55:43 +00:00
|
|
|
|
|
|
|
|
2018-06-11 17:13:02 +00:00
|
|
|
;;
|
|
|
|
;; Mode lines
|
|
|
|
;;
|
|
|
|
|
2018-08-16 03:30:23 +00:00
|
|
|
(doom-modeline-def-modeline 'main
|
2019-04-22 15:35:52 +00:00
|
|
|
'(bar workspace-name window-number modals matches buffer-info remote-host buffer-position parrot selection-info)
|
2019-05-13 17:59:51 +00:00
|
|
|
'(objed-state misc-info persp-name fancy-battery irc mu4e github debug lsp minor-modes input-method indent-info 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
|
2019-05-18 15:53:47 +00:00
|
|
|
'(bar matches buffer-info)
|
2019-04-16 20:12:40 +00:00
|
|
|
'(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-04-22 15:35:52 +00:00
|
|
|
'(bar window-number modals matches buffer-info-simple buffer-position parrot selection-info)
|
2019-05-13 17:59:51 +00:00
|
|
|
'(objed-state misc-info fancy-battery irc-buffers debug lsp minor-modes input-method indent-info 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
|
2019-05-18 15:53:47 +00:00
|
|
|
'(bar window-number buffer-default-directory)
|
|
|
|
'(misc-info fancy-battery mu4e github debug major-mode process))
|
2018-06-11 17:13:02 +00:00
|
|
|
|
2019-05-09 17:53:14 +00:00
|
|
|
(doom-modeline-def-modeline 'package
|
|
|
|
'(bar window-number package)
|
2019-05-18 15:53:47 +00:00
|
|
|
'(misc-info major-mode process))
|
2019-05-09 17:53:14 +00:00
|
|
|
|
|
|
|
(doom-modeline-def-modeline 'info
|
2019-05-11 17:14:48 +00:00
|
|
|
'(bar window-number buffer-info info-nodes buffer-position parrot selection-info)
|
2019-05-09 17:53:14 +00:00
|
|
|
'(misc-info buffer-encoding major-mode))
|
|
|
|
|
2018-08-16 03:30:23 +00:00
|
|
|
(doom-modeline-def-modeline 'media
|
2019-01-15 16:55:43 +00:00
|
|
|
'(bar window-number buffer-size buffer-info)
|
2019-04-16 20:12:40 +00:00
|
|
|
'(misc-info media-info major-mode process vcs))
|
2019-01-15 16:55:43 +00:00
|
|
|
|
|
|
|
(doom-modeline-def-modeline 'pdf
|
|
|
|
'(bar window-number buffer-size buffer-info pdf-pages)
|
2019-05-18 15:53:47 +00:00
|
|
|
'(misc-info major-mode process vcs))
|
2018-06-11 17:13:02 +00:00
|
|
|
|
2019-05-09 19:17:15 +00:00
|
|
|
(doom-modeline-def-modeline 'helm
|
|
|
|
'(bar helm-buffer-id helm-number helm-follow helm-prefix-argument)
|
|
|
|
'(helm-help))
|
|
|
|
|
2018-12-28 10:13:42 +00:00
|
|
|
|
2018-06-11 17:13:02 +00:00
|
|
|
;;
|
2019-01-17 16:38:51 +00:00
|
|
|
;; Interfaces
|
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."
|
2019-01-17 16:38:51 +00:00
|
|
|
(doom-modeline-mode 1))
|
|
|
|
(make-obsolete 'doom-modeline-init 'doom-modeline-mode "1.6.0")
|
2019-01-11 17:51:15 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
2019-01-17 16:38:51 +00:00
|
|
|
(defun doom-modeline-set-main-modeline (&optional default)
|
|
|
|
"Set main mode-line.
|
|
|
|
If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|
|
|
(doom-modeline-set-modeline 'main default))
|
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 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
|
|
|
|
2019-01-15 16:55:43 +00:00
|
|
|
;;;###autoload
|
2019-05-09 17:53:14 +00:00
|
|
|
(defun doom-modeline-set-info-modeline ()
|
|
|
|
"Set Info mode-line."
|
|
|
|
(doom-modeline-set-modeline 'info))
|
2019-01-15 16:55:43 +00:00
|
|
|
|
2019-05-05 18:06:03 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-modeline-set-package-modeline ()
|
|
|
|
"Set package mode-line."
|
|
|
|
(doom-modeline-set-modeline 'package))
|
|
|
|
|
2019-05-09 17:53:14 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-modeline-set-media-modeline ()
|
|
|
|
"Set media mode-line."
|
|
|
|
(doom-modeline-set-modeline 'media))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-modeline-set-pdf-modeline ()
|
|
|
|
"Set pdf mode-line."
|
|
|
|
(doom-modeline-set-modeline 'pdf))
|
|
|
|
|
2019-05-09 19:17:15 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-modeline-set-helm-modeline (&rest _)
|
|
|
|
"Set helm mode-line."
|
|
|
|
(doom-modeline-set-modeline 'helm))
|
|
|
|
|
2018-12-28 10:13:42 +00:00
|
|
|
|
2018-06-13 12:43:03 +00:00
|
|
|
;;
|
2019-01-17 16:38:51 +00:00
|
|
|
;; Mode
|
2018-06-13 12:43:03 +00:00
|
|
|
;;
|
|
|
|
|
2019-01-17 16:38:51 +00:00
|
|
|
(defvar doom-modeline--default-mode-line mode-line-format)
|
2019-05-09 19:17:15 +00:00
|
|
|
(declare-function helm-display-mode-line 'helm)
|
2019-01-30 16:23:52 +00:00
|
|
|
|
2019-01-17 16:38:51 +00:00
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode doom-modeline-mode
|
|
|
|
"Toggle doom-modeline on or off."
|
|
|
|
:group 'doom-modeline
|
|
|
|
:global t
|
|
|
|
:lighter nil
|
|
|
|
(if doom-modeline-mode
|
|
|
|
(progn
|
|
|
|
(doom-modeline-refresh-bars) ; create bars
|
2019-01-27 10:30:25 +00:00
|
|
|
(doom-modeline-set-main-modeline t) ; set default mode-line
|
2019-01-17 16:38:51 +00:00
|
|
|
(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
|
|
|
|
(doom-modeline-set-main-modeline))))
|
|
|
|
;; Add hooks
|
2019-05-09 17:53:14 +00:00
|
|
|
(add-hook 'Info-mode-hook #'doom-modeline-set-info-modeline)
|
2019-04-12 12:20:53 +00:00
|
|
|
(add-hook 'magit-mode-hook #'doom-modeline-set-project-modeline)
|
2019-01-17 16:38:51 +00:00
|
|
|
(add-hook 'dashboard-mode-hook #'doom-modeline-set-project-modeline)
|
|
|
|
(add-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
|
|
|
(add-hook 'circe-mode-hook #'doom-modeline-set-special-modeline)
|
2019-05-11 17:02:05 +00:00
|
|
|
(add-hook 'pdf-view-mode-hook #'doom-modeline-set-pdf-modeline)
|
2019-05-09 19:17:15 +00:00
|
|
|
(add-hook 'paradox-menu-mode-hook #'doom-modeline-set-package-modeline)
|
|
|
|
;; Add advice
|
|
|
|
(advice-add #'helm-display-mode-line :override #'doom-modeline-set-helm-modeline))
|
2019-01-17 16:38:51 +00:00
|
|
|
(progn
|
|
|
|
;; Restore mode-line
|
|
|
|
(setq-default mode-line-format doom-modeline--default-mode-line)
|
|
|
|
;; Remove hooks
|
2019-05-09 17:53:14 +00:00
|
|
|
(remove-hook 'Info-mode-hook #'doom-modeline-set-info-modeline)
|
2019-04-12 12:20:53 +00:00
|
|
|
(remove-hook 'magit-mode-hook #'doom-modeline-set-project-modeline)
|
2019-01-17 16:38:51 +00:00
|
|
|
(remove-hook 'dashboard-mode-hook #'doom-modeline-set-project-modeline)
|
|
|
|
(remove-hook 'image-mode-hook #'doom-modeline-set-media-modeline)
|
|
|
|
(remove-hook 'circe-mode-hook #'doom-modeline-set-special-modeline)
|
2019-05-11 17:02:05 +00:00
|
|
|
(remove-hook 'pdf-view-mode-hook #'doom-modeline-set-pdf-modeline)
|
2019-05-09 19:17:15 +00:00
|
|
|
(remove-hook 'paradox-menu-mode-hook #'doom-modeline-set-package-modeline)
|
|
|
|
;; Remove advices
|
|
|
|
(advice-remove #'helm-display-mode-line #'doom-modeline-set-helm-modeline))))
|
2018-06-13 12:43:03 +00:00
|
|
|
|
2018-06-11 17:13:02 +00:00
|
|
|
(provide 'doom-modeline)
|
|
|
|
|
|
|
|
;;; doom-modeline.el ends here
|