]> git.eshelyaron.com Git - sweep.git/commitdiff
FIXED: error on interactively removing variable highlighting v0.4.2
authorEshel Yaron <me@eshelyaron.com>
Thu, 29 Sep 2022 20:12:02 +0000 (23:12 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 29 Sep 2022 20:24:22 +0000 (23:24 +0300)
sweeprolog.el

index 6782626c1745df6d51d6eadeb2660fb7fae93547..77dffd94aba91507ce15d19ce752f3780a5cd1c0 100644 (file)
@@ -2143,18 +2143,20 @@ Interactively, POINT is set to the current point."
                    (cons car (line-beginning-position))))
                (cdr sol)))))
 
-(defun sweeprolog-highlight-variable (var)
-  "Highlight occurences of the variable VAR in the current clause.
+(defun sweeprolog-highlight-variable (point &optional var)
+  "Highlight occurences of the variable VAR in the clause at POINT.
 
 If VAR is nil, clear variable highlighting in the current clause
 instead.
 
-Interactively, if a prefix argument is specificed, clear variable
-highlighting in the current clause.  Otherwise prompt for VAR,
-defaulting to the variable at point, if any."
-  (interactive (unless current-prefix-arg
-                 (let ((v (symbol-at-point)))
-                   (list (read-string "Highlight variable: "
+Interactively, operate on the clause at point.  If a prefix
+argument is specificed, clear variable highlighting in the
+current clause.  Otherwise prompt for VAR, defaulting to the
+variable at point, if any."
+  (interactive (list (point)
+                     (unless current-prefix-arg
+                       (let ((v (symbol-at-point)))
+                         (read-string "Highlight variable: "
                                       nil nil
                                       (and v
                                            (save-match-data
@@ -2165,14 +2167,14 @@ defaulting to the variable at point, if any."
                                            (symbol-name v))))))
                sweeprolog-mode sweeprolog-top-level-mode)
   (let ((sweeprolog--variable-at-point var))
-    (font-lock-fontify-region (point) (point))))
+    (font-lock-fontify-region point point)))
 
 (defun sweeprolog-cursor-sensor-functions (var)
   (list
    (lambda (_win old dir)
      (if (eq dir 'entered)
-         (sweeprolog-highlight-variable var)
-       (sweeprolog-highlight-variable nil)))))
+         (sweeprolog-highlight-variable (point) var)
+       (sweeprolog-highlight-variable old)))))
 
 (defvar-local sweeprolog--timer nil)
 (defvar-local sweeprolog--colourise-buffer-duration 0.2)