mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 14:30:50 -08:00
Fix hi-lock-tests when 'use-dialog-box' is non-nil
* test/lisp/hi-lock-tests.el (hi-lock-case-fold) (hi-lock-unhighlight): Bind 'use-dialog-box' to nil.
This commit is contained in:
parent
5093a53496
commit
deef41a825
1 changed files with 75 additions and 60 deletions
|
|
@ -86,13 +86,18 @@
|
||||||
(unhighlight-regexp "a a")
|
(unhighlight-regexp "a a")
|
||||||
(should (= (length (overlays-in (point-min) (point-max))) 0))
|
(should (= (length (overlays-in (point-min) (point-max))) 0))
|
||||||
|
|
||||||
(let ((search-spaces-regexp search-whitespace-regexp)) (highlight-regexp "a a"))
|
(let ((search-spaces-regexp search-whitespace-regexp))
|
||||||
|
(highlight-regexp "a a"))
|
||||||
(should (= (length (overlays-in (point-min) (point-max))) 1))
|
(should (= (length (overlays-in (point-min) (point-max))) 1))
|
||||||
(cl-letf (((symbol-function 'completing-read)
|
;; We bind use-dialog-box to nil to prevent unhighlight-regexp
|
||||||
(lambda (_prompt _coll
|
;; from using popup menus, since the replacement for
|
||||||
&optional _x _y _z _hist defaults _inherit)
|
;; completing-read below is not ready for that calamity
|
||||||
(car defaults))))
|
(let ((use-dialog-box nil))
|
||||||
(call-interactively 'unhighlight-regexp))
|
(cl-letf (((symbol-function 'completing-read)
|
||||||
|
(lambda (_prompt _coll
|
||||||
|
&optional _x _y _z _hist defaults _inherit)
|
||||||
|
(car defaults))))
|
||||||
|
(call-interactively 'unhighlight-regexp)))
|
||||||
(should (= (length (overlays-in (point-min) (point-max))) 0))
|
(should (= (length (overlays-in (point-min) (point-max))) 0))
|
||||||
|
|
||||||
(emacs-lisp-mode)
|
(emacs-lisp-mode)
|
||||||
|
|
@ -142,12 +147,16 @@
|
||||||
(let ((search-spaces-regexp search-whitespace-regexp)) (highlight-regexp "a a"))
|
(let ((search-spaces-regexp search-whitespace-regexp)) (highlight-regexp "a a"))
|
||||||
(font-lock-ensure)
|
(font-lock-ensure)
|
||||||
(should (memq 'hi-yellow (get-text-property 1 'face)))
|
(should (memq 'hi-yellow (get-text-property 1 'face)))
|
||||||
(cl-letf (((symbol-function 'completing-read)
|
;; We bind use-dialog-box to nil to prevent unhighlight-regexp
|
||||||
(lambda (_prompt _coll
|
;; from using popup menus, since the replacement for
|
||||||
&optional _x _y _z _hist defaults _inherit)
|
;; completing-read below is not ready for that calamity
|
||||||
(car defaults)))
|
(let ((use-dialog-box nil))
|
||||||
(font-lock-fontified t))
|
(cl-letf (((symbol-function 'completing-read)
|
||||||
(call-interactively 'unhighlight-regexp))
|
(lambda (_prompt _coll
|
||||||
|
&optional _x _y _z _hist defaults _inherit)
|
||||||
|
(car defaults)))
|
||||||
|
(font-lock-fontified t))
|
||||||
|
(call-interactively 'unhighlight-regexp)))
|
||||||
(should (null (get-text-property 1 'face))))))
|
(should (null (get-text-property 1 'face))))))
|
||||||
|
|
||||||
(ert-deftest hi-lock-unhighlight ()
|
(ert-deftest hi-lock-unhighlight ()
|
||||||
|
|
@ -156,58 +165,64 @@
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert "aAbB\n")
|
(insert "aAbB\n")
|
||||||
|
|
||||||
(cl-letf (((symbol-function 'completing-read)
|
;; We bind use-dialog-box to nil to prevent unhighlight-regexp
|
||||||
(lambda (_prompt _coll
|
;; from using popup menus, since the replacement for
|
||||||
&optional _x _y _z _hist defaults _inherit)
|
;; completing-read below is not ready for that calamity
|
||||||
(car defaults))))
|
(let ((use-dialog-box nil))
|
||||||
|
(cl-letf (((symbol-function 'completing-read)
|
||||||
|
(lambda (_prompt _coll
|
||||||
|
&optional _x _y _z _hist defaults _inherit)
|
||||||
|
(car defaults))))
|
||||||
|
(highlight-regexp "a")
|
||||||
|
(highlight-regexp "b")
|
||||||
|
(should (= (length (overlays-in (point-min) (point-max))) 4))
|
||||||
|
;; `hi-lock--regexps-at-point' should take regexp "a" at point 1,
|
||||||
|
;; not the last regexp "b"
|
||||||
|
(goto-char 1)
|
||||||
|
(call-interactively 'unhighlight-regexp)
|
||||||
|
(should (= (length (overlays-in 1 3)) 0))
|
||||||
|
(should (= (length (overlays-in 3 5)) 2))
|
||||||
|
;; Next call should unhighlight remaining regepxs
|
||||||
|
(call-interactively 'unhighlight-regexp)
|
||||||
|
(should (= (length (overlays-in 3 5)) 0))
|
||||||
|
|
||||||
(highlight-regexp "a")
|
;; Test unhighlight all
|
||||||
(highlight-regexp "b")
|
(highlight-regexp "a")
|
||||||
(should (= (length (overlays-in (point-min) (point-max))) 4))
|
(highlight-regexp "b")
|
||||||
;; `hi-lock--regexps-at-point' should take regexp "a" at point 1,
|
(should (= (length (overlays-in (point-min) (point-max))) 4))
|
||||||
;; not the last regexp "b"
|
(unhighlight-regexp t)
|
||||||
(goto-char 1)
|
(should (= (length (overlays-in (point-min) (point-max))) 0))
|
||||||
(call-interactively 'unhighlight-regexp)
|
|
||||||
(should (= (length (overlays-in 1 3)) 0))
|
|
||||||
(should (= (length (overlays-in 3 5)) 2))
|
|
||||||
;; Next call should unhighlight remaining regepxs
|
|
||||||
(call-interactively 'unhighlight-regexp)
|
|
||||||
(should (= (length (overlays-in 3 5)) 0))
|
|
||||||
|
|
||||||
;; Test unhighlight all
|
(emacs-lisp-mode)
|
||||||
(highlight-regexp "a")
|
(setq font-lock-mode t)
|
||||||
(highlight-regexp "b")
|
|
||||||
(should (= (length (overlays-in (point-min) (point-max))) 4))
|
|
||||||
(unhighlight-regexp t)
|
|
||||||
(should (= (length (overlays-in (point-min) (point-max))) 0))
|
|
||||||
|
|
||||||
(emacs-lisp-mode)
|
(highlight-regexp "a")
|
||||||
(setq font-lock-mode t)
|
(highlight-regexp "b")
|
||||||
|
(font-lock-ensure)
|
||||||
|
(should (memq 'hi-yellow (get-text-property 1 'face)))
|
||||||
|
(should (memq 'hi-yellow (get-text-property 3 'face)))
|
||||||
|
;; `hi-lock--regexps-at-point' should take regexp "a" at point 1,
|
||||||
|
;; not the last regexp "b"
|
||||||
|
(goto-char 1)
|
||||||
|
(let ((font-lock-fontified t))
|
||||||
|
(call-interactively 'unhighlight-regexp))
|
||||||
|
(should (null (get-text-property 1 'face)))
|
||||||
|
(should (memq 'hi-yellow (get-text-property 3 'face)))
|
||||||
|
;; Next call should unhighlight remaining regepxs
|
||||||
|
(let ((font-lock-fontified t))
|
||||||
|
(call-interactively 'unhighlight-regexp))
|
||||||
|
(should (null (get-text-property 3 'face)))
|
||||||
|
|
||||||
(highlight-regexp "a")
|
;; Test unhighlight all
|
||||||
(highlight-regexp "b")
|
(highlight-regexp "a")
|
||||||
(font-lock-ensure)
|
(highlight-regexp "b")
|
||||||
(should (memq 'hi-yellow (get-text-property 1 'face)))
|
(font-lock-ensure)
|
||||||
(should (memq 'hi-yellow (get-text-property 3 'face)))
|
(should (memq 'hi-yellow (get-text-property 1 'face)))
|
||||||
;; `hi-lock--regexps-at-point' should take regexp "a" at point 1,
|
(should (memq 'hi-yellow (get-text-property 3 'face)))
|
||||||
;; not the last regexp "b"
|
(let ((font-lock-fontified t))
|
||||||
(goto-char 1)
|
(unhighlight-regexp t))
|
||||||
(let ((font-lock-fontified t)) (call-interactively 'unhighlight-regexp))
|
(should (null (get-text-property 1 'face)))
|
||||||
(should (null (get-text-property 1 'face)))
|
(should (null (get-text-property 3 'face))))))))
|
||||||
(should (memq 'hi-yellow (get-text-property 3 'face)))
|
|
||||||
;; Next call should unhighlight remaining regepxs
|
|
||||||
(let ((font-lock-fontified t)) (call-interactively 'unhighlight-regexp))
|
|
||||||
(should (null (get-text-property 3 'face)))
|
|
||||||
|
|
||||||
;; Test unhighlight all
|
|
||||||
(highlight-regexp "a")
|
|
||||||
(highlight-regexp "b")
|
|
||||||
(font-lock-ensure)
|
|
||||||
(should (memq 'hi-yellow (get-text-property 1 'face)))
|
|
||||||
(should (memq 'hi-yellow (get-text-property 3 'face)))
|
|
||||||
(let ((font-lock-fontified t)) (unhighlight-regexp t))
|
|
||||||
(should (null (get-text-property 1 'face)))
|
|
||||||
(should (null (get-text-property 3 'face)))))))
|
|
||||||
|
|
||||||
(provide 'hi-lock-tests)
|
(provide 'hi-lock-tests)
|
||||||
;;; hi-lock-tests.el ends here
|
;;; hi-lock-tests.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue