+(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
+arguments, before blinking the beacon. If any returns
+non-nil, the beacon will not blink.
+
+For instance, if you want to disable beacon on buffers where
+`hl-line-mode' is on, you can do:
+
+ (add-hook \\='beacon-dont-blink-predicates
+ (lambda () (bound-and-true-p hl-line-mode)))")
+
+(add-hook 'beacon-dont-blink-predicates #'window-minibuffer-p)
+
+(defcustom beacon-dont-blink-major-modes '(t magit-status-mode magit-popup-mode
+ gnus-summary-mode gnus-group-mode)
+ "A list of major-modes where the beacon won't blink.
+Whenever the current buffer satisfies `derived-mode-p' for
+one of the major-modes on this list, the beacon will not
+blink."
+ :type '(repeat symbol))
+
+(defcustom beacon-dont-blink-commands '(next-line previous-line
+ forward-line)
+ "A list of commands that should not make the beacon blink.
+Use this for commands that scroll the window in very
+predictable ways, when the blink would be more distracting
+than helpful.."
+ :type '(repeat symbol))
+
+\f
+;;; Internal variables
+(defvar beacon--window-scrolled nil)
+(defvar beacon--previous-place nil)
+(defvar beacon--previous-mark-head nil)
+(defvar beacon--previous-window nil)
+(defvar beacon--previous-window-start 0)
+
+(defun beacon--record-vars ()
+ (unless (window-minibuffer-p)
+ (setq beacon--previous-mark-head (car mark-ring))
+ (setq beacon--previous-place (point-marker))
+ (setq beacon--previous-window (selected-window))
+ (setq beacon--previous-window-start (window-start))))
+