Subject: Re: bug#74362: 31.0.50; Add completions for font names

From: Eli Zaretskii <[email-masked]>
Date: Sat, 16 Nov 2024 09:55:52 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 15 Nov 2024 12:33:14 -0500
> 
> > Also, the doc string of customize-face should be amended to say that
> > it offers completion on fonts.
> 
> Hmm... the docstring currently doesn't describe the UI at all (and
> I can't think of a reason why it should).  Similarly the manual doesn't
> seem to describe any part of the UI of `customize-face`.
> Apparently, we presume the UI is self-explanatory.  If we want to fix
> that, I think it's beyond the scope of this patch submission.

How about mentioning the completion in the help-echo of this field?

Btw, could set-face-font also benefit from this improvement?

> > Btw, how does one invoke completion on the face attributes which are
> > supposed to provide one, such as weight or colors?  M-C-i doesn't seem
> > to do it for me, or what am I missing?
> 
> M-TAB worked for me on the "Foregound" color name field.
> For weights, I see a menu rather than a text field so there doesn't seem
> to be a "completion" option.

Right.

Btw^2: When we select a font, do we have to change the Foundry as
well?  Or does Emacs disregard any non-matching foundries (if, for
example, the selected Family is not available with the specified
Foundry)?

> +        ;; Cache the list for a max of 60s.
> +        (let ((time (float-time)))
> +         (if (and lastlist (eq (selected-frame) lastframe)
> +                  (> 60 (- time lasttime)))

Maybe the 60 thing should be a defvar?

> --- a/lisp/cus-face.el
> +++ b/lisp/cus-face.el
> @@ -48,6 +48,7 @@ custom-declare-face
>  (defconst custom-face-attributes
>    `((:family
>       (string :tag "Font Family"
> +	     :completions custom-face--font-completion
>  	     :help-echo "Font family or fontset alias name."))

I'm curious: how come :foreground and :background don't need a
:completions specifier, and yet they provide completion OOTB?