;; Author: Artur Malabarba <emacs@endlessparentheses.com>
;; URL: https://github.com/Malabarba/beacon
;; Keywords: convenience
-;; Version: 0.2.1
+;; Version: 0.3
;; Package-Requires: ((seq "1.9"))
;; This program is free software; you can redistribute it and/or modify
e.g. \"#666600\"."
:type '(choice number color))
+(defface beacon-fallback-background
+ '((((class color) (background light)) (:background "black"))
+ (((class color) (background dark)) (:background "white")))
+ "Fallback beacon background color.
+Used in cases where the color can't be determined by Emacs.
+Only the background of this face is used.")
+
(defvar beacon-dont-blink-predicates nil
"A list of predicates that prevent the beacon blink.
These predicate functions are called in order, with no
(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-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)
(beacon--maybe-push-mark)
(setq beacon--window-scrolled nil))
-(defun beacon--window-scroll-function (win _start-pos)
+(defun beacon--window-scroll-function (win start-pos)
"Blink the beacon or record that window has been scrolled.
If invoked during the command loop, record the current window so
that it may be blinked on post-command. This is because the
If invoked outside the command loop, `post-command-hook' would be
unreliable, so just blink immediately."
- (if this-command
- (setq beacon--window-scrolled win)
- (setq beacon--window-scrolled nil)
- (beacon-blink)))
+ (unless (and (equal beacon--previous-window-start start-pos)
+ (equal beacon--previous-window win))
+ (if this-command
+ (setq beacon--window-scrolled win)
+ (setq beacon--window-scrolled nil)
+ (beacon-blink))))
(defun beacon--blink-on-focus ()
"Blink if `beacon-blink-when-focused' is non-nil"