all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Need for colorful completing read
@ 2022-09-05 20:48 Jean Louis
  2022-09-05 20:51 ` Lars Ingebrigtsen
  2022-09-06  5:05 ` Akib Azmain Turja
  0 siblings, 2 replies; 15+ messages in thread
From: Jean Louis @ 2022-09-05 20:48 UTC (permalink / raw)
  To: Help GNU Emacs

Hello,

I would like to make a function similar to `completing-read' for the
choice of colors as shown by {M-x list-colors-display RET} so that I
can choose or select a color and that I can see the color while
selecting it.

Is that possible or maybe already exists somewhere?


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Need for colorful completing read
  2022-09-05 20:48 Need for colorful completing read Jean Louis
@ 2022-09-05 20:51 ` Lars Ingebrigtsen
  2022-09-05 21:07   ` Jean Louis
                     ` (2 more replies)
  2022-09-06  5:05 ` Akib Azmain Turja
  1 sibling, 3 replies; 15+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-05 20:51 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

Jean Louis <bugs@gnu.support> writes:

> I would like to make a function similar to `completing-read' for the
> choice of colors as shown by {M-x list-colors-display RET} so that I
> can choose or select a color and that I can see the color while
> selecting it.
>
> Is that possible or maybe already exists somewhere?

`read-color'



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

* Re: Need for colorful completing read
  2022-09-05 20:51 ` Lars Ingebrigtsen
@ 2022-09-05 21:07   ` Jean Louis
  2022-09-06  4:11     ` Emanuel Berg
  2022-09-06 10:02     ` Lars Ingebrigtsen
  2022-09-06  5:06   ` Akib Azmain Turja
  2022-09-06  8:59   ` Philip Kaludercic
  2 siblings, 2 replies; 15+ messages in thread
From: Jean Louis @ 2022-09-05 21:07 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Help GNU Emacs

* Lars Ingebrigtsen <larsi@gnus.org> [2022-09-05 23:51]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > I would like to make a function similar to `completing-read' for the
> > choice of colors as shown by {M-x list-colors-display RET} so that I
> > can choose or select a color and that I can see the color while
> > selecting it.
> >
> > Is that possible or maybe already exists somewhere?
> 
> `read-color'

Thanks, that is great. 

I am inspecting it. There are 754 completion possibilities. Do you
think this number is changeable over few years?

I am asking as I think I should rather put the list of colors into the
database so that a column references other table of these colors. 

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Need for colorful completing read
  2022-09-05 21:07   ` Jean Louis
@ 2022-09-06  4:11     ` Emanuel Berg
  2022-09-06 10:02     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 15+ messages in thread
From: Emanuel Berg @ 2022-09-06  4:11 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> `read-color'
>
> Thanks, that is great. 
>
> I am inspecting it. There are 754 completion possibilities.
> Do you think this number is changeable over few years?

They change over a few computers, rather. I have 10!

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Need for colorful completing read
  2022-09-05 20:48 Need for colorful completing read Jean Louis
  2022-09-05 20:51 ` Lars Ingebrigtsen
@ 2022-09-06  5:05 ` Akib Azmain Turja
  2022-09-11  6:26   ` Jean Louis
  1 sibling, 1 reply; 15+ messages in thread
From: Akib Azmain Turja @ 2022-09-06  5:05 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

[-- Attachment #1: Type: text/plain, Size: 1142 bytes --]

Jean Louis <bugs@gnu.support> writes:

> Hello,
>
> I would like to make a function similar to `completing-read' for the
> choice of colors as shown by {M-x list-colors-display RET} so that I
> can choose or select a color and that I can see the color while
> selecting it.
>
> Is that possible or maybe already exists somewhere?

It should be possible.  Marginalia shows faces (on *Completion* buffer,
or Vertico, or Selectrum) when you call describe-face.  So, you should
also be able to show the colors by show spaces with both background set
to the color you want to show.  May be you can use Marginalia to do
this.  See Marginalia README, C-h P marginalia RET (make sure you loaded
the package list with M-x package-show-package-list).

