From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs 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 Message-ID: <87v9bxg7rl.fsf@tcd.ie> References: <5ffe1f20.1c69fb81.77469.0e30@mx.google.com> <5ffe2149.1c69fb81.b9bf6.0d1d@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4029"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 45829@debbugs.gnu.org To: Mauro Aranda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 15 23:23:45 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0XVI-0000OS-EU for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Jan 2021 23:23:36 +0100 Original-Received: from localhost ([::1]:55308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0XVH-0001EF-GT for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Jan 2021 17:23:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0XUk-0000xU-Mi for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2021 17:23:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0XUk-0005BA-Eq for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2021 17:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l0XUk-000241-Bb for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2021 17:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Jan 2021 22:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45829 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45829-submit@debbugs.gnu.org id=B45829.16107493697900 (code B ref 45829); Fri, 15 Jan 2021 22:23:02 +0000 Original-Received: (at 45829) by debbugs.gnu.org; 15 Jan 2021 22:22:49 +0000 Original-Received: from localhost ([127.0.0.1]:41925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0XUX-00023M-2E for submit@debbugs.gnu.org; Fri, 15 Jan 2021 17:22:49 -0500 Original-Received: from mail-wr1-f50.google.com ([209.85.221.50]:44530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0XUU-000234-EY for 45829@debbugs.gnu.org; Fri, 15 Jan 2021 17:22:47 -0500 Original-Received: by mail-wr1-f50.google.com with SMTP id w5so10738201wrm.11 for <45829@debbugs.gnu.org>; Fri, 15 Jan 2021 14:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=jXjQ7OWuM526GQq0szkmqSKiippTIuWCPezJX/hA3YA=; b=MSo0arkKeFUsXZy4DTlsVHLVOo7jVVViGyWqYYyTTEyGgofWe/KneaPyDDANonNIwr tzm/OWKO6l6OJlwhsT8OpXWh/siyFGAKxyqLeUf9YQ3rBE5uYKGfNXthIhexwPNBJQIr o3Hm7PfdOMxvEn3qzBlHhhEo2MFYd/u6sFlGVQYKQNbk3FpDDjg5jH4ELK+hwsjG76fl LRuoxD348DXGHPaMMTo+Tg+GLgqniLq98SaqAi0UboM4zjsX8EfYpr+HdLLAfg3GreCV SDKirpdDgcdsKByyehBrEsU5X5y6lsOCiRbvP1iH2XYhE9LRn9OzpU1R3TgBWY4MDvFZ 454Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=jXjQ7OWuM526GQq0szkmqSKiippTIuWCPezJX/hA3YA=; b=W8WRehjWEtDrhptAKuy2/0XdbZGTqB5IVj5plQCm546VLzqaSS0SRZ0V/A+JYv9TzU oPCUxQOGAMmJGSmRhjydrGRMsF1MqPbHRe9TajrA+5jndrlB1ngL90k4fBUrzh1YOoOP 9a37+kJX8G7dLHbnfe1LHsw72ZN+iELQEeOIySOZdcJ2AJHbJBUWQc1Fef8/c4fV4Yv6 Kaqzd9u22ZLoUPIwkkhglKY/h7kslPHiB5har5AEbVKVw7GPeJuVZtjtDUbLMcUUMrTN TS4+0auJJ/U/bTr++5juFVAl51GjZC7zaAqGF7WBhn/haEFQwHfJYCBqx35OzfMX7raC F7Sw== X-Gm-Message-State: AOAM531UBGB5IEG4oC2PutWXCXpAkznCTnob7uMuEFwHowkG6wrhk+aR y0CgkEldoI2aPw99tm03rLBHwA== X-Google-Smtp-Source: ABdhPJwiUlRm0vlt2lvHeTs0h0BOZXBphdl7ElPBDcd7UweDw6BkpbRuK7f22QL4bXOAGuffVvQU7Q== X-Received: by 2002:a5d:65c4:: with SMTP id e4mr15816879wrw.115.1610749360547; Fri, 15 Jan 2021 14:22:40 -0800 (PST) Original-Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id m17sm17653770wrn.0.2021.01.15.14.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 14:22:39 -0800 (PST) In-Reply-To: <5ffe2149.1c69fb81.b9bf6.0d1d@mx.google.com> (Mauro Aranda's message of "Tue, 12 Jan 2021 19:23:03 -0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:198005 Archived-At: Mauro Aranda 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