From: Artur Malabarba Date: Wed, 14 Oct 2015 08:46:20 +0000 (+0100) Subject: Default to blinking on window scroll instead of point movement X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/8abbedcc63e7e3d6efd1c0bbbdfd678b88592d21 Default to blinking on window scroll instead of point movement --- diff --git a/beacon.el b/beacon.el index cf3868bcb..0628dadc6 100644 --- a/beacon.el +++ b/beacon.el @@ -36,18 +36,25 @@ (defvar beacon--timer nil) -(defcustom beacon-minimum-distance 15 - "Minimum movement distance in lines to blink the beacon." - :type 'integer) - (defcustom beacon-push-mark nil "Should the mark be pushed before long movements?" :type 'boolean) +(defcustom beacon-blink-when-point-moves nil + "Should the beacon blink when changing buffer? +If nil, don't blink due to plain movement. +If non-nil, this should be an integer, which is the minimum +movement distance (in lines) that triggers a beacon blink." + :type '(choice integer (const nil))) + (defcustom beacon-blink-when-buffer-changes t "Should the beacon blink when changing buffer?" :type 'boolean) +(defcustom beacon-blink-when-window-scrolls t + "Should the beacon blink when the window scrolls?" + :type 'boolean) + (defcustom beacon-blink-duration 0.3 "Time, in seconds, that the blink should last." :type 'number) @@ -60,7 +67,7 @@ "Size of the beacon in characters." :type 'number) -(defcustom beacon-brightness 0.5 +(defcustom beacon-brightness 0.4 "Brightness as a float between 0 and 1." :type 'number) @@ -144,6 +151,7 @@ Only returns `beacon-size' elements." ;;; Movement detection (defvar beacon--previous-place nil) +(defvar beacon--previous-window-start nil) (defvar beacon--previous-mark-head nil) (defun beacon--maybe-push-mark () @@ -166,17 +174,24 @@ Only returns `beacon-size' elements." (when beacon-blink-when-buffer-changes (unless (window-minibuffer-p) (beacon-blink)))) - ;; Blink for distance movement - ((and (> (abs (- (point) beacon--previous-place)) - beacon-minimum-distance) + ;; Blink for scrolling. + ((and beacon-blink-when-window-scrolls + (progn (redisplay) + (not (equal beacon--previous-window-start (window-start))))) + (beacon--maybe-push-mark) + (beacon-blink)) + ;; Blink for movement + ((and beacon-blink-when-point-moves + (> (abs (- (point) beacon--previous-place)) + beacon-blink-when-point-moves) (> (count-screen-lines (min (point) beacon--previous-place) - (max (point) beacon--previous-place)) - beacon-minimum-distance)) + (max (point) beacon--previous-place)))) (beacon--maybe-push-mark) (beacon-blink)) ;; Even if we don't blink, vanish any previous beacon. (t (beacon--vanish))) (unless (window-minibuffer-p) + (setq beacon--previous-window-start (window-start)) (setq beacon--previous-mark-head (car mark-ring)) (setq beacon--previous-place (point-marker))))