>
>
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/
>

-- 
Akib Azmain Turja

Find me on Mastodon at @akib@hostux.social.

This message is signed by me with my GnuPG key.  Its fingerprint is:

    7001 8CE5 819F 17A3 BBA6  66AF E74F 0EFA 922A E7F5

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: Need for colorful completing read
  2022-09-05 20:51 ` Lars Ingebrigtsen
  2022-09-05 21:07   ` Jean Louis
@ 2022-09-06  5:06   ` Akib Azmain Turja
  2022-09-06  8:59   ` Philip Kaludercic
  2 siblings, 0 replies; 15+ messages in thread
From: Akib Azmain Turja @ 2022-09-06  5:06 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean Louis, Help GNU Emacs

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Jean Louis <bugs@gnu.support> writes:
>
>> I would like to make a function similar to `completing-read' for the
>> choice of colors as shown by {M-x list-colors-display RET} so that I
>> can choose or select a color and that I can see the color while
>> selecting it.
>>
>> Is that possible or maybe already exists somewhere?
>
> `read-color'
>

Oh, yeah, I just forgot it.

-- 
Akib Azmain Turja

Find me on Mastodon at @akib@hostux.social.

This message is signed by me with my GnuPG key.  Its fingerprint is:

    7001 8CE5 819F 17A3 BBA6  66AF E74F 0EFA 922A E7F5

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: Need for colorful completing read
  2022-09-05 20:51 ` Lars Ingebrigtsen
  2022-09-05 21:07   ` Jean Louis
  2022-09-06  5:06   ` Akib Azmain Turja
@ 2022-09-06  8:59   ` Philip Kaludercic
  2022-09-06 10:03     ` Lars Ingebrigtsen
  2 siblings, 1 reply; 15+ messages in thread
From: Philip Kaludercic @ 2022-09-06  8:59 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean Louis, Help GNU Emacs

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Jean Louis <bugs@gnu.support> writes:
>
>> I would like to make a function similar to `completing-read' for the
>> choice of colors as shown by {M-x list-colors-display RET} so that I
>> can choose or select a color and that I can see the color while
>> selecting it.
>>
>> Is that possible or maybe already exists somewhere?
>
> `read-color'

Would there be any way to re-use this when completing color-names in CSS?



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

* Re: Need for colorful completing read
  2022-09-05 21:07   ` Jean Louis
  2022-09-06  4:11     ` Emanuel Berg
@ 2022-09-06 10:02     ` Lars Ingebrigtsen
  2022-09-06 10:20       ` Jean Louis
  1 sibling, 1 reply; 15+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-06 10:02 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

Jean Louis <bugs@gnu.support> writes:

> I am inspecting it. There are 754 completion possibilities. Do you
> think this number is changeable over few years?

It probably doesn't change a lot -- it looks like we haven't had a
change in the `x-colors' variable since 2010, for instance.




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

* Re: Need for colorful completing read
  2022-09-06  8:59   ` Philip Kaludercic
@ 2022-09-06 10:03     ` Lars Ingebrigtsen
  2022-09-06 10:11       ` Philip Kaludercic
  0 siblings, 1 reply; 15+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-06 10:03 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Jean Louis, Help GNU Emacs

Philip Kaludercic <philipk@posteo.net> writes:

> Would there be any way to re-use this when completing color-names in CSS?

I haven't looked at the CSS code -- are CSS colours the same as the "OS
colours"?




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

* Re: Need for colorful completing read
  2022-09-06 10:03     ` Lars Ingebrigtsen
