[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el
From: |
Basil L. Contovounesios |
Subject: |
bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el |
Date: |
Fri, 15 Jan 2021 22:22:38 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Mauro Aranda <maurooaranda@gmail.com> writes:
> Opinions?
Just some minor nits from me.
> -;; Fixme: match
> (define-widget 'color 'editable-field
> "Choose a color name (with sample)."
> :format "%{%t%}: %v (%{sample%})\n"
> :value-create 'widget-color-value-create
> - :size 10
> + :size (1+ (apply #'max (mapcar #'length (defined-colors))))
Is defined-colors guaranteed to return non-nil?
If not, you need (apply #'max 0 ...).
> +(defun widget-color-match (_widget value)
> + "Non-nil if VALUE is a defined color or a RGB hex string."
> + (and (stringp value)
> + (or (color-defined-p value)
> + (string-match-p "^#\\([[:xdigit:]]\\{3\\}\\)\\{1,4\\}$" value))))
Shouldn't that be "\\`#[[:xdigit:]]\\{3\\}\\{1,4\\}\\'"
or at least "\\`#\\(?:[[:xdigit:]]\\{3\\}\\)\\{1,4\\}\\'"
(if you want to be explicit)?
> +(ert-deftest widget-test-color-match ()
> + "Test that the :match function for the color widget works."
> + (let* ((widget (widget-convert 'color)))
Nit: could also be let.
> + (should (widget-apply widget :match "red"))
> + (should (widget-apply widget :match "#fa3"))
> + (should (widget-apply widget :match "#ff0000"))
> + (should (widget-apply widget :match "#111222333"))
> + (should (widget-apply widget :match "#111122223333"))
> + (should-not (widget-apply widget :match "someundefinedcolorihope"))
> + (should-not (widget-apply widget :match "#11223"))))
Thanks,
--
Basil
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el, Mauro Aranda, 2021/01/12
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el, Mauro Aranda, 2021/01/12
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el,
Basil L. Contovounesios <=
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el, Eli Zaretskii, 2021/01/16
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el, Mauro Aranda, 2021/01/16
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el, Lars Ingebrigtsen, 2021/01/19
- bug#45829: 28.0.50; Some tweaks to the color widget, from wid-edit+.el, Mauro Aranda, 2021/01/19