Fix hl-line tests
authorPo Lu <luangruo@yahoo.com>
Wed, 23 Mar 2022 12:25:33 +0000 (20:25 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 23 Mar 2022 12:25:33 +0000 (20:25 +0800)
* lisp/hl-line.el (hl-line-mode): Restore old setter.
* test/lisp/hl-line-tests.el (hl-line-tests-verify): Don't rely
`cl-some' always returning t on success.
(hl-line-tests-sticky-across-frames): Use correct global variable.

lisp/hl-line.el
test/lisp/hl-line-tests.el

index 20b3f4160fd11351710c77b1ad5807b76530564c..e42d1d97d9d8ba2de18b38f0d366101d1783b7c8 100644 (file)
@@ -102,7 +102,15 @@ This variable has no effect in Global Highlight Line mode.
 For that, use `global-hl-line-sticky-flag'."
   :type 'boolean
   :version "22.1"
-  :group 'hl-line)
+  :group 'hl-line
+  :set (lambda (symbol value)
+         (set-default symbol value)
+         (unless value
+           (let ((selected (window-buffer (selected-window))))
+             (dolist (buffer (buffer-list))
+               (unless (eq buffer selected)
+                 (with-current-buffer buffer
+                   (hl-line-unhighlight))))))))
 
 (defcustom global-hl-line-sticky-flag nil
   "Non-nil means the Global HL-Line mode highlight appears in all windows.
index 6bff09135b225ce59a0db2bdaf9409adc603f8ba..888351addac0d37413c8f69517b445eeb11b292c 100644 (file)
 (require 'hl-line)
 
 (defsubst hl-line-tests-verify (_label on-p)
-  (eq on-p (cl-some (apply-partially #'eq hl-line--overlay)
-                    (overlays-at (point)))))
+  (if on-p
+      (cl-some (apply-partially #'eq hl-line-overlay)
+               (overlays-at (point)))
+    (not (cl-some (apply-partially #'eq hl-line-overlay)
+                  (overlays-at (point))))))
 
 (ert-deftest hl-line-tests-sticky-across-frames ()
   (skip-unless (display-graphic-p))
-  (customize-set-variable 'hl-line-sticky-flag t)
+  (customize-set-variable 'global-hl-line-sticky-flag t)
   (call-interactively #'global-hl-line-mode)
   (let ((first-frame (selected-frame))
         (first-buffer "foo")