@ 2022-09-06 10:11       ` Philip Kaludercic
  2022-09-06 10:27         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 15+ messages in thread
From: Philip Kaludercic @ 2022-09-06 10:11 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean Louis, Help GNU Emacs

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Would there be any way to re-use this when completing color-names in CSS?
>
> I haven't looked at the CSS code -- are CSS colours the same as the "OS
> colours"?

According to https://en.wikipedia.org/wiki/Web_colors:

          The first versions of Mosaic and Netscape Navigator used the
          X11 color names as the basis for their color lists, as both
          started as X Window System applications

          [...]

          Several colors are defined by web browsers. A particular
          browser may not recognize all of these colors, but as of 2005,
          all modern, general-use, graphical browsers support the full
          list of colors. Many of these colors are from the list of X11
          color names distributed with the X Window System.

So it looks like it.



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

* Re: Need for colorful completing read
  2022-09-06 10:02     ` Lars Ingebrigtsen
@ 2022-09-06 10:20       ` Jean Louis
  0 siblings, 0 replies; 15+ messages in thread
From: Jean Louis @ 2022-09-06 10:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Help GNU Emacs

* Lars Ingebrigtsen <larsi@gnus.org> [2022-09-06 13:03]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > I am inspecting it. There are 754 completion possibilities. Do you
> > think this number is changeable over few years?
> 
> It probably doesn't change a lot -- it looks like we haven't had a
> change in the `x-colors' variable since 2010, for instance.

Thank you, that is good reference.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Need for colorful completing read
  2022-09-06 10:11       ` Philip Kaludercic
@ 2022-09-06 10:27         ` Lars Ingebrigtsen
  2022-09-06 16:50           ` Yuri Khan
  0 siblings, 1 reply; 15+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-06 10:27 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Jean Louis, Help GNU Emacs

Philip Kaludercic <philipk@posteo.net> writes:

> So it looks like it.

Then I guess we can use that in css-mode.



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

* Re: Need for colorful completing read
  2022-09-06 10:27         ` Lars Ingebrigtsen
@ 2022-09-06 16:50           ` Yuri Khan
  2022-09-06 17:38             ` Philip Kaludercic
  0 siblings, 1 reply; 15+ messages in thread
From: Yuri Khan @ 2022-09-06 16:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Philip Kaludercic, Jean Louis, Help GNU Emacs

On Tue, 6 Sept 2022 at 19:29, Lars Ingebrigtsen <larsi@gnus.org> wrote:

> > So it looks like it.
>
> Then I guess we can use that in css-mode.

Does anybody use X11 colors in web design though? I had an impression
that most people™ define colors directly in #rrggbb or rgb(r, g, b) or
rgba(r, g, b, a). Sometimes in hsl, especially if they want nice
gradients. If they are wise enough, they define a few color-valued
custom properties (css variables) at the root element level, and
reference them from everywhere, but the color values are still mostly
#rrggbb and determined by the brandbook rather than the X11 list.



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

* Re: Need for colorful completing read
  2022-09-06 16:50           ` Yuri Khan
@ 2022-09-06 17:38             ` Philip Kaludercic
  0 siblings, 0 replies; 15+ messages in thread
From: Philip Kaludercic @ 2022-09-06 17:38 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Lars Ingebrigtsen, Jean Louis, Help GNU Emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Tue, 6 Sept 2022 at 19:29, Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
>> > So it looks like it.
>>
>> Then I guess we can use that in css-mode.
>
> Does anybody use X11 colors in web design though? I had an impression
> that most people™ define colors directly in #rrggbb or rgb(r, g, b) or
> rgba(r, g, b, a). Sometimes in hsl, especially if they want nice
> gradients. If they are wise enough, they define a few color-valued
> custom properties (css variables) at the root element level, and
> reference them from everywhere, but the color values are still mostly
> #rrggbb and determined by the brandbook rather than the X11 list.

FWIW I use them, though I don't create professional web sites.  That
being said, if css-mode offers completion it would still be nice to have
some kind of a idea what kind of colors some of the more outlandish
names represent.  There is also rainbow-mode, but that only works if the
text is already in the buffer.



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

* Re: Need for colorful completing read
  2022-09-06  5:05 ` Akib Azmain Turja
@ 2022-09-11  6:26   ` Jean Louis
  0 siblings, 0 replies; 15+ messages in thread
