1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

* cus-face.el: Provide completion for font families (bug#74362)

* lisp/cus-edit.el (custom-face--font-cache-timeout): New var.
(custom-face--font-completion): New function.
* lisp/cus-face.el (custom-face-attributes): Use it.
This commit is contained in:
Stefan Monnier 2024-11-17 17:49:49 -05:00
parent 200c877cd4
commit ea55048823
3 changed files with 26 additions and 1 deletions

View File

@ -167,6 +167,8 @@ GNU ELPA instead.
This inherits from the 'header-line' face, but is the face actually used
on the header lines (along with 'header-line-inactive').
** In 'customize-face', the "Font family" attribute now supports completion.
* Editing Changes in Emacs 31.1

View File

@ -3425,6 +3425,28 @@ to switch between two values."
;;; The `custom-face-edit' Widget.
(defvar custom-face--font-cache-timeout 60
"Refresh the cache of font families after at most this many seconds.")
(defalias 'custom-face--font-completion
(let ((lastlist nil)
(lasttime nil)
(lastframe nil))
(completion-table-case-fold
(completion-table-dynamic
(lambda (_string)
;; Flush the cache timeout after a while.
(let ((time (float-time)))
(if (and lastlist (eq (selected-frame) lastframe)
(> custom-face--font-cache-timeout (- time lasttime)))
lastlist
;; (message "last list time: %s" (if lasttime (- time lasttime)))
(setq lasttime time)
(setq lastframe (selected-frame))
(setq lastlist
(nconc (mapcar #'car face-font-family-alternatives)
(font-family-list))))))))))
(define-widget 'custom-face-edit 'checklist
"Widget for editing face attributes.
The following properties have special meanings for this widget:

View File

@ -48,7 +48,8 @@
(defconst custom-face-attributes
`((:family
(string :tag "Font Family"
:help-echo "Font family or fontset alias name."))
:completions custom-face--font-completion
:help-echo "Font family or fontset alias name (with completion)."))
(:foundry
(string :tag "Font Foundry"