From c0f2acb9facba3858d0537456c8553a399e115ea Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Tue, 7 Nov 2023 20:00:27 +0900 Subject: [PATCH 1/3] Check delta-y and delta-x type to protect from misconfiguration No user feedback is produced --- beacon.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beacon.el b/beacon.el index 16b70f3..485a589 100644 --- a/beacon.el +++ b/beacon.el @@ -378,7 +378,8 @@ variables: `beacon-mode', `beacon-dont-blink-commands', "Return non-nil if latest vertical movement is > DELTA-Y. If DELTA-Y is nil, return nil. The same is true for DELTA-X and horizonta movement." - (and delta-y + + (and (numberp delta-y) (markerp beacon--previous-place) (equal (marker-buffer beacon--previous-place) (current-buffer)) @@ -387,7 +388,7 @@ The same is true for DELTA-X and horizonta movement." (> (abs (- (point) beacon--previous-place)) delta-y) ;; Col movement. - (or (and delta-x + (or (and (numberp delta-x) (> (abs (- (current-column) (save-excursion (goto-char beacon--previous-place) From e07416df1bca3ebb3214b436a208c823b9e20122 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Tue, 7 Nov 2023 20:36:32 +0900 Subject: [PATCH 2/3] Warn the user if misconfiguration detected --- beacon.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/beacon.el b/beacon.el index 485a589..c06ba05 100644 --- a/beacon.el +++ b/beacon.el @@ -379,6 +379,11 @@ variables: `beacon-mode', `beacon-dont-blink-commands', If DELTA-Y is nil, return nil. The same is true for DELTA-X and horizonta movement." + (when (and delta-y (not (numberp delta-y))) + (warn "beacon-blink-when-point-moves-vertically is not an integer.")) + (when (and delta-x (not (numberp delta-x))) + (warn "beacon-blink-when-point-moves-horizontally is not an integer.")) + (and (numberp delta-y) (markerp beacon--previous-place) (equal (marker-buffer beacon--previous-place) From 5fd72ee331163290f98c135c816ed1a2d4fb073c Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Tue, 7 Nov 2023 20:36:48 +0900 Subject: [PATCH 3/3] Fail and refuse to start mode if misconfiguration detected --- beacon.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/beacon.el b/beacon.el index c06ba05..a061114 100644 --- a/beacon.el +++ b/beacon.el @@ -481,6 +481,18 @@ unreliable, so just blink immediately." :global t (if beacon-mode (progn + ;; Fail when misconfigured. + (when (and beacon-blink-when-point-moves-horizontally + (not (numberp beacon-blink-when-point-moves-horizontally))) + (user-error + "When non-nil, beacon-blink-when-point-moves-horizontally is not an integer: %s" + beacon-blink-when-point-moves-horizontally)) + (when (and beacon-blink-when-point-moves-vertically + (not (numberp beacon-blink-when-point-moves-vertically))) + (user-error + "When non-nil, beacon-blink-when-point-moves-vertically is not an integer: %s" + beacon-blink-when-point-moves-vertically)) + (add-hook 'window-scroll-functions #'beacon--window-scroll-function) (add-function :after after-focus-change-function #'beacon--blink-on-focus)