From 3d5d0deda54a9381a5f8db7a5a05c93d09361a27 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Thu, 29 Sep 2022 23:03:21 +0300 Subject: [PATCH] ADDED: new user option sweeprolog-enable-cursor-sensor * sweeprolog-enable-cursor-sensor: New option * (sweeprolog-mode): use it --- sweeprolog.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 937e621..794e0aa 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -127,6 +127,16 @@ inserted to the input history in `sweeprolog-top-level-mode' buffers." :type '(repeat string) :group 'sweeprolog) +(defcustom sweeprolog-enable-cursor-sensor t + "If non-nil, enable `cursor-sensor-mode' in `sweeprolog-mode'. + +When enabled, `sweeprolog-mode' leverages `cursor-sensor-mode' to +highlight all occurences of the variable at point in the current +clause." + :package-version '((sweeprolog "0.4.2")) + :type 'boolean + :group 'sweeprolog) + (defvar sweeprolog-prolog-server-port nil) (declare-function sweeprolog-initialize "sweep-module") @@ -2179,17 +2189,10 @@ Interactively, POINT is set to the current point." (add-hook 'kill-buffer-hook (lambda () (when (timerp sweeprolog--timer) - (cancel-timer sweeprolog--timer)))))) - + (cancel-timer sweeprolog--timer))))) + (when sweeprolog-enable-cursor-sensor + (cursor-sensor-mode 1))) -(defun sweeprolog-cursor-sensor-functions (var) - (list - (lambda (_win old dir) - (if (eq dir 'entered) - (let ((sweeprolog--variable-at-point var)) - (font-lock-fontify-region (point) (point))) - (let ((sweeprolog--variable-at-point nil)) - (font-lock-fontify-region old old)))))) (provide 'sweeprolog) -- 2.39.2