GNU bug report logs -
#45829
28.0.50; Some tweaks to the color widget, from wid-edit+.el
Previous Next
Reported by: Mauro Aranda <maurooaranda <at> gmail.com>
Date: Tue, 12 Jan 2021 22:14:02 UTC
Severity: wishlist
Tags: fixed, patch
Found in version 28.0.50
Done: Mauro Aranda <maurooaranda <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Mauro Aranda <maurooaranda <at> 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
This bug report was last modified 4 years and 120 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.