diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 081b604d5b2..53e6f779b31 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -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. diff --git a/test/lisp/hi-lock-tests.el b/test/lisp/hi-lock-tests.el index 71983c713d2..760b319a926 100644 --- a/test/lisp/hi-lock-tests.el +++ b/test/lisp/hi-lock-tests.el @@ -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