]> code.delx.au - gnu-emacs-elpa/commitdiff
[#26] Fix when default background is unspecified-fg or unspecified-bg
authorSyohei YOSHIDA <syohex@gmail.com>
Wed, 28 Oct 2015 01:27:17 +0000 (10:27 +0900)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Wed, 28 Oct 2015 07:56:42 +0000 (07:56 +0000)
Default background color is unspecified-fg or unspecified-bg if emacs runs in
no-window mode(emacs -nw). '(color-values "unspecified-[fb]g")' returns nil
and beacon--color-range raises error.

Applying this patch uses fallback color instead of default background color.

Copyright-paperwork-exempt: yes

beacon.el

index 6433ba054505d1eb2fcd022c8b5ab3d4454db2d5..eb08d1a99f2dde0bf0a136c6ce561830ffcf5152 100644 (file)
--- a/beacon.el
+++ b/beacon.el
   :group 'emacs
   :prefix "beacon-")
 
+(defface beacon-fallback
+  '((((class color) (background light))
+     (:background "black"))
+    (((class color) (background dark))
+     (:background "white")))
+  "Fallback background color")
+
 (defvar beacon--timer nil)
 
 (defcustom beacon-push-mark 35
@@ -221,7 +228,10 @@ Only returns `beacon-size' elements."
 
 (defun beacon--color-range ()
   "Return a list of background colors for the beacon."
-  (let* ((bg (color-values (face-attribute 'default :background)))
+  (let* ((default-bg (face-attribute 'default :background))
+         (bg (color-values (if (string-prefix-p "unspecified" default-bg)
+                               (face-attribute 'beacon-fallback :background)
+                             default-bg)))
          (fg (cond
               ((stringp beacon-color) (color-values beacon-color))
               ((< (color-distance "black" bg)