unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74362: 31.0.50; Add completions for font names
@ 2024-11-14 22:48 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-15  8:39 ` Robert Pluim
  2024-11-15 12:24 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-14 22:48 UTC (permalink / raw)
  To: 74362; +Cc: monnier

Package: Emacs
Version: 31.0.50


In the UI of `customize-face`, the font family name is the main one that
provides no help to fill it.
The simple patch below provides completion (I had to put the completion
function in `cus-edit.el` because of a circularity between
`cus-face.el` and `minibuffer.el` so we can't call
`completion-table-dynamic` while loading `cus-face.el`).

Comments/objections?


        Stefan


diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 8eba4270bcb..763dfc31fb8 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -3425,6 +3425,12 @@ custom-visibility
 
 ;;; The `custom-face-edit' Widget.
 
+(defalias 'custom-face--font-completion 
+  (completion-table-dynamic
+   (lambda (_string)
+     (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:
diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index d0a1a66e29f..9a0ab4b47c7 100644
--- 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."))
 
     (:foundry






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#74362: 31.0.50; Add completions for font names
  2024-11-14 22:48 bug#74362: 31.0.50; Add completions for font names Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-15  8:39 ` Robert Pluim
  2024-11-15 16:50   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-15 12:24 ` Eli Zaretskii
  1 sibling, 1 reply; 4+ messages in thread
From: Robert Pluim @ 2024-11-15  8:39 UTC (permalink / raw)
  To: 74362; +Cc: Stefan Monnier

>>>>> On Thu, 14 Nov 2024 17:48:54 -0500, Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:

    Stefan> Package: Emacs
    Stefan> Version: 31.0.50


    Stefan> In the UI of `customize-face`, the font family name is the main one that
    Stefan> provides no help to fill it.
    Stefan> The simple patch below provides completion (I had to put the completion
    Stefan> function in `cus-edit.el` because of a circularity between
    Stefan> `cus-face.el` and `minibuffer.el` so we can't call
    Stefan> `completion-table-dynamic` while loading `cus-face.el`).

    Stefan> Comments/objections?

You have trailing whitespace. Also it would be better if this was
wrapped in `completion-table-case-fold', I think (everyone disagrees
on how to write "mono").

Robert
-- 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74362: 31.0.50; Add completions for font names
  2024-11-14 22:48 bug#74362: 31.0.50; Add completions for font names Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-15  8:39 ` Robert Pluim
@ 2024-11-15 12:24 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-11-15 12:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 74362

> Cc: monnier@iro.umontreal.ca
> Date: Thu, 14 Nov 2024 17:48:54 -0500
> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> In the UI of `customize-face`, the font family name is the main one that
> provides no help to fill it.
> The simple patch below provides completion (I had to put the completion
> function in `cus-edit.el` because of a circularity between
> `cus-face.el` and `minibuffer.el` so we can't call
> `completion-table-dynamic` while loading `cus-face.el`).
> 
> Comments/objections?

I suggest to try this on a system that has a lot of fonts installed,
to make sure this doesn't slow down customize-face too much.  In
bug#74337 a user reported that font-family-list returned a list of no
fewer than 10775(!) families.  I wonder what will that do to this
command.

Also, the doc string of customize-face should be amended to say that
it offers completion on fonts.

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?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74362: 31.0.50; Add completions for font names
  2024-11-15  8:39 ` Robert Pluim
@ 2024-11-15 16:50   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-15 16:50 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 74362

> You have trailing whitespace.

Thanks.  🙂

> Also it would be better if this was wrapped in
> `completion-table-case-fold', I think (everyone disagrees on how to
> write "mono").

So you're saying font family names are case-insensitive?
I was wondering about that and couldn't find it documented anywhere.


        Stefan






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-15 16:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 22:48 bug#74362: 31.0.50; Add completions for font names Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15  8:39 ` Robert Pluim
2024-11-15 16:50   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 12:24 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).