core: fix red mode-line when an error occurred

Rename function configuration-layer//set-error to
configuration-layer//increment-error-count
This commit is contained in:
syl20bnr 2016-01-11 23:58:47 -05:00
parent ac8a4bc7df
commit 3d63dd4392
5 changed files with 38 additions and 36 deletions

View file

@ -633,7 +633,7 @@ path."
(condition-case err (condition-case err
(set-default var (eval (pop variables))) (set-default var (eval (pop variables)))
('error ('error
(configuration-layer//set-error) (configuration-layer//increment-error-count)
(spacemacs-buffer/append (spacemacs-buffer/append
(format (concat "\nAn error occurred while setting layer " (format (concat "\nAn error occurred while setting layer "
"variable %s " "variable %s "
@ -737,7 +737,7 @@ path."
(t (spacemacs-buffer/warning "Cannot install package %S." (t (spacemacs-buffer/warning "Cannot install package %S."
pkg-name))) pkg-name)))
('error ('error
(configuration-layer//set-error) (configuration-layer//increment-error-count)
(spacemacs-buffer/append (spacemacs-buffer/append
(format (concat "\nAn error occurred while installing %s " (format (concat "\nAn error occurred while installing %s "
"(error: %s)\n") pkg-name err)))))) "(error: %s)\n") pkg-name err))))))
@ -904,7 +904,7 @@ path."
(condition-case err (condition-case err
(funcall (intern (format "%S/pre-init-%S" layer pkg-name))) (funcall (intern (format "%S/pre-init-%S" layer pkg-name)))
('error ('error
(configuration-layer//set-error) (configuration-layer//increment-error-count)
(spacemacs-buffer/append (spacemacs-buffer/append
(format (format
(concat "\nAn error occurred while pre-configuring %S " (concat "\nAn error occurred while pre-configuring %S "
@ -924,7 +924,7 @@ path."
(condition-case err (condition-case err
(funcall (intern (format "%S/post-init-%S" layer pkg-name))) (funcall (intern (format "%S/post-init-%S" layer pkg-name)))
('error ('error
(configuration-layer//set-error) (configuration-layer//increment-error-count)
(spacemacs-buffer/append (spacemacs-buffer/append
(format (format
(concat "\nAn error occurred while post-configuring %S " (concat "\nAn error occurred while post-configuring %S "
@ -1284,12 +1284,10 @@ to select one."
(spacemacs-buffer/append "\n")) (spacemacs-buffer/append "\n"))
(spacemacs-buffer/message "No orphan package to delete.")))) (spacemacs-buffer/message "No orphan package to delete."))))
(defun configuration-layer//set-error () (defun configuration-layer//increment-error-count ()
"Set the error flag and change the mode-line color to red." "Increment the error counter."
(if configuration-layer-error-count (if configuration-layer-error-count
(setq configuration-layer-error-count (setq configuration-layer-error-count (1+ configuration-layer-error-count))
(1+ configuration-layer-error-count))
(face-remap-add-relative 'mode-line '((:background "red") mode-line))
(setq configuration-layer-error-count 1))) (setq configuration-layer-error-count 1)))
(provide 'core-configuration-layer) (provide 'core-configuration-layer)

View file

@ -285,7 +285,7 @@ are caught and signalled to user in spacemacs buffer."
(condition-case-unless-debug err (condition-case-unless-debug err
(,func) (,func)
(error (error
(configuration-layer//set-error) (configuration-layer//increment-error-count)
(spacemacs-buffer/append (format "Error in %s: %s\n" (spacemacs-buffer/append (format "Error in %s: %s\n"
',(symbol-name func) ',(symbol-name func)
(error-message-string err)) (error-message-string err))

View file

@ -604,19 +604,25 @@ already exist, and switch to it."
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line) (spacemacs-buffer/set-mode-line spacemacs--default-mode-line)
(force-mode-line-update) (force-mode-line-update)
(spacemacs-buffer-mode)) (spacemacs-buffer-mode))
(add-hook 'emacs-startup-hook (add-hook
'emacs-startup-hook
(lambda () (lambda ()
(with-current-buffer (get-buffer spacemacs-buffer-name) (with-current-buffer (get-buffer spacemacs-buffer-name)
(when dotspacemacs-startup-lists (when dotspacemacs-startup-lists
(spacemacs-buffer/insert-startupify-lists)) (spacemacs-buffer/insert-startupify-lists))
(if configuration-layer-error-count (if configuration-layer-error-count
(progn
(spacemacs-buffer-mode)
(spacemacs-buffer/set-mode-line (spacemacs-buffer/set-mode-line
(format (concat "%s error(s) at startup! " (format
(concat "%s error(s) at startup! "
"Spacemacs may not be able to operate properly.") "Spacemacs may not be able to operate properly.")
configuration-layer-error-count)) configuration-layer-error-count))
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line)) (face-remap-add-relative 'mode-line
'((:background "red") mode-line)))
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line)
(spacemacs-buffer-mode))
(force-mode-line-update) (force-mode-line-update)
(spacemacs-buffer-mode)
(spacemacs-buffer/goto-link-line))) t))))) (spacemacs-buffer/goto-link-line))) t)))))
(spacemacs-buffer/goto-link-line) (spacemacs-buffer/goto-link-line)
(switch-to-buffer spacemacs-buffer-name) (switch-to-buffer spacemacs-buffer-name)

View file

@ -1387,11 +1387,10 @@ on whether the spacemacs-ivy layer is used or not, with
(if (display-graphic-p) 'wave 'utf-8))) (if (display-graphic-p) 'wave 'utf-8)))
(defun spacemacs//set-powerline-for-startup-buffers () (defun spacemacs//set-powerline-for-startup-buffers ()
"Set the powerline for buffers created when Emacs starts." "Set the powerline for buffers created when Emacs starts."
(unless configuration-layer-error-count
(dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*")) (dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*"))
(when (and (get-buffer buffer) (when (and (get-buffer buffer)
(configuration-layer/package-usedp 'spaceline)) (configuration-layer/package-usedp 'spaceline))
(spacemacs//restore-powerline buffer))))) (spacemacs//restore-powerline buffer))))
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
'spacemacs//set-powerline-for-startup-buffers)) 'spacemacs//set-powerline-for-startup-buffers))
:config :config

View file

@ -33,12 +33,11 @@ PAD import on left (l) or right (r) or left-right (lr)."
(defun spacemacs//set-vimish-powerline-for-startup-buffers () (defun spacemacs//set-vimish-powerline-for-startup-buffers ()
"Set the powerline for buffers created when Emacs starts." "Set the powerline for buffers created when Emacs starts."
(unless configuration-layer-error-count
(dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*")) (dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*"))
(when (get-buffer buffer) (when (get-buffer buffer)
(with-current-buffer buffer (with-current-buffer buffer
(setq-local mode-line-format (default-value 'mode-line-format)) (setq-local mode-line-format (default-value 'mode-line-format))
(powerline-set-selected-window) (powerline-set-selected-window)
(powerline-reset)))))) (powerline-reset)))))
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
'spacemacs//set-vimish-powerline-for-startup-buffers)) 'spacemacs//set-vimish-powerline-for-startup-buffers))