Fix thinko in previous hi-lock-read-face-name change

* lisp/hi-lock.el (hi-lock-read-face-name): Fix the string/symbol
logic.
This commit is contained in:
Lars Ingebrigtsen 2022-01-20 14:53:12 +01:00
parent 27b3948a8a
commit 6305c3f30d
2 changed files with 10 additions and 11 deletions

View file

@ -729,9 +729,10 @@ with completion and history."
face)
(if (and hi-lock-auto-select-face (not current-prefix-arg))
(setq face (or (pop hi-lock--unused-faces) (car defaults)))
(setq face (read-face-name
(format-prompt "Highlight using face" (car defaults))
defaults))
(setq face (symbol-name
(read-face-name
(format-prompt "Highlight using face" (car defaults))
defaults)))
;; Update list of un-used faces.
(setq hi-lock--unused-faces (remove face hi-lock--unused-faces))
;; Grow the list of defaults.

View file

@ -30,10 +30,9 @@
(let ((faces hi-lock-face-defaults))
(with-temp-buffer
(insert "a A b B\n")
(cl-letf (((symbol-function 'completing-read)
(lambda (_prompt _coll
&optional _x _y _z _hist defaults _inherit)
(car defaults))))
(cl-letf (((symbol-function 'read-face-name)
(lambda (_prompt &optional defaults)
(intern (car defaults)))))
(dotimes (_ 2)
(let ((face (hi-lock-read-face-name)))
(hi-lock-set-pattern "a" face))))
@ -43,10 +42,9 @@
(let ((faces hi-lock-face-defaults))
(with-temp-buffer
(insert "foo bar")
(cl-letf (((symbol-function 'completing-read)
(lambda (_prompt _coll
&optional _x _y _z _hist defaults _inherit)
(car defaults))))
(cl-letf (((symbol-function 'read-face-name)
(lambda (_prompt &optional defaults)
(intern (car defaults)))))
(hi-lock-set-pattern "9999" (hi-lock-read-face-name)) ; No match
(hi-lock-set-pattern "foo" (hi-lock-read-face-name)))
;; Only one match, then we have used just 1 face