mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-11-21 09:30:29 +01:00
Don't try to enable `mode-icons-mode' until a frame exists
In order to work better with the Emacs daemon, don't try to set up `mode-icons-mode' when no frame has been created yet. This should prevent `mode-icons-mode' trying to figure out what height the icons should be when we don't know what sort of font will be used yet.
This commit is contained in:
parent
02fa5f74db
commit
82cfba411c
1 changed files with 27 additions and 11 deletions
|
@ -1790,20 +1790,38 @@ When ENABLE is non-nil, enable the changes to the mode line."
|
||||||
(when place-eol
|
(when place-eol
|
||||||
(setcar place-eol mode-icons--backup-eol-construct)))))
|
(setcar place-eol mode-icons--backup-eol-construct)))))
|
||||||
|
|
||||||
|
(defun mode-icons--mode-enable ()
|
||||||
|
"Set up for the command ‘mode-icons-mode’."
|
||||||
|
(add-hook 'after-change-major-mode-hook #'mode-icons-reset)
|
||||||
|
(mode-icons-fix t)
|
||||||
|
(mode-icons-set-minor-mode-icon)
|
||||||
|
(mode-icons-major-mode-icons))
|
||||||
|
|
||||||
|
(defun mode-icons--mode-enable-for-first-frame ()
|
||||||
|
"Set up for the command ‘mode-icons-mode’ and then stop it from running again.
|
||||||
|
This function should be used in the
|
||||||
|
‘server-after-make-frame-hook’ hook. It will call
|
||||||
|
‘mode-icons--mode-enable’ and then remove itself from
|
||||||
|
‘server-after-make-frame-hook’."
|
||||||
|
(mode-icons--mode-enable)
|
||||||
|
(remove-hook 'server-after-make-frame-hook #'mode-icons--mode-enable-for-first-frame))
|
||||||
|
|
||||||
|
(defun mode-icons--mode-disable ()
|
||||||
|
"Tear down for the command ‘mode-icons-mode’."
|
||||||
|
(remove-hook 'after-change-major-mode-hook #'mode-icons-reset)
|
||||||
|
(mode-icons-set-minor-mode-icon-undo)
|
||||||
|
(mode-icons-major-mode-icons-undo)
|
||||||
|
(mode-icons-fix))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode mode-icons-mode
|
(define-minor-mode mode-icons-mode
|
||||||
"Replace the name of the current major mode with an icon."
|
"Replace the name of the current major mode with an icon."
|
||||||
:global t
|
:global t
|
||||||
(if mode-icons-mode
|
(if mode-icons-mode
|
||||||
(progn
|
(if (daemonp)
|
||||||
(add-hook 'after-change-major-mode-hook #'mode-icons-reset)
|
(add-hook 'server-after-make-frame-hook #'mode-icons--mode-enable-for-first-frame)
|
||||||
(mode-icons-fix t)
|
(mode-icons--mode-enable))
|
||||||
(mode-icons-set-minor-mode-icon)
|
(mode-icons--mode-disable)))
|
||||||
(mode-icons-major-mode-icons))
|
|
||||||
(remove-hook 'after-change-major-mode-hook #'mode-icons-reset)
|
|
||||||
(mode-icons-set-minor-mode-icon-undo)
|
|
||||||
(mode-icons-major-mode-icons-undo)
|
|
||||||
(mode-icons-fix)))
|
|
||||||
|
|
||||||
(defun mode-icons-reset-hash ()
|
(defun mode-icons-reset-hash ()
|
||||||
"Reset `mode-icons-get-icon-spec' and `mode-icons-get-icon-display'."
|
"Reset `mode-icons-get-icon-spec' and `mode-icons-get-icon-display'."
|
||||||
|
@ -1826,8 +1844,6 @@ When ENABLE is non-nil, enable the changes to the mode line."
|
||||||
(with-current-buffer ,(current-buffer)
|
(with-current-buffer ,(current-buffer)
|
||||||
(mode-icons-set-minor-mode-icon)))))))
|
(mode-icons-set-minor-mode-icon)))))))
|
||||||
|
|
||||||
(add-hook 'emacs-startup-hook #'mode-icons-reset)
|
|
||||||
|
|
||||||
(defadvice isearch-mode (after mode-icons--reset-isearch-icon activate)
|
(defadvice isearch-mode (after mode-icons--reset-isearch-icon activate)
|
||||||
"Make `mode-icons' aware of icon."
|
"Make `mode-icons' aware of icon."
|
||||||
(mode-icons-set-minor-mode-icon))
|
(mode-icons-set-minor-mode-icon))
|
||||||
|
|
Loading…
Reference in a new issue