aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTino Calancha2017-08-25 00:00:20 +0900
committerTino Calancha2017-08-25 00:09:50 +0900
commit303481b4ecd7d422653263389f86c83b4a4c855b (patch)
treeffebda89bb8f5cb6379a803073224c536eb816aa /test
parent0332a0ef2bbe6954f080cb6c9d3f0cc2517a1ab1 (diff)
downloademacs-303481b4ecd7d422653263389f86c83b4a4c855b.tar.gz
emacs-303481b4ecd7d422653263389f86c83b4a4c855b.zip
Keep face available if there are no matches
If font-lock-mode is disabled in the current buffer, and there are no matches for REGEXP, then keep FACE available for a next search. * lisp/hi-lock.el (hi-lock-set-pattern): Add FACE into hi-lock--unused-faces if font-lock-mode is disabled and there are no matches. * test/lisp/hi-lock-tests.el (hi-lock-test-set-pattern): Add test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/hi-lock-tests.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/lisp/hi-lock-tests.el b/test/lisp/hi-lock-tests.el
index 2cb662cfaca..9e2401979b0 100644
--- a/test/lisp/hi-lock-tests.el
+++ b/test/lisp/hi-lock-tests.el
@@ -36,5 +36,17 @@
36 (hi-lock-set-pattern "a" face)))) 36 (hi-lock-set-pattern "a" face))))
37 (should (equal hi-lock--unused-faces (cdr faces)))))) 37 (should (equal hi-lock--unused-faces (cdr faces))))))
38 38
39(ert-deftest hi-lock-test-set-pattern ()
40 (let ((faces hi-lock-face-defaults))
41 (with-temp-buffer
42 (insert "foo bar")
43 (cl-letf (((symbol-function 'completing-read)
44 (lambda (prompt coll x y z hist defaults)
45 (car defaults))))
46 (hi-lock-set-pattern "9999" (hi-lock-read-face-name)) ; No match
47 (hi-lock-set-pattern "foo" (hi-lock-read-face-name)))
48 ;; Only one match, then we have used just 1 face
49 (should (equal hi-lock--unused-faces (cdr faces))))))
50
39(provide 'hi-lock-tests) 51(provide 'hi-lock-tests)
40;;; hi-lock-tests.el ends here 52;;; hi-lock-tests.el ends here