* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
@ 2021-10-24 9:35 dalanicolai
2021-10-24 12:47 ` Stefan Kangas
0 siblings, 1 reply; 7+ messages in thread
From: dalanicolai @ 2021-10-24 9:35 UTC (permalink / raw)
To: 51371
[-- Attachment #1.1: Type: text/plain, Size: 4199 bytes --]
Motivation for this patch is that I would like to use the following code
snippet in https://elpa.gnu.org/packages/sketch-mode.html.
```
(let ((list-colors-sort 'hsv))
(list-colors-display (mapcar #'car shr-color-html-colors-alist)
nil))
```
The snippet passes colors form the shr-color-html-colors-alist variable
to list-colors-display. However, currently, despite the docstring
suggesting to me something different, the list-colors-display function
only applies its sort functionality if no list is passes as argument.
I don't see a good reason for that limitation, because the limitation is
set using a when condition, while the sort function works perfectly fine
with custom color-lists (e.g. try the snippet above).
So this patch simply removes the (when (null list)) condition, and
passes the list, if given, to the sort functionality.
Adapting the docstring is not necessary as it already suggests that the
sort functionality works in general.
With this patch, I can offer a great sorted color selection menu,
providing only colors supported by SVG.
In GNU Emacs 28.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.30,
cairo version 1.17.4)
of 2021-09-06 built on daniel-fedora
Repository revision: c4724add006e62b81f847937db56335a81bdcc74
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Fedora 34 (Workstation Edition)
Configured using:
'configure --with-mailutils --with-cairo --with-modules --with-pgtk
--with-native-compilation'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB
Important settings:
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=none
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)
Memory information:
((conses 16 67179 6847)
(symbols 48 6625 0)
(strings 32 19309 1709)
(string-bytes 1 660631)
(vectors 16 13095)
(vector-slots 8 260900 12229)
(floats 8 22 32)
(intervals 56 225 0)
(buffers 992 11))
[-- Attachment #1.2: Type: text/html, Size: 33059 bytes --]
[-- Attachment #2: facemenu.patch --]
[-- Type: text/x-patch, Size: 1083 bytes --]
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index 7417bb1203..d4d6975061 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -542,8 +542,7 @@ list-colors-display
colors that the current display can handle. Customize
`list-colors-sort' to change the order in which colors are shown.
Type \\<help-mode-map>\\[revert-buffer] after customizing \
-`list-colors-sort' to redisplay colors in
-the new order.
+`list-colors-sort' to redisplay colors in the new order.
If the optional argument BUFFER-NAME is nil, it defaults to \"*Colors*\".
@@ -551,8 +550,8 @@ list-colors-display
function to call each time the user types RET or clicks on a
color. The function should accept a single argument, the color name."
(interactive)
- (when (and (null list) (> (display-color-cells) 0))
- (setq list (list-colors-duplicates (defined-colors)))
+ (when (> (display-color-cells) 0)
+ (setq list (list-colors-duplicates (or list (defined-colors))))
(when list-colors-sort
;; Schwartzian transform with `(color key1 key2 key3 ...)'.
(setq list (mapcar
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
2021-10-24 9:35 bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general dalanicolai
@ 2021-10-24 12:47 ` Stefan Kangas
2021-10-24 13:16 ` dalanicolai
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2021-10-24 12:47 UTC (permalink / raw)
To: dalanicolai; +Cc: 51371
dalanicolai <dalanicolai@gmail.com> writes:
> The snippet passes colors form the shr-color-html-colors-alist variable
> to list-colors-display. However, currently, despite the docstring
> suggesting to me something different, the list-colors-display function
> only applies its sort functionality if no list is passes as argument.
> I don't see a good reason for that limitation, because the limitation is
> set using a when condition, while the sort function works perfectly fine
> with custom color-lists (e.g. try the snippet above).
>
> So this patch simply removes the (when (null list)) condition, and
> passes the list, if given, to the sort functionality.
> Adapting the docstring is not necessary as it already suggests that the sort functionality works in general.
Is there any situation in which you wouldn't want the list sorted?
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
2021-10-24 12:47 ` Stefan Kangas
@ 2021-10-24 13:16 ` dalanicolai
2021-10-24 13:18 ` dalanicolai
2021-10-24 22:08 ` Stefan Kangas
0 siblings, 2 replies; 7+ messages in thread
From: dalanicolai @ 2021-10-24 13:16 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51371
[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]
(@stefan Did not notice it was a group message)
Not really, I think. But if so then I guess we could just call it with
list-colors-sort set to nil:
```
(let ((list-colors-sort 'nil))
(list-colors-display (mapcar #'car shr-color-html-colors-alist)
nil))
```
On Sun, 24 Oct 2021 at 14:47, Stefan Kangas <stefan@marxist.se> wrote:
> dalanicolai <dalanicolai@gmail.com> writes:
>
> > The snippet passes colors form the shr-color-html-colors-alist variable
> > to list-colors-display. However, currently, despite the docstring
> > suggesting to me something different, the list-colors-display function
> > only applies its sort functionality if no list is passes as argument.
> > I don't see a good reason for that limitation, because the limitation is
> > set using a when condition, while the sort function works perfectly fine
> > with custom color-lists (e.g. try the snippet above).
> >
> > So this patch simply removes the (when (null list)) condition, and
> > passes the list, if given, to the sort functionality.
> > Adapting the docstring is not necessary as it already suggests that the
> sort functionality works in general.
>
> Is there any situation in which you wouldn't want the list sorted?
>
[-- Attachment #2: Type: text/html, Size: 1793 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
2021-10-24 13:16 ` dalanicolai
@ 2021-10-24 13:18 ` dalanicolai
2021-10-24 22:08 ` Stefan Kangas
1 sibling, 0 replies; 7+ messages in thread
From: dalanicolai @ 2021-10-24 13:18 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51371
[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]
The nil (again) without the quote of course
On Sun, 24 Oct 2021 at 15:16, dalanicolai <dalanicolai@gmail.com> wrote:
> (@stefan Did not notice it was a group message)
>
> Not really, I think. But if so then I guess we could just call it with
> list-colors-sort set to nil:
> ```
> (let ((list-colors-sort 'nil))
> (list-colors-display (mapcar #'car shr-color-html-colors-alist)
> nil))
> ```
>
>
>
> On Sun, 24 Oct 2021 at 14:47, Stefan Kangas <stefan@marxist.se> wrote:
>
>> dalanicolai <dalanicolai@gmail.com> writes:
>>
>> > The snippet passes colors form the shr-color-html-colors-alist variable
>> > to list-colors-display. However, currently, despite the docstring
>> > suggesting to me something different, the list-colors-display function
>> > only applies its sort functionality if no list is passes as argument.
>> > I don't see a good reason for that limitation, because the limitation is
>> > set using a when condition, while the sort function works perfectly fine
>> > with custom color-lists (e.g. try the snippet above).
>> >
>> > So this patch simply removes the (when (null list)) condition, and
>> > passes the list, if given, to the sort functionality.
>> > Adapting the docstring is not necessary as it already suggests that
>> the sort functionality works in general.
>>
>> Is there any situation in which you wouldn't want the list sorted?
>>
>
[-- Attachment #2: Type: text/html, Size: 2209 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
2021-10-24 13:16 ` dalanicolai
2021-10-24 13:18 ` dalanicolai
@ 2021-10-24 22:08 ` Stefan Kangas
2021-10-25 21:46 ` dalanicolai
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2021-10-24 22:08 UTC (permalink / raw)
To: dalanicolai; +Cc: 51371
dalanicolai <dalanicolai@gmail.com> writes:
> (@stefan Did not notice it was a group message)
>
> Not really, I think. But if so then I guess we could just call it with
> list-colors-sort set to nil:
> ```
> (let ((list-colors-sort 'nil))
^ no need to quote nil, BTW.
> (list-colors-display (mapcar #'car shr-color-html-colors-alist)
> nil))
> ```
Do we have any data from e.g. GNU ELPA, MELPA, GitHub or something to
back that up?
I checked, and we have only one call to `list-colors-display' in the
Emacs tree: in `widget-color--choose-action'. Does that function still
work as it should with your patch?
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
2021-10-24 22:08 ` Stefan Kangas
@ 2021-10-25 21:46 ` dalanicolai
2021-10-30 15:40 ` Stefan Kangas
0 siblings, 1 reply; 7+ messages in thread
From: dalanicolai @ 2021-10-25 21:46 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51371
[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]
I see, it is called when setting the face foreground/background via the
customize menu.
I've tested it, and it works still perfectly fine (as expected...
predicting the expected
effects/implications in this case seems quite straightforward to me).
On Mon, 25 Oct 2021 at 00:08, Stefan Kangas <stefan@marxist.se> wrote:
> dalanicolai <dalanicolai@gmail.com> writes:
>
> > (@stefan Did not notice it was a group message)
> >
> > Not really, I think. But if so then I guess we could just call it with
> > list-colors-sort set to nil:
> > ```
> > (let ((list-colors-sort 'nil))
> ^ no need to quote nil, BTW.
> > (list-colors-display (mapcar #'car shr-color-html-colors-alist)
> > nil))
> > ```
>
> Do we have any data from e.g. GNU ELPA, MELPA, GitHub or something to
> back that up?
>
> I checked, and we have only one call to `list-colors-display' in the
> Emacs tree: in `widget-color--choose-action'. Does that function still
> work as it should with your patch?
>
[-- Attachment #2: Type: text/html, Size: 1530 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general
2021-10-25 21:46 ` dalanicolai
@ 2021-10-30 15:40 ` Stefan Kangas
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Kangas @ 2021-10-30 15:40 UTC (permalink / raw)
To: dalanicolai; +Cc: 51371
close 51371 29.1
thanks
dalanicolai <dalanicolai@gmail.com> writes:
> I see, it is called when setting the face foreground/background via the customize menu.
> I've tested it, and it works still perfectly fine (as expected... predicting the expected
> effects/implications in this case seems quite straightforward to me).
OK, I think you are correct, and furthermore a caller can disable
sorting themselves by let-binding `list-colors-sort'. So I've pushed
your patch to master, after fixing it up to follow our conventions for
ChangeLog, etc. (See commit eb07b3d9b3.)
However, I skipped this hunk,
@@ -542,8 +542,7 @@ list-colors-display
colors that the current display can handle. Customize
`list-colors-sort' to change the order in which colors are shown.
Type \\<help-mode-map>\\[revert-buffer] after customizing \
-`list-colors-sort' to redisplay colors in
-the new order.
+`list-colors-sort' to redisplay colors in the new order.
If the optional argument BUFFER-NAME is nil, it defaults to \"*Colors*\".
as it would lead to this incorrectly filled docstring,
Display names of defined colors, and show what they look like.
If the optional argument LIST is non-nil, it should be a list of
colors to display. Otherwise, this command computes a list of
colors that the current display can handle. Customize
‘list-colors-sort’ to change the order in which colors are shown.
Type g after customizing ‘list-colors-sort’ to redisplay colors in
the new order.
You had missed that "\" character, which indicates a continued line.
In the future, you could send the patch using "git format-patch -1 HEAD"
to get a full git patch with your author details already filled in.
That makes it easier for us to install. Thanks for the patch!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-10-30 15:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-24 9:35 bug#51371: 28.0.50; [PATCH] Make list-colors-display sorting support general dalanicolai
2021-10-24 12:47 ` Stefan Kangas
2021-10-24 13:16 ` dalanicolai
2021-10-24 13:18 ` dalanicolai
2021-10-24 22:08 ` Stefan Kangas
2021-10-25 21:46 ` dalanicolai
2021-10-30 15:40 ` Stefan Kangas
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.