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

View File

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

View File

@ -604,20 +604,26 @@ already exist, and switch to it."
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line)
(force-mode-line-update)
(spacemacs-buffer-mode))
(add-hook 'emacs-startup-hook
(lambda ()
(with-current-buffer (get-buffer spacemacs-buffer-name)
(when dotspacemacs-startup-lists
(spacemacs-buffer/insert-startupify-lists))
(if configuration-layer-error-count
(spacemacs-buffer/set-mode-line
(format (concat "%s error(s) at startup! "
"Spacemacs may not be able to operate properly.")
configuration-layer-error-count))
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line))
(force-mode-line-update)
(spacemacs-buffer-mode)
(spacemacs-buffer/goto-link-line))) t)))))
(add-hook
'emacs-startup-hook
(lambda ()
(with-current-buffer (get-buffer spacemacs-buffer-name)
(when dotspacemacs-startup-lists
(spacemacs-buffer/insert-startupify-lists))
(if configuration-layer-error-count
(progn
(spacemacs-buffer-mode)
(spacemacs-buffer/set-mode-line
(format
(concat "%s error(s) at startup! "
"Spacemacs may not be able to operate properly.")
configuration-layer-error-count))
(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)
(spacemacs-buffer/goto-link-line))) t)))))
(spacemacs-buffer/goto-link-line)
(switch-to-buffer spacemacs-buffer-name)
(spacemacs//redisplay))

View File

@ -1387,11 +1387,10 @@ on whether the spacemacs-ivy layer is used or not, with
(if (display-graphic-p) 'wave 'utf-8)))
(defun spacemacs//set-powerline-for-startup-buffers ()
"Set the powerline for buffers created when Emacs starts."
(unless configuration-layer-error-count
(dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*"))
(when (and (get-buffer buffer)
(configuration-layer/package-usedp 'spaceline))
(spacemacs//restore-powerline buffer)))))
(dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*"))
(when (and (get-buffer buffer)
(configuration-layer/package-usedp 'spaceline))
(spacemacs//restore-powerline buffer))))
(add-hook 'emacs-startup-hook
'spacemacs//set-powerline-for-startup-buffers))
: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 ()
"Set the powerline for buffers created when Emacs starts."
(unless configuration-layer-error-count
(dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*"))
(when (get-buffer buffer)
(with-current-buffer buffer
(setq-local mode-line-format (default-value 'mode-line-format))
(powerline-set-selected-window)
(powerline-reset))))))
(dolist (buffer '("*Messages*" "*spacemacs*" "*Compile-Log*"))
(when (get-buffer buffer)
(with-current-buffer buffer
(setq-local mode-line-format (default-value 'mode-line-format))
(powerline-set-selected-window)
(powerline-reset)))))
(add-hook 'emacs-startup-hook
'spacemacs//set-vimish-powerline-for-startup-buffers))