]> code.delx.au - gnu-emacs-elpa/blobdiff - beacon.el
Try again to fix the case of no bg color
[gnu-emacs-elpa] / beacon.el
index c2b5f6b0b89907da83d569b9eeadafafee5cd2ca..4d4e58b2d88bb9f9c9e9d8db3053e106c875861f 100644 (file)
--- a/beacon.el
+++ b/beacon.el
@@ -256,17 +256,21 @@ Only returns `beacon-size' elements."
 (defun beacon--color-range ()
   "Return a list of background colors for the beacon."
   (let* ((default-bg (or (save-excursion
-                           (forward-line 1)
-                           (forward-char -1)
+                           (unless (eobp)
+                             (forward-line 1)
+                             (unless (or (bobp) (not (bolp)))
+                               (forward-char -1)))
                            (background-color-at-point))
                          (face-background 'default)))
-         (bg (color-values (if (string-match "\\`unspecified-" default-bg)
+         (bg (color-values (if (or (not (stringp default-bg))
+                                   (string-match "\\`unspecified-" default-bg))
                                (face-attribute 'beacon-fallback-background :background)
                              default-bg)))
          (fg (cond
               ((stringp beacon-color) (color-values beacon-color))
-              ((< (color-distance "black" bg)
-                  (color-distance "white" bg))
+              ((and (stringp bg)
+                    (< (color-distance "black" bg)
+                       (color-distance "white" bg)))
                (make-list 3 (* beacon-color 65535)))
               (t (make-list 3 (* (- 1 beacon-color) 65535))))))
     (apply #'seq-mapn (lambda (r g b) (format "#%04x%04x%04x" r g b))