From: Jean Louis @ 2022-09-11  6:26 UTC (permalink / raw)
  To: Akib Azmain Turja; +Cc: Help GNU Emacs

* Akib Azmain Turja <akib@disroot.org> [2022-09-06 08:11]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > Hello,
> >
> > I would like to make a function similar to `completing-read' for the
> > choice of colors as shown by {M-x list-colors-display RET} so that I
> > can choose or select a color and that I can see the color while
> > selecting it.
> >
> > Is that possible or maybe already exists somewhere?
> 
> It should be possible.  Marginalia shows faces (on *Completion* buffer,
> or Vertico, or Selectrum) when you call describe-face.  So, you should
> also be able to show the colors by show spaces with both background set
> to the color you want to show.  May be you can use Marginalia to do
> this.  See Marginalia README, C-h P marginalia RET (make sure you loaded
> the package list with M-x package-show-package-list).

First I have entered all Emacs colors' names into the PostgreSQL
database by using emacs-libpq module:

(defun x-colors-to-db ()
  (let ((colors (sort x-colors 'string<)))
    (while colors
      (rcd-sql "INSERT INTO emacscolors (emacscolors_name) VALUES ($1)" cf-db (pop colors)))))

More about the module:

emacs-libpq @ Github:
https://github.com/anse1/emacs-libpq

Then I have some settings to find which table columns need to be
replaced with Emacs colors:

(defvar columns-to-read-color '(
				"hyobjectypes_emacsforegroundcolor"
				"hyobjectypes_emacsbackgroundcolor"
				)
  "Columns to read Emacs color.")

Then I have some conditional to recognize if value is asked for
specific column, so that it is replaced with `read-color':

    (let ((new-value (cond ((member column columns-to-choose-contact)
			    (let* ((query (rcd-ask cf-people-prompt))
				   (id (cf-people-search-id query)))
			      id))
			   ((member column columns-to-read-color)
			    (rcd-db-read-color-for-column value))

And then finally the function that verifies that color exists in the
database and choses color in colorful way.

(defun rcd-db-read-color-for-column (&optional value)
  "Return color ID with optional default VALUE."
  (let* ((color-chosen (read-color))
	 (value (if value (rcd-db-get-entry "emacscolors" "emacscolors_name" value cf-db)))
	 (color-chosen (if (seq-empty-p color-chosen) value color-chosen))
	 (color-name (rcd-db-get-entry-where "emacscolors" "emacscolors_name"
					     (format "emacscolors_name = '%s'" color-chosen) cf-db)))
    (if (and color-name
	       (string= color-name color-chosen))
	(let ((color-id (rcd-db-get-entry-where "emacscolors" "emacscolors_id"
						(format "emacscolors_name = '%s'" color-chosen) cf-db)))
	  color-id))))

One can see how it works here on video:
https://gnu.support/images/2022/09/2022-09-11/2022-09-11-09:23:09.ogv


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

end of thread, other threads:[~2022-09-11  6:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05 20:48 Need for colorful completing read Jean Louis
2022-09-05 20:51 ` Lars Ingebrigtsen
2022-09-05 21:07   ` Jean Louis
2022-09-06  4:11     ` Emanuel Berg
2022-09-06 10:02     ` Lars Ingebrigtsen
2022-09-06 10:20       ` Jean Louis
2022-09-06  5:06   ` Akib Azmain Turja
2022-09-06  8:59   ` Philip Kaludercic
2022-09-06 10:03     ` Lars Ingebrigtsen
2022-09-06 10:11       ` Philip Kaludercic
2022-09-06 10:27         ` Lars Ingebrigtsen
2022-09-06 16:50           ` Yuri Khan
2022-09-06 17:38             ` Philip Kaludercic
2022-09-06  5:05 ` Akib Azmain Turja
2022-09-11  6:26   ` Jean Louis

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.