From dc4dd6db74fc2fa226c2b53984cf83ad07b909d2 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 31 Aug 2015 01:09:43 -0700 Subject: [PATCH] Automatically fix themes that set ansi-term-color-vector to old version Fixes `face-attribute: Invalid face: unspecified` --- dotfiles/emacs.d/init.el | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 28957188..aaa133c2 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -2119,17 +2119,29 @@ window is active in the perspective." (setq left-margin-width 0) (defvar-setq hl-line-mode nil)) +(defun imalison:after-load-theme (&rest args) + (when (fboundp 'powerline-reset) + (powerline-reset)) + (imalison:restore-ansi-term-color-vector)) + (when t (if (emacs24_4-p) - (advice-add 'load-theme :after #'(lambda (&rest args) - (when (fboundp 'powerline-reset) - (powerline-reset)))) + (advice-add 'load-theme :after #'imalison:after-load-theme) (defadvice load-theme (after name activate) - (when (fboundp 'powerline-reset) - (powerline-reset))))) + (imalison:after-load-theme)))) (when (file-exists-p custom-after-file) (load custom-after-file)) +(defvar imalison:ansi-term-color-vector ansi-term-color-vector) + +(defun imalison:ansi-term-color-vector-broken? () + (--some (or (eq it 'unspecified) (not (symbolp it))) + (append ansi-term-color-vector nil))) + +(defun imalison:restore-ansi-term-color-vector (&optional force) + (when (or force (imalison:ansi-term-color-vector-broken?)) + (setq ansi-term-color-vector imalison:ansi-term-color-vector))) + (defun imalison:appearance (&optional frame) (interactive) (message "called set appearance")