From 0186ce9de904cf4eb1823d670460c368e9c2c090 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Fri, 16 Aug 2019 20:05:39 +0800 Subject: [PATCH] [Feature] New indicator for markdown/org preview with grip. --- README.md | 1 + doom-modeline-segments.el | 25 +++++++++++++++++++++++++ doom-modeline.el | 3 ++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a3a445..5b29c2f 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ The `doom-modeline` was designed for minimalism, and offers: - An indicator for buffer position which is compatible with `nyan-mode` - An indicator for party parrot - An indicator for PDF page number with `pdf-tools` +- An indicator for markdown/org preview with `grip` - An indicator for battery status with `fancy-battery` - Truncated file name, file icon, buffer state and project name in buffer information segment, which is compatible with `projectile` and `project` diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 4cc4ee9..701e121 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -65,6 +65,7 @@ (defvar flymake--backend-state) (defvar flymake--mode-line-format) (defvar flymake-menu) +(defvar grip-port) (defvar helm--mode-line-display-prefarg) (defvar iedit-occurrences-overlays) (defvar mc/mode-line) @@ -140,6 +141,7 @@ (declare-function flymake-running-backends 'flymake) (declare-function flymake-show-diagnostics-buffer 'flymake) (declare-function flymake-start 'flymake) +(declare-function grip-mode 'grip-mode) (declare-function helm-candidate-number-at-point 'helm) (declare-function helm-get-candidate-number 'helm) (declare-function iedit-find-current-occurrence-overlay 'iedit-lib) @@ -2291,6 +2293,29 @@ The cdr can also be a function that returns a name to use.") 'doom-modeline-buffer-file 'mode-line-inactive))))) +;; +;; Markdown/org preview +;; + +(doom-modeline-def-segment grip + (when (bound-and-true-p grip-mode) + (concat + (doom-modeline-spc) + (propertize + (if (display-graphic-p) + (doom-modeline-icon-material "pageview" + :face (if (doom-modeline--active) + 'all-the-icons-lblue + 'mode-line-inactive) + :height 1.1 + :v-adjust -0.225) + "G") + 'help-echo (format "Preview with grip: http://localhost:%d +mouse-1: Exit preview" grip-port) + 'mouse-face '(:box 0) + 'local-map (make-mode-line-mouse-map 'mouse-1 #'grip-mode)) + (doom-modeline-spc)))) + (provide 'doom-modeline-segments) ;;; doom-modeline-segments.el ends here diff --git a/doom-modeline.el b/doom-modeline.el index 0880699..9f80009 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -57,6 +57,7 @@ ;; - An indicator for buffer position which is compatible with nyan-mode ;; - An indicator for party parrot ;; - An indicator for PDF page number with pdf-tools +;; - An indicator for markdown/org preivews with grip ;; - An indicator for battery status with fancy-battery ;; - Truncated file name, file icon, buffer state and project name in buffer ;; information segment, which is compatible with projectile and project @@ -88,7 +89,7 @@ (doom-modeline-def-modeline 'main '(bar workspace-name window-number modals matches buffer-info remote-host buffer-position parrot selection-info) - '(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)) + '(objed-state misc-info persp-name fancy-battery grip irc mu4e github debug lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs checker)) (doom-modeline-def-modeline 'minimal '(bar matches buffer-info-simple)