[Performance] Improve the performance of pdf-pages segment.

This commit is contained in:
Vincent Zhang 2019-03-22 02:19:25 +08:00
parent 748824e692
commit 80d0d40a34

View file

@ -1831,8 +1831,9 @@ mouse-1: Toggle Debug on Quit"
;; pdf pages ;; pdf pages
;; ;;
(doom-modeline-def-segment pdf-pages (defvar-local doom-modeline--pdf-pages nil)
(when (eq major-mode 'pdf-view-mode) (defun doom-modeline-update-pdf-pages ()
(setq doom-modeline--pdf-pages
(propertize (propertize
(format " P%d/%d " (format " P%d/%d "
(eval `(pdf-view-current-page)) (eval `(pdf-view-current-page))
@ -1840,6 +1841,11 @@ mouse-1: Toggle Debug on Quit"
'face (if (doom-modeline--active) 'face (if (doom-modeline--active)
'mode-line 'mode-line
'mode-line-inactive)))) 'mode-line-inactive))))
(add-hook 'pdf-view-change-page-hook #'doom-modeline-update-pdf-pages)
(doom-modeline-def-segment pdf-pages
(when (eq major-mode 'pdf-view-mode)
doom-modeline--pdf-pages))
;; ;;