From unknown Thu Aug 21 12:10:02 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#29456 <29456@debbugs.gnu.org> To: bug#29456 <29456@debbugs.gnu.org> Subject: Status: [PATCH] Add command for cycling between CSS color formats Reply-To: bug#29456 <29456@debbugs.gnu.org> Date: Thu, 21 Aug 2025 19:10:02 +0000 retitle 29456 [PATCH] Add command for cycling between CSS color formats reassign 29456 emacs submitter 29456 Simen Heggest=C3=B8yl severity 29456 wishlist tag 29456 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 26 10:22:14 2017 Received: (at submit) by debbugs.gnu.org; 26 Nov 2017 15:22:14 +0000 Received: from localhost ([127.0.0.1]:59452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eIyl4-0006n7-DE for submit@debbugs.gnu.org; Sun, 26 Nov 2017 10:22:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eIyl0-0006mq-LA for submit@debbugs.gnu.org; Sun, 26 Nov 2017 10:22:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eIyku-0000lD-4U for submit@debbugs.gnu.org; Sun, 26 Nov 2017 10:22:05 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56717) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eIykt-0000l7-Va for submit@debbugs.gnu.org; Sun, 26 Nov 2017 10:22:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIyks-0001OZ-An for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 10:22:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eIyko-0000iC-4V for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 10:22:02 -0500 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:45405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eIykn-0000gS-Lu for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 10:21:58 -0500 Received: by mail-lf0-x22d.google.com with SMTP id f131so21971306lff.12 for ; Sun, 26 Nov 2017 07:21:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:mime-version; bh=mrKyEUoEVbcYYCddCyexZ0VlpVqu7cLNxTgrJzUpFfs=; b=rhi3rCbOT4uwJGjRyhPp301YlqoZEhmmZR0mIKSpzpJrmJwwh/ZcEhii6d69ltCOkW OAQxSCp/ropEp7MY8W8fAQeNjYv5Et7WTs+tN5c0uAaxs7bCXM50uZNDvdQ8Qg2fIlqX I3UjNKi05hNiNf33h7iZ6LLYEPn9vYBjc8UNFHLHK5s5P+iGYtaP883gEQX4xxfm+Y4H qCaInGt9ccv27uSmVlxLJZFjKu8Zqqe2CEgcwZ9Xi1jfXQY7x2ew52qLA0hdxdw/adJw MSIVCNLWMlJc0xsmKOA5t8+jFkrC1avUsd6+kBfiIPASvM9eQudCRxkFh/t6StenP+bZ 1OQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:mime-version; bh=mrKyEUoEVbcYYCddCyexZ0VlpVqu7cLNxTgrJzUpFfs=; b=O7c2dFpwCnzCkulb5B6U8NHZCdPlgzkDbVtRQWSPw/b6dTi4TY12nqlIGnEqFEZMXf 4iSi+UlSFDevwbykJAR8LU/wMZP4aL49WJrmsFtV5+CcgVfYdCjFWFFjARzmtgcAJlaQ 2MCS29VsDHUU+vHh1oMImKLuXEZiTalh0xxewoIPWH4KS9IYsZV0mvkyV7BvlGpCwqBc UR3bSrLSMo8vUgV2IvGmrXsthZkU8XBu06mNl+TQPrjXGG043NTpULq0j9BDTKKMFv/2 yi8BjUgmtxfTmpoo5D77gIBRnGzWLILhFYJZheqET3NqXvXeMsKCYdTroDC7xIXS6/ct m2Bg== X-Gm-Message-State: AJaThX4ZXaql+eNgwImB8iLK0PNh27llQs4+/L8nVr9hYhGshzscGPec t4ZskL8e6SGdc747LPOU5vx8ew== X-Google-Smtp-Source: AGs4zMbAHsOR0ZcLpPRQldC2smX9c4ersnrAjgPxBWY7sbj0xywcHj1DFtXF458AA7VW4PB7QRFC6Q== X-Received: by 10.25.87.210 with SMTP id l201mr6581257lfb.101.1511709715535; Sun, 26 Nov 2017 07:21:55 -0800 (PST) Received: from [192.168.100.8] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id k69sm4466128lfg.63.2017.11.26.07.21.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Nov 2017 07:21:54 -0800 (PST) Date: Sun, 26 Nov 2017 16:21:51 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: [PATCH] Add command for cycling between CSS color formats To: bug-gnu-emacs@gnu.org Message-Id: <1511709711.2341.0@smtp.gmail.com> X-Mailer: geary/0.12-dev MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-kcsKK7l//BZQd9NVfWnf" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Tom Tromey , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-kcsKK7l//BZQd9NVfWnf Content-Type: multipart/alternative; boundary="=-9vqaxKBQ/2EMX1OwhFN5" --=-9vqaxKBQ/2EMX1OwhFN5 Content-Type: text/plain; charset=us-ascii; format=flowed The attached patch adds a new command 'css-cycle-color-format' to CSS mode, for cycling between color formats (e.g. "black" => "#000000" => "rgb(0, 0, 0)" => "black"), bound to 'C-c C-f'. I'll install the patch after a while unless there are any comments. -- Simen --=-9vqaxKBQ/2EMX1OwhFN5 Content-Type: text/html; charset=us-ascii
The attached patch adds a new command 'css-cycle-color-format' to CSS
mode, for cycling between color formats (e.g. "black" => "#000000" =>
"rgb(0, 0, 0)" => "black"), bound to 'C-c C-f'.

I'll install the patch after a while unless there are any comments.

-- Simen
--=-9vqaxKBQ/2EMX1OwhFN5-- --=-kcsKK7l//BZQd9NVfWnf Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-command-for-cycling-between-CSS-color-formats.patch Content-Transfer-Encoding: quoted-printable >From 54f258b39822d7042c240fe6bbde63ccfb49e59d Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Sun, 17 Sep 2017 20:08:18 +0200 Subject: [PATCH] Add command for cycling between CSS color formats * lisp/textmodes/css-mode.el (css-mode-map): Add keybinding for `css-cycle-color-format'. (css--web-color-to-4-dpc, css-named-color-to-hex) (css-hex-to-rgb, css-rgb-to-named-color-or-hex): New functions. (css-cycle-color-format): New command for cycling between color formats. * test/lisp/textmodes/css-mode-tests.el (css-test-web-color-to-4-dpc): (css-test-named-color-to-hex, css-test-hex-to-rgb) (css-test-rgb-to-named-color-or-hex, css-test-cycle-color-format): New tests for the functions mentioned above. * etc/NEWS: Mention the new command. --- etc/NEWS | 7 ++++ lisp/textmodes/css-mode.el | 79 +++++++++++++++++++++++++++++++= +++- test/lisp/textmodes/css-mode-tests.el | 53 +++++++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index c47ca42d27..ab9f285740 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -63,6 +63,13 @@ whether '"' is also replaced in 'electric-quote-mode'. = If non-nil, =0C * Changes in Specialized Modes and Packages in Emacs 27.1 =20 +** CSS mode + +--- +*** A new command 'css-cycle-color-format' for cycling between color +formats (e.g. "black" =3D> "#000000" =3D> "rgb(0, 0, 0)") has been added, +bound to 'C-c C-f'. + ** Dired =20 +++ diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 93ca36b08a..~ M32R{!269{ ߓ]_ƺǙs7Wguwm(|SN,jJN!J;Bgy %6 ]e*AsF#B@)T<"m4m8=,\Af Gzu6TDUoY?3m^Άq;8ukefF? k)芧6yȦeEI6 kUj/ݸ$ZPҹ[E-c+IJ^oG2 |Y݀*k1op]'@k.Yt`q5GodС+v&{_+ [5 V5[QАUNVP>-Rr*@7Ca ==[flP%0"-76EdV C53R!.+GlrHjyCe2>#eu:=n TuRKnޠ=*9PL8.zFmwn`Ώt+ڡG/t D2-.!ienb֛XI< a]qblB 0 "x1ۤv{yd+?Λ=5!'СZh%<kÑAcvTjx-~ D&'3e:j)q;(_aNjJ~娬rA)PQ 7ҴfϠf2*i֌<|~ aJM@Gk6hB-.6- h=~sZqȤ"s4/v5YC#٬ԩyU;Ud=m"rݢcƮ,Kk#zWfQ˵rVk}u5Bq_TGA6DtbT[@@|LIfGVnjI\Z֛}{ )lݶfG}M2Xgׇ[^MaERT&o=:!Dڢ|h|_: G*'Sy)LTGG~}gY^-/F=+1ko,u/yšg#A]$;ޔ6ݢy h:#XIQJN1 >"$o Kw"5a1_9N4pd/-\ U..nӬZi c h%#pfVY}WYX8%^+  'Fڣs(Vr7_o%XnFUFUrW_sÔmq;{\6n_04 +㯖֊g<|oi-!$`I劼 t=%]FscҰ@!-36-罢<\)H\uKct2]Rd/:RVhVЋ6[YK<mE*9'ʶ=N@bBǿsWҊ=jvQS<)U8,LPHh |.v^Cql"طn4"?UAQ "3U(14&Ova[}}g uU-$˙$<8S,{خVS=Hշm3]-Z؃ m[_[BM뎥Djxe*:|)j^'NQVnκC7zU}2>8=Ph}orE^"n HVl(Je1 &{ (!:k ]iHO+CޗRmLhfޗ\m{X8ud{-~%ȦVƣ 2,OKnlK$&K[q0}GmX[0uX(C\cc*[<䜹mFIZ` v"ȋndc0 7HSj(hw {mւͩAx/ dKFNkCfaknkKx@' |*VvEfA`"Ѐ8JL\t-- 뢑-v6.,ɧ q_ &v-CX[dBkt{Lf&UǹGUReh'^RVkucTF2mwpWAoߐJ$BP ?f¶+ɺEyD6Ld+)ߒγdDiFK[X^h}~6 a!L>as!D5bl7>>?NGۨAy,XH[}0V7ЙNp+qd {Khy"v`6/]Oh<:i84,:_A94]{H {'/s"d9O֖6l??(9-_[}T7x?Vm$&awv%:́` pBRUHt@!O%)I,q*UO' Cgak݊QI5+aMkD_Ĩœ*AGҗ~o8ND59yAxɨ3+n/lH.ލUyBUˆy~FZ4\vIwCb5im TJ 1Xz: /,TSzPnj&f{qθ?8=^Y^ieQ°q1вWRc\<Ե+򶕁ogDzį'W\7O6=\ aM$V$LSǛ]Ki c4BsLtBðN7qnf7Mm|YvˊɳE֮qI OQJIm:\nCʛSF-5yxcj}S?!$hʞ_0uKԧ$>NOtvÔ5ؕbϷv$Ti})-L(83gԆ5 C |o yt Җm^F /w#$x iH)V:^);ЦN-oiغ(arz,BfgzዴVͤB 4vxa}15.ZR)TvrxBV<DDpk|Kɳ v sEua.gff=e.xv_CbbX dEc-#3*Lg*hN8c<wG*UYC%A 9_{0`q"@,PNaI&}fAۿs\yםp4TUFOa@p!Qntr({;Bkv6O;')HKRYTBaEf(@ʻarm@Pnvj݉6Y2dXl`Jo)5w:c]vobOᑧ`P|Spn&ڼ$p_Ic9gklO[>PNK`a2Á%S])ºծ@Iؖzĩ 8/a#zy){jOg0a0IF B]tp?dtj(A!2\Gqؿ%UzNA0pg U w"IPȭ̾yVsbLL P:.;/A߇h2y<|,*1~t]SZC!H8$>Bz2oԁɇ^3|UOoDB̥e9ؐ~eÓtŻZ]6RPxQB%k-9Eޓo }F)zτuQT2"h3%L#6}~ /#U^ipۆϟ"+z*r#I5N\qE<R\ 0LJ%OʕڰMuӂiMFk}glI%Hh5s3Ӡzt0c v13_ A\5YK_5X6ӻ0&z?\VY tiU7 WpϜXA VvR/e=]0𻡼5MÇC:<,l%ݪnBq7>V}{Von2,dOJP{rsO 1L/5VL݋֗6^ƊOgk{I͆Dq%dۯRi鈅IBl$w.!OhA`cy?UY&`f(}#f<l=Bɡ̸D&*RV[[d.95W(fq#g,%c!eT)K+߲Z%7oPLCh a9; L7!Mɱd Ff1m(]!J'z`619X 91mBm֫*6t޼( ;;^!Z-y]|nf)'>R7 ͱ{UV&6Nɗe$wKO?Jt $)tr@Sii2K8mT7З.,6H"U!<~c@UW@7pә8οt&pGЌ{-{)vsBW2yz_pk# h+gv|7C5\$[:= r+p$;2+篥7 OJ=G[4eָc= xI>@ePBpS@Ȑ(E߀/T}Sd3U#Qf֟ќxq}ŷlċ&竷[75 `SFE8vTs(^9ז9(4 ZtS N T'~밳q=U!^Z{8&Z6=U P2}kŋ`N1=Ug"c]L~ %Q]jG̴]0˒#s/oP|j[L'n˜0^Jg;wb$vu1E?6?|YEZ G`uNmS +dɛ횯S{<p{G?u5H>PpWoBa.s=`#G):Y&f0Hf n qDď}t3y5 fXU 1r<ځ0 Vcaj QIfF+ BwM jSN%a>?6!zP^~:u%Ӑ!u惯[?r !Q1 w,ctK BY5;6cyD%)<9Tuc6b Q~#$APiE,Q ٍ|Bik (, N\Cz͞_rV$Q*8є]95kLtҗo<5&'9`gbQ4V7j(a`_Y߂c4[\\ W)Rzp[sn*o@'99#x 3@}ϴ!l0A?2y|Vi`-zut:Jto<`3ePj|F"hecdG; _h(F([G}?{ ƿ0QuIl/:k6:9>dh] M AD-ÙES 2?Sn0C:OFgdi = fVDI:2Pj} t}{`b)?J8@,Z {yycx"&:->])Gch;(;0'aP]o 2&ݏX~iK"Rfۺl]B1kRqѸwA0f[棁Ni2+ؽ:\> ݙ۲<6oNX@tY['&VŌ 8_Įt\$jfEP:nJ:7?"%)Od~l3mstKЍ$ B "OzokyTewyDhLB͖2+HAU6 _X abled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57755) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJ17m-0005Io-Kl for submit@debbugs.gnu.org; Sun, 26 Nov 2017 12:53:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJ17l-0005hG-HQ for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 12:53:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJ17i-0005HY-DG for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 12:53:49 -0500 Received: from gateway20.websitewelcome.com ([192.185.54.2]:46246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJ17i-0005BJ-4B for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 12:53:46 -0500 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 44D97400D38AB for ; Sun, 26 Nov 2017 11:53:32 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id J17UeP0F7DL8rJ17UeA85d; Sun, 26 Nov 2017 11:53:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HYdOho+CjJgDDyrz6qrxc/y05qUPimSOWPJ2XUkNGVs=; b=BFjDk2QXzEBciagfGbLKIufphB j102nHb/Aep9d38tIAzoOAYGKnLw7fHPQ7DhIEGcJilU5O2mzajTGvuMmujdg6TSODzWkdLgQs1tH BPptBiajT0O1UFriHivb/i5Pa; Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:36232 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eJ17U-000zcO-0k; Sun, 26 Nov 2017 11:53:32 -0600 From: Tom Tromey References: <1511709711.2341.0@smtp.gmail.com> X-Attribution: Tom Date: Sun, 26 Nov 2017 10:53:30 -0700 In-Reply-To: <1511709711.2341.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sun, 26 Nov 2017 16:21:51 +0100") Message-ID: <873751vsdh.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.90.63 X-Source-L: No X-Exim-ID: 1eJ17U-000zcO-0k X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya) [71.218.90.63]:36232 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> I'll install the patch after a while unless there are any comments. Nice feature! It seems to me that none of the functions handle alpha components. css-color-4 added optional alpha to hex colors (and made rgb and rgba synonyms), and there's been rgba for a while... Tom From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 26 12:53:57 2017 Received: (at submit) by debbugs.gnu.org; 26 Nov 2017 17:53:57 +0000 Received: from localhost ([127.0.0.1]:59580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJ17t-0005o9-Gs for submit@debbugs.gnu.org; Sun, 26 Nov 2017 12:53:57 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJ17s-0005nw-PI for submit@debbugs.gnu.org; Sun, 26 Nov 2017 12:53:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJ17m-0005Iw-OI for submit@debbugs.gnu.org; Sun, 26 Nov 2017 12:53:51 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57755) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJ17m-0005Io-Kl for submit@debbugs.gnu.org; Sun, 26 Nov 2017 12:53:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJ17l-0005hG-HQ for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 12:53:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJ17i-0005HY-DG for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 12:53:49 -0500 Received: from gateway20.websitewelcome.com ([192.185.54.2]:46246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJ17i-0005BJ-4B for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2017 12:53:46 -0500 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 44D97400D38AB for ; Sun, 26 Nov 2017 11:53:32 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id J17UeP0F7DL8rJ17UeA85d; Sun, 26 Nov 2017 11:53:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HYdOho+CjJgDDyrz6qrxc/y05qUPimSOWPJ2XUkNGVs=; b=BFjDk2QXzEBciagfGbLKIufphB j102nHb/Aep9d38tIAzoOAYGKnLw7fHPQ7DhIEGcJilU5O2mzajTGvuMmujdg6TSODzWkdLgQs1tH BPptBiajT0O1UFriHivb/i5Pa; Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:36232 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eJ17U-000zcO-0k; Sun, 26 Nov 2017 11:53:32 -0600 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: [PATCH] Add command for cycling between CSS color formats References: <1511709711.2341.0@smtp.gmail.com> X-Attribution: Tom Date: Sun, 26 Nov 2017 10:53:30 -0700 In-Reply-To: <1511709711.2341.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sun, 26 Nov 2017 16:21:51 +0100") Message-ID: <873751vsdh.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.90.63 X-Source-L: No X-Exim-ID: 1eJ17U-000zcO-0k X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya) [71.218.90.63]:36232 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, Tom Tromey , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> I'll install the patch after a while unless there are any comments. Nice feature! It seems to me that none of the functions handle alpha components. css-color-4 added optional alpha to hex colors (and made rgb and rgba synonyms), and there's been rgba for a while... Tom From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 12:08:40 2017 Received: (at 29456) by debbugs.gnu.org; 27 Nov 2017 17:08:40 +0000 Received: from localhost ([127.0.0.1]:32935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJMtc-0007F6-1W for submit@debbugs.gnu.org; Mon, 27 Nov 2017 12:08:40 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJMta-0007Es-M3 for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 12:08:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJMtR-0000LA-CZ for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 12:08:33 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJMt6-00006O-TF; Mon, 27 Nov 2017 12:08:08 -0500 Received: from [176.228.60.248] (port=2128 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eJMt6-0000Ht-56; Mon, 27 Nov 2017 12:08:08 -0500 Date: Mon, 27 Nov 2017 19:07:56 +0200 Message-Id: <83indv645v.fsf@gnu.org> From: Eli Zaretskii To: Simen =?utf-8?Q?Heggest=C3=B8yl?= In-reply-to: <1511709711.2341.0@smtp.gmail.com> (message from Simen =?utf-8?Q?Heggest=C3=B8yl?= on Sun, 26 Nov 2017 16:21:51 +0100) Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats References: <1511709711.2341.0@smtp.gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Sun, 26 Nov 2017 16:21:51 +0100 > From: Simen Heggestøyl > Cc: Tom Tromey , Stefan Monnier > > The attached patch adds a new command 'css-cycle-color-format' to CSS > mode, for cycling between color formats (e.g. "black" => "#000000" => > "rgb(0, 0, 0)" => "black"), bound to 'C-c C-f'. Thanks. These functions are confusingly similar to, but subtly different from, the similar functions in color.el, and in general the whole system of color conversions used by Emacs for its display needs. Here's a tell-tale example: (css--web-color-to-4-dpc "#fff") => "#ffffffffffff" but (apply 'color-rgb-to-hex (color-name-to-rgb "#fff")) => "#f0f0f0f0f0f0" The latter follows the X color definitions, so why does css-mode.el need a different interpretation of the hex-RGB notation? My fear is that someone will mix css-mode functions with those from elsewhere in Emacs, and will bump into confusing and contradicting results. Is it possible to avoid that? From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 12:41:34 2017 Received: (at 29456) by debbugs.gnu.org; 27 Nov 2017 17:41:34 +0000 Received: from localhost ([127.0.0.1]:32950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNPR-0008CM-W1 for submit@debbugs.gnu.org; Mon, 27 Nov 2017 12:41:34 -0500 Received: from gateway23.websitewelcome.com ([192.185.48.71]:26604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNPP-0008CE-Pl for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 12:41:32 -0500 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 30F895BA9E for <29456@debbugs.gnu.org>; Mon, 27 Nov 2017 11:41:31 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id JNPPekviBpOTvJNPPeQ4tT; Mon, 27 Nov 2017 11:41:31 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=I/TQqFlE+v8913HIcuwv41GjKAIRBos8/7jEmK78lrQ=; b=LsDvj4lcBSc71gipcH9qfaXJX8 tK9F3VO1uc9rJYsJsEvgz9k8m0KGDANdKeGYWrWsh3tNjiY0bwBtyM/8sTrIBoSEiB+61rTNhoBnr b2ixZWbGR5lT3dGemvymBdrQ1; Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:54294 helo=pokyo) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eJNPO-000bFV-QX; Mon, 27 Nov 2017 11:41:30 -0600 From: Tom Tromey To: Eli Zaretskii Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats References: <1511709711.2341.0@smtp.gmail.com> <83indv645v.fsf@gnu.org> X-Attribution: Tom Date: Mon, 27 Nov 2017 10:41:29 -0700 In-Reply-To: <83indv645v.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 Nov 2017 19:07:56 +0200") Message-ID: <87a7z7aaba.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.90.63 X-Source-L: No X-Exim-ID: 1eJNPO-000bFV-QX X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-90-63.hlrn.qwest.net (pokyo) [71.218.90.63]:54294 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, tom@tromey.com, Simen =?utf-8?Q?Heggest=C3=B8yl?= , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) >>>>> "Eli" == Eli Zaretskii writes: Eli> The latter follows the X color definitions, so why does css-mode.el Eli> need a different interpretation of the hex-RGB notation? CSS color names came from X a long time ago, but their mapping to rgb is now part of the CSS specification. And, apparently there were multiple versions of this file coming from X. The Emacs one would be ok provided the lists are identical and will always remain so. Otherwise, css-mode needs its own list. Eli> My fear is that someone will mix css-mode functions with those from Eli> elsewhere in Emacs, and will bump into confusing and contradicting Eli> results. Is it possible to avoid that? Using "css-" in the name seems sufficient to me. Maybe a comment explaining this would help as well. Tom From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 13:11:46 2017 Received: (at 29456) by debbugs.gnu.org; 27 Nov 2017 18:11:46 +0000 Received: from localhost ([127.0.0.1]:32989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNsg-0000cM-3R for submit@debbugs.gnu.org; Mon, 27 Nov 2017 13:11:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNse-0000c8-14 for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 13:11:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJNsX-0003aC-VH for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 13:11:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJNsS-0003Y2-Py; Mon, 27 Nov 2017 13:11:32 -0500 Received: from [176.228.60.248] (port=2319 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eJNsS-0007gF-2c; Mon, 27 Nov 2017 13:11:32 -0500 Date: Mon, 27 Nov 2017 20:11:21 +0200 Message-Id: <83d1436186.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey In-reply-to: <87a7z7aaba.fsf@tromey.com> (message from Tom Tromey on Mon, 27 Nov 2017 10:41:29 -0700) Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats References: <1511709711.2341.0@smtp.gmail.com> <83indv645v.fsf@gnu.org> <87a7z7aaba.fsf@tromey.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, simenheg@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Tom Tromey > Cc: Simen Heggestyl , > 29456@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca > Date: Mon, 27 Nov 2017 10:41:29 -0700 > > >>>>> "Eli" == Eli Zaretskii writes: > > Eli> The latter follows the X color definitions, so why does css-mode.el > Eli> need a different interpretation of the hex-RGB notation? > > CSS color names came from X a long time ago, but their mapping to rgb is > now part of the CSS specification. And, apparently there were multiple > versions of this file coming from X. The Emacs one would be ok provided > the lists are identical and will always remain so. Otherwise, css-mode > needs its own list. Sorry, I don't understand: what list are you talking about? > Eli> My fear is that someone will mix css-mode functions with those from > Eli> elsewhere in Emacs, and will bump into confusing and contradicting > Eli> results. Is it possible to avoid that? > > Using "css-" in the name seems sufficient to me. Maybe a comment > explaining this would help as well. A comment will help, but I'm actually wondering why does css-mode need to use 12-bit or 16-bit per component RGB notation? Why not use only 8-bit, as in #RRGGBB? The problems only happen in converting 8-bit RGB notations to higher number of bits. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 13:35:13 2017 Received: (at 29456) by debbugs.gnu.org; 27 Nov 2017 18:35:13 +0000 Received: from localhost ([127.0.0.1]:33017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJOFM-0001J4-UQ for submit@debbugs.gnu.org; Mon, 27 Nov 2017 13:35:13 -0500 Received: from gateway31.websitewelcome.com ([192.185.143.38]:20677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJOFK-0001Iw-Jn for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 13:35:11 -0500 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id E0EDF1A6A6 for <29456@debbugs.gnu.org>; Mon, 27 Nov 2017 12:35:07 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id JOFFeGx5DRtUXJOFFeOVAY; Mon, 27 Nov 2017 12:35:07 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2F4Tgp5wiYNhOvqpe9XjCbZ+2+YjuY9YgtGY3pKXbRk=; b=D0cFYsZIwylBmKhgMGlAs5Sjj7 k8CFNNyq6Fv7SfT7nYy6qAgi2Q3V5dns9DKHxgwwQcz9H7whdPQhVMZ9TFspvlWUJnbwgJR20WlX2 v5McgKuV5gF9QSS3Gc8QS+005; Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:54788 helo=pokyo) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eJOFF-000jgN-54; Mon, 27 Nov 2017 12:35:05 -0600 From: Tom Tromey To: Eli Zaretskii Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats References: <1511709711.2341.0@smtp.gmail.com> <83indv645v.fsf@gnu.org> <87a7z7aaba.fsf@tromey.com> <83d1436186.fsf@gnu.org> X-Attribution: Tom Date: Mon, 27 Nov 2017 11:35:04 -0700 In-Reply-To: <83d1436186.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 Nov 2017 20:11:21 +0200") Message-ID: <87609va7tz.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.90.63 X-Source-L: No X-Exim-ID: 1eJOFF-000jgN-54 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-90-63.hlrn.qwest.net (pokyo) [71.218.90.63]:54788 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, Tom Tromey , simenheg@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) >>>>> "Eli" == Eli Zaretskii writes: Eli> Sorry, I don't understand: what list are you talking about? Sorry, I misunderstood. CSS also specifies hex and rgb syntax itself. Eli> A comment will help, but I'm actually wondering why does css-mode need Eli> to use 12-bit or 16-bit per component RGB notation? Why not use only Eli> 8-bit, as in #RRGGBB? The problems only happen in converting 8-bit Eli> RGB notations to higher number of bits. #RGB is specified by CSS, it is equivalent to #RRGGBB, and is often seen. With css-color-4, #RGBA is also allowed. Basically css-mode needs to understand the peculiarities of CSS syntax, which differs somewhat from other systems AFAIK. Tom From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 13:43:44 2017 Received: (at 29456) by debbugs.gnu.org; 27 Nov 2017 18:43:44 +0000 Received: from localhost ([127.0.0.1]:33021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJONc-0001XG-Ef for submit@debbugs.gnu.org; Mon, 27 Nov 2017 13:43:44 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJONY-0001Wv-QQ for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 13:43:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJONS-0002m9-Bs for 29456@debbugs.gnu.org; Mon, 27 Nov 2017 13:43:35 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJONL-0002lA-CD; Mon, 27 Nov 2017 13:43:27 -0500 Received: from [176.228.60.248] (port=2536 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eJONJ-0008FQ-LZ; Mon, 27 Nov 2017 13:43:27 -0500 Date: Mon, 27 Nov 2017 20:43:06 +0200 Message-Id: <83bmjn5zr9.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey In-reply-to: <87609va7tz.fsf@tromey.com> (message from Tom Tromey on Mon, 27 Nov 2017 11:35:04 -0700) Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats References: <1511709711.2341.0@smtp.gmail.com> <83indv645v.fsf@gnu.org> <87a7z7aaba.fsf@tromey.com> <83d1436186.fsf@gnu.org> <87609va7tz.fsf@tromey.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, simenheg@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Tom Tromey > Cc: Tom Tromey , simenheg@gmail.com, 29456@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Mon, 27 Nov 2017 11:35:04 -0700 > > Eli> A comment will help, but I'm actually wondering why does css-mode need > Eli> to use 12-bit or 16-bit per component RGB notation? Why not use only > Eli> 8-bit, as in #RRGGBB? The problems only happen in converting 8-bit > Eli> RGB notations to higher number of bits. > > #RGB is specified by CSS, it is equivalent to #RRGGBB, and is often > seen. With css-color-4, #RGBA is also allowed. > > Basically css-mode needs to understand the peculiarities of CSS syntax, > which differs somewhat from other systems AFAIK. Then I think there should be a prominent remark in the doc strings of css-mode not to mix these functions with those from color.el, due to this incompatibility. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 28 13:33:41 2017 Received: (at 29456) by debbugs.gnu.org; 28 Nov 2017 18:33:41 +0000 Received: from localhost ([127.0.0.1]:35053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJkhR-0007iv-Ii for submit@debbugs.gnu.org; Tue, 28 Nov 2017 13:33:41 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:41312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJkhP-0007ig-G3 for 29456@debbugs.gnu.org; Tue, 28 Nov 2017 13:33:39 -0500 Received: by mail-lf0-f49.google.com with SMTP id f18so904109lfg.8 for <29456@debbugs.gnu.org>; Tue, 28 Nov 2017 10:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:date:message-id:mime-version; bh=moCTQ4g+b87/Ubu2g5Q0f/XFCeXSHJR27X/ommkmRBg=; b=gxhPm94jrNYhUwIb4LyQtEjMe2KyMX3Ldq2fkiU8JrahXYtntR++S4HHjCaUKkthZr IsjDvT3lCKecCZTArYDwSQXNOUmZW2bWzHM63G+6Nz/Vz6JvVsS1ZWvK86pXAnNc/1Ve zkQtscxMiJU4qnytmGggZ8XKskpkblj2RgE0J9XQHu9r6wMhEEq918xW9aD8rmyqjBxv U02vNvq7EjJ9mL9BbahbUHNnx4xLt0VD5eOpF24LRSvWfYuICN5ukkf1jAYlqrG3L0Ud x5kr0YDzDDApeFdOb1OaWQMlumtopILRaSAQUVtmB83eg64ZsRK7zPtRxNvpACizHRdm mU1g== 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:in-reply-to:date:message-id :mime-version; bh=moCTQ4g+b87/Ubu2g5Q0f/XFCeXSHJR27X/ommkmRBg=; b=HUg87mJkYlTvN26dSzjbVqI7znwFNEKrmsst0N/P7miTslabL5ay6YKfvn187cxrep UY7JiVawGwZuq9toyfXZkUcMmdzcmWKF3VoDd1VvjnI3bfTuW0YfhIcJxxAmwgyDwrPg MdnxwJpMqjn5aFHhY2QOuaf+voKqmlmVGArQ23vtN1APQZehfGCuCN/6EdtwOzvAtERr KxdwWA1XIS52RT/fg4YkOxL1KD5V89tJYJAccHcxpuFlnLOMVUTMESAlCck4yalHXj6x q4ZbTKXaZWFBN7/4otGykDQw/5td3LfSrovwbWzgQcHAo0nOyvB48gtiTTXzixU9NVbM yg/A== X-Gm-Message-State: AJaThX4uLoJqZb/UxvkfOk01d1J51OomGVLdcUpabkc4tg50hWP31P4j 4muDliz79VhaD0zRA6k6QFk= X-Google-Smtp-Source: AGs4zMbmayw9wtcs1NOfv71m8eu1U4zwFGQLoiM2FLvVnBv2BfkF0b9ypl+ZZNntFPMwciMQbk/2ZA== X-Received: by 10.25.151.206 with SMTP id z197mr24165lfd.139.1511894013565; Tue, 28 Nov 2017 10:33:33 -0800 (PST) Received: from x240 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id t16sm6676341lje.81.2017.11.28.10.33.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Nov 2017 10:33:32 -0800 (PST) From: =?utf-8?Q?Simen_Heggest=C3=B8yl?= To: Eli Zaretskii Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats In-Reply-To: <83bmjn5zr9.fsf@gnu.org> (message from Eli Zaretskii on Mon, 27 Nov 2017 20:43:06 +0200) Date: Tue, 28 Nov 2017 19:33:30 +0100 Message-ID: <87lgiqmex1.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Tom Tromey writes: > Nice feature! Glad you like it! > It seems to me that none of the functions handle alpha components. > css-color-4 added optional alpha to hex colors (and made rgb and rgba > synonyms), and there's been rgba for a while... Right, it makes sense to support that too. I haven't used alpha formats other than rgba(...) myself. Would it be useful for rgba(255, 0, 0, 0.5) to turn into #ff000088, for instance? Eli Zaretskii writes: > Then I think there should be a prominent remark in the doc strings of > css-mode not to mix these functions with those from color.el, due to > this incompatibility. That sounds like a good idea. I'll address the comments from both of you in an update to the patch, though it might be a while until I have the time to update it. Thanks for your comments so far. -- Simen From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 28 15:57:43 2017 Received: (at 29456) by debbugs.gnu.org; 28 Nov 2017 20:57:43 +0000 Received: from localhost ([127.0.0.1]:35185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJmwo-0004kG-Or for submit@debbugs.gnu.org; Tue, 28 Nov 2017 15:57:42 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:39614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJmwl-0004k0-LC for 29456@debbugs.gnu.org; Tue, 28 Nov 2017 15:57:41 -0500 Received: by mail-lf0-f46.google.com with SMTP id l81so1381416lfl.6 for <29456@debbugs.gnu.org>; Tue, 28 Nov 2017 12:57:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:date:message-id:mime-version :content-transfer-encoding; bh=RobXH8+WNn8dtQH9l6pFI2tKNnqX7iA+Pc1EUkqgpt4=; b=dh/qAR7nJ4RBTC5y7ktBtyeSbsvsnh4+/6EGBzJ9ccTEMqGKczxMrlrMHA0SnQ8ccM 5NNq4dZDitb+Md7uHkMJiUV3+wjEIuuXVnYaSDhVKiqmLwaDRutRwtYRlHbJJtfSDJ27 vORqamr+wq4OSiA5JvDg7Woh5soDa0rp0V2oWBoIoACmu0MskZPPv8Mq0UrfzkxmMXuy QZlw0NcQNAqUJQ/ETGLDJp3rGcCXk7pRrjHcDDx9pKzqRM6nLJzprh7m3ocn8oqlQXKY uZqrKvePe9YJJ2svIr8Og4ARXzqSdwx2Cltg+RrgTE+gXdzVHjYEkfhTyDAgf2PFA5qb 4EKw== 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:in-reply-to:date:message-id :mime-version:content-transfer-encoding; bh=RobXH8+WNn8dtQH9l6pFI2tKNnqX7iA+Pc1EUkqgpt4=; b=Oj6/MVRgpHFZnPz7mpITNeZu6TVwvCnWbe+3ByAQ4RvurPKk/Ilx/4S6bPeRO/yCy3 cqkxTPClDzxTp8xKUrxVI8KQZKmzgo5Pf7jYbubTKuT10VtBoGyeHk1ikKJqOetXdVGc JkWrw2Yxc9KbqkNimiVrFn7e8WVTbSOE29TWKVCXw1YhiBqY+OoMnNXYFrK+cooEjnkJ Q8zdoTWgOroORJs/lRClaP5+nWY5eCPghkGxaITsosgRh8hPa+rtTNmFIvwtiR1nZZ7B gRSv51SJ8GedshTv8o9MiJkRzurtmQsVpOIPlEDhnNR7D75sLe8UyCUj6A9XDQ6bUbTW ZM5A== X-Gm-Message-State: AJaThX7fRpw1+kbvqbjhHgWmN8gxvhc9RAu7o6BWoFwuFenECdQPs+Tl II2bcbYhBmS3LQHox+bFKZA= X-Google-Smtp-Source: AGs4zMa46HBxPpyNU1L0JCh3j8hA5HjaygTqYYbbxnPtgSyVBxC1WH/4IoyvUW5Ok8vEphZpqsGLPw== X-Received: by 10.46.89.2 with SMTP id n2mr216619ljb.149.1511902653562; Tue, 28 Nov 2017 12:57:33 -0800 (PST) Received: from x240 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id s66sm15477lje.40.2017.11.28.12.57.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Nov 2017 12:57:32 -0800 (PST) From: =?utf-8?Q?Simen_Heggest=C3=B8yl?= To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats In-Reply-To: <87lgiqmex1.fsf@gmail.com> (message from Simen =?utf-8?Q?Hegg?= =?utf-8?Q?est=C3=B8yl?= on Tue, 28 Nov 2017 19:33:30 +0100) Date: Tue, 28 Nov 2017 21:57:30 +0100 Message-ID: <87shcyce9x.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29456 Cc: eliz@gnu.org, 29456@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Simen Heggest=C3=B8yl writes: > Right, it makes sense to support that too. I haven't used alpha formats > other than rgba(...) myself. Would it be useful for rgba(255, 0, 0, 0.5) > to turn into #ff000088, for instance? ^^^^^^^^^ #ff000080, sorry. -- Simen From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 10 07:46:26 2017 Received: (at 29456) by debbugs.gnu.org; 10 Dec 2017 12:46:26 +0000 Received: from localhost ([127.0.0.1]:54557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eO0zx-0002vd-Hx for submit@debbugs.gnu.org; Sun, 10 Dec 2017 07:46:26 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:37173) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eO0zw-0002vM-4z for 29456@debbugs.gnu.org; Sun, 10 Dec 2017 07:46:24 -0500 Received: by mail-lf0-f54.google.com with SMTP id a12so16275950lfe.4 for <29456@debbugs.gnu.org>; Sun, 10 Dec 2017 04:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=VhUF/O4BrK/Fq23NL1gKy8jlqRQTdyK8Wx/bs9SQNxo=; b=jmYyHOaiGZ+V9TVtr+2utnFVDGe8rpw2DnmJYNCIIzXDPdhx/MZxqGoiM1gfDizlxV q7bTpAS9IzSoHH8p6GNG/ce4kPpzpT/iC7Z+wgT7MqgKZyCj3E4S9+uTGAK783yWSvTQ ljnACxurP5VGbcslQ1bR6jwT0F5ToNvzbzBDgxrJUpqP5TXXF3pKSnRLE5YlsO9cuFCy uF/Eu5zRdTw1cD9iRi83WZ2/SWAljaZX4ds+BGBeBf/PdYZGjVYNAsQIArKM2w+fOXGm YYUUHjJFwm9lvlxecT5UlpSe9mKJEEy0eAaIWL0LirkXW7p0aLKYp/NnNV6V3xnPlVQR c+kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=VhUF/O4BrK/Fq23NL1gKy8jlqRQTdyK8Wx/bs9SQNxo=; b=o8ng4UrAC8jO+/zFaCFqJq+Gozm4FXJPZ9yUUskD05wTvlonCSOTUyuluEMcT7RPa3 8nKQ48q7RvjaXY5u4NGLZF+JbjXxY6gUfCnILx0s8QC10jhONXpXe7PvQ6iC/eNVRxx1 laYa+XvnEXJwCLs1HTBvhUgmNrn/HzCGyrrY6ArolnoYKnHkE1goypG10ydU+6AatRiw GPjAzm5xKOkF74OoGcY2uTdXwXmBsLhHRDVvhHF1DDkO0f+Ydeh9hE2kYyxepx0S1a8M 4eIXHb2vYxdNG2w9wtgU21V/WrZ7Kq2nSN42HyDmN7Arb9S4rQjaS6IqA3AgEa61Jhmk Gr/Q== X-Gm-Message-State: AJaThX4KeolJujxXAenGEKnCnzX02WoDqUD9MNbrPP5R3WhK/PbP+5sz blqcWR5C53BDkzzN4ULT2J8= X-Google-Smtp-Source: AGs4zMbx1bDrW96qcVKdSDrKNOMtoQ8RC6WX1Fh7WiL8dh6LgY4XQF625N4R/6iwPhGT8DHMm3BT/A== X-Received: by 10.25.215.167 with SMTP id q39mr15520394lfi.33.1512909978127; Sun, 10 Dec 2017 04:46:18 -0800 (PST) Received: from [192.168.100.12] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id v17sm2287391ljv.38.2017.12.10.04.46.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Dec 2017 04:46:16 -0800 (PST) Date: Sun, 10 Dec 2017 13:46:14 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats To: Simen =?iso-8859-1?q?Heggest=F8yl?= Message-Id: <1512909974.15208.0@smtp.gmail.com> In-Reply-To: <87shcyce9x.fsf@gmail.com> References: <87lgiqmex1.fsf@gmail.com> X-Mailer: geary/0.12-dev MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-08ow+NF3IG0A/dGjfhVQ" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29456 Cc: eliz@gnu.org, 29456@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-08ow+NF3IG0A/dGjfhVQ Content-Type: multipart/alternative; boundary="=-l4uZOPXb7vUMy18cbZZI" --=-l4uZOPXb7vUMy18cbZZI Content-Type: text/plain; charset=us-ascii; format=flowed I've updated the patch to support switching between #RGBA/#RRGGBBAA and rgba() too, fixing a bug in `css--hex-color' along the way for handling the #RGBA case. If you agree, I think that fix should go into the emacs-26 branch as well. I also prefixed the function names with `css--' to more strongly indicate that they're intended for internal usage, and mentioned in the docstrings their incompatibility with color.el. -- Simen --=-l4uZOPXb7vUMy18cbZZI Content-Type: text/html; charset=us-ascii
I've updated the patch to support switching between #RGBA/#RRGGBBAA and
rgba() too, fixing a bug in `css--hex-color' along the way for handling
the #RGBA case. If you agree, I think that fix should go into the
emacs-26 branch as well.

I also prefixed the function names with `css--' to more strongly
indicate that they're intended for internal usage, and mentioned in the
docstrings their incompatibility with color.el.

-- Simen
--=-l4uZOPXb7vUMy18cbZZI-- --=-08ow+NF3IG0A/dGjfhVQ Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-command-for-cycling-between-CSS-color-formats.patch Content-Transfer-Encoding: quoted-printable >From 70d8834de32e31862dc0f14ce80f7e608e4151db Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Sun, 17 Sep 2017 20:08:18 +0200 Subject: [PATCH] Add command for cycling between CSS color formats * lisp/textmodes/css-mode.el (css-mode-map): Add keybinding for 'css-cycle-color-format'. (css--rgb-color): Add support for extracting alpha component. (css--hex-color): Correct function when the hex string is in the #RGBA format. (css--hex-alpha, css--color-to-4-dpc, css--named-color-to-hex) (css--format-rgba-alpha, css--hex-to-rgb) (css--rgb-to-named-color-or-hex): New functions. (css-cycle-color-format): New command for cycling between color formats. * test/lisp/textmodes/css-mode-tests.el (css-test-color-to-4-dpc): (css-test-named-color-to-hex, css-test-format-rgba-alpha) (css-test-hex-to-rgb, css-test-rgb-to-named-color-or-hex) (css-test-cycle-color-format, css-test-hex-color) (css-test-hex-alpha): New tests for the changes mentioned above. * etc/NEWS: Mention the new command. --- etc/NEWS | 7 ++ lisp/textmodes/css-mode.el | 133 ++++++++++++++++++++++++++++++= ++-- test/lisp/textmodes/css-mode-tests.el | 77 ++++++++++++++++++++ 3 files changed, 210 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index dd7d983970..33eaf257df 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -63,6 +63,13 @@ whether '"' is also replaced in 'electric-quote-mode'. = If non-nil, =0C * Changes in Specialized Modes and Packages in Emacs 27.1 =20 +** CSS mode + +--- +*** A new command 'css-cycle-color-format' for cycling between color +formats (e.g. "black" =3D> "#000000" =3D> "rgb(0, 0, 0)") has been added, +bound to 'C-c C-f'. + ** Dired =20 +++ diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 93ca36b08a..6bf365ecb3 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -32,12 +32,13 @@ =20 ;;; Code: =20 -(require 'eww) (require 'cl-lib) (require 'color) +(require 'eww) (require 'seq) (require 'sgml-mode) (require 'smie) +(require 'thingatpt) (eval-when-compile (require 'subr-x)) =20 (defgroup css nil @@ -806,6 +807,7 @@ css-mode-syntax-table (defvar css-mode-map (let ((map (make-sparse-keymap))) (define-key map [remap info-lookup-symbol] 'css-lookup-symbol) + (define-key map "\C-c\C-f" 'css-cycle-color-format) map) "Keymap used in `css-mode'.") =20 @@ -936,11 +938,13 @@ css--color-skip-blanks "Skip blanks and comments." (while (forward-comment 1))) =20 -(cl-defun css--rgb-color () +(cl-defun css--rgb-color (&optional include-alpha) "Parse a CSS rgb() or rgba() color. Point should be just after the open paren. Returns a hex RGB color, or nil if the color could not be recognized. -This recognizes CSS-color-4 extensions." +This recognizes CSS-color-4 extensions. +When INCLUDE-ALPHA is non-nil, the alpha component is included in +the returned hex string." (let ((result '()) (iter 0)) (while (< iter 4) @@ -952,8 +956,8 @@ css--color-skip-blanks (number (string-to-number str))) (when is-percent (setq number (* 255 (/ number 100.0)))) - ;; Don't push the alpha. - (when (< iter 3) + (if (and include-alpha (=3D iter 3)) + (push (round (* number 255)) result) (push (min (max 0 (truncate number)) 255) result)) (goto-char (match-end 0)) (css--color-skip-blanks) @@ -966,7 +970,11 @@ css--color-skip-blanks (css--color-skip-blanks))) (when (looking-at ")") (forward-char) - (apply #'format "#%02x%02x%02x" (nreverse result))))) + (apply #'format + (if (and include-alpha (=3D (length result) 4)) + "#%02x%02x%02x%02x" + "#%02x%02x%02x") + (nreverse result))))) =20 (cl-defun css--hsl-color () "Parse a CSS hsl() or hsla() color. @@ -1037,10 +1045,18 @@ css--hex-color STR is the incoming CSS hex color. This function simply drops any transparency." ;; Either #RGB or #RRGGBB, drop the "A" or "AA". - (if (> (length str) 4) + (if (> (length str) 5) (substring str 0 7) (substring str 0 4))) =20 +(defun css--hex-alpha (hex) + "Return the alpha component of CSS color HEX. +HEX can either be in the #RGBA or #RRGGBBAA format. If the color +doesn't have an alpha component, nil is returned." + (cl-case (length hex) + (5 (string (elt hex 4))) + (9 (substring hex 7 9)))) + (defun css--named-color (start-point str) "Check whether STR, seen at point, is CSS named color. Returns STR if it is a valid color. Special care is taken @@ -1383,6 +1399,109 @@ css-completion-at-point (progn (insert ": ;") (forward-char -1)))))))))) =20 +(defun css--color-to-4-dpc (hex) + "Convert the CSS color HEX to four digits per component. +CSS colors use one or two digits per component for RGB hex +values. Convert the given color to four digits per component. + +Note that this function handles CSS colors specifically, and +should not be mixed with those in color.el." + (let ((six-digits (=3D (length hex) 7))) + (apply + #'concat + `("#" + ,@(seq-mapcat + (apply-partially #'make-list (if six-digits 2 4)) + (seq-partition (seq-drop hex 1) (if six-digits 2 1))))))) + +(defun css--named-color-to-hex () + "Convert named CSS color at point to hex format. +Return non-nil if a conversion was made. + +Note that this function handles CSS colors specifically, and +should not be mixed with those in color.el." + (save-excursion + (unless (or (looking-at css--colors-regexp) + (eq (char-before) ?#)) + (backward-word)) + (when (member (word-at-point) (mapcar #'car css--color-map)) + (looking-at css--colors-regexp) + (let ((color (css--compute-color (point) (match-string 0)))) + (replace-match color)) + t))) + +(defun css--format-rgba-alpha (alpha) + "Return ALPHA component formatted for use in rgba()." + (if (or (=3D alpha 0) + (=3D alpha 1)) + (format "%d" alpha) + (string-remove-suffix "0" (format "%.2f" alpha)))) + +(defun css--hex-to-rgb () + "Convert CSS hex color at point to RGB format. +Return non-nil if a conversion was made. + +Note that this function handles CSS colors specifically, and +should not be mixed with those in color.el." + (save-excursion + (unless (or (eq (char-after) ?#) + (eq (char-before) ?\()) + (backward-sexp)) + (when-let* ((hex (when (looking-at css--colors-regexp) + (and (eq (elt (match-string 0) 0) ?#) + (match-string 0)))) + (rgb (css--hex-color hex))) + (seq-let (r g b) + (mapcar (lambda (x) (round (* x 255))) + (color-name-to-rgb (css--color-to-4-dpc rgb))) + (replace-match + (if-let* ((alpha (css--hex-alpha hex)) + (a (css--format-rgba-alpha + (/ (string-to-number alpha 16) + (float (expt 16 (length alpha))))))) + (format "rgba(%d, %d, %d, %s)" r g b a) + (format "rgb(%d, %d, %d)" r g b)))) + t))) + +(defun css--rgb-to-named-color-or-hex () + "Convert CSS RGB color at point to a named color or hex format. +Convert to a named color if the color at point has a name, else +convert to hex format. Return non-nil if a conversion was made. + +Note that this function handles CSS colors specifically, and +should not be mixed with those in color.el." + (save-excursion + (when-let* ((open-paren-pos (nth 1 (syntax-ppss)))) + (when (save-excursion + (goto-char open-paren-pos) + (looking-back "rgba?" (- (point) 4))) + (goto-char (nth 1 (syntax-ppss))))) + (when (eq (char-before) ?\)) + (backward-sexp)) + (skip-chars-backward "rgba") + (when (looking-at css--colors-regexp) + (let* ((start (match-end 0)) + (color (save-excursion + (goto-char start) + (css--rgb-color t)))) + (when color + (kill-sexp) + (kill-sexp) + (let ((named-color (seq-find (lambda (x) (equal (cdr x) color)) + css--color-map))) + (insert (if named-color (car named-color) color))) + t))))) + +(defun css-cycle-color-format () + "Cycle the color at point between different CSS color formats. +Supported formats are by name (if possible), hexadecimal, and +RGB." + (interactive) + (or (css--named-color-to-hex) + (css--hex-to-rgb) + (css--rgb-to-named-color-or-hex) + (message "It doesn't look like a color at point"))) + ;;;###autoload (define-derived-mode css-mode prog-mode "CSS" "Major mode to edit Cascading Style Sheets (CSS). diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/cs= s-mode-tests.el index 47cf5f9244..f3d4243721 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -244,6 +244,71 @@ css-mode-tests--completions (should (member "body" completions)) (should-not (member "article" completions))))) =20 +(ert-deftest css-test-color-to-4-dpc () + (should (equal (css--color-to-4-dpc "#ffffff") + (css--color-to-4-dpc "#fff"))) + (should (equal (css--color-to-4-dpc "#aabbcc") + (css--color-to-4-dpc "#abc"))) + (should (equal (css--color-to-4-dpc "#fab") + "#ffffaaaabbbb")) + (should (equal (css--color-to-4-dpc "#fafbfc") + "#fafafbfbfcfc"))) + +(ert-deftest css-test-named-color-to-hex () + (dolist (item '(("black" "#000000") + ("white" "#ffffff") + ("salmon" "#fa8072"))) + (with-temp-buffer + (css-mode) + (insert (nth 0 item)) + (css--named-color-to-hex) + (should (equal (buffer-string) (nth 1 item)))))) + +(ert-deftest css-test-format-rgba-alpha () + (should (equal (css--format-rgba-alpha 0) "0")) + (should (equal (css--format-rgba-alpha 0.0) "0")) + (should (equal (css--format-rgba-alpha 1) "1")) + (should (equal (css--format-rgba-alpha 1.0) "1")) + (should (equal (css--format-rgba-alpha 0.10000) "0.1")) + (should (equal (css--format-rgba-alpha 0.100001) "0.1")) + (should (equal (css--format-rgba-alpha 0.2524334) "0.25"))) + +(ert-deftest css-test-hex-to-rgb () + (dolist (item '(("#000" "rgb(0, 0, 0)") + ("#000000" "rgb(0, 0, 0)") + ("#fff" "rgb(255, 255, 255)") + ("#ffffff" "rgb(255, 255, 255)") + ("#ffffff80" "rgba(255, 255, 255, 0.5)") + ("#fff8" "rgba(255, 255, 255, 0.5)"))) + (with-temp-buffer + (css-mode) + (insert (nth 0 item)) + (css--hex-to-rgb) + (should (equal (buffer-string) (nth 1 item)))))) + +(ert-deftest css-test-rgb-to-named-color-or-hex () + (dolist (item '(("rgb(0, 0, 0)" "black") + ("rgb(255, 255, 255)" "white") + ("rgb(255, 255, 240)" "ivory") + ("rgb(18, 52, 86)" "#123456") + ("rgba(18, 52, 86, 0.5)" "#12345680"))) + (with-temp-buffer + (css-mode) + (insert (nth 0 item)) + (css--rgb-to-named-color-or-hex) + (should (equal (buffer-string) (nth 1 item)))))) + +(ert-deftest css-test-cycle-color-format () + (with-temp-buffer + (css-mode) + (insert "black") + (css-cycle-color-format) + (should (equal (buffer-string) "#000000")) + (css-cycle-color-format) + (should (equal (buffer-string) "rgb(0, 0, 0)")) + (css-cycle-color-format) + (should (equal (buffer-string) "black")))) + (ert-deftest css-mdn-symbol-guessing () (dolist (item '(("@med" "ia" "@media") ("@keyframes " "{" "@keyframes") @@ -295,6 +360,18 @@ css-mode-tests--completions (insert input ")")) (should (equal (css--hsl-color) "#ff0000"))))) =20 +(ert-deftest css-test-hex-color () + (should (equal (css--hex-color "#abc") "#abc")) + (should (equal (css--hex-color "#abcd") "#abc")) + (should (equal (css--hex-color "#aabbcc") "#aabbcc")) + (should (equal (css--hex-color "#aabbccdd") "#aabbcc"))) + +(ert-deftest css-test-hex-alpha () + (should (equal (css--hex-alpha "#abcd") "d")) + (should-not (css--hex-alpha "#abc")) + (should (equal (css--hex-alpha "#aabbccdd") "dd")) + (should-not (css--hex-alpha "#aabbcc"))) + (ert-deftest css-test-named-color () (dolist (text '("@mixin black" "@include black")) (with-temp-buffer --=20 2.15.1 = --=-08ow+NF3IG0A/dGjfhVQ-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 10 13:10:16 2017 Received: (at 29456) by debbugs.gnu.org; 10 Dec 2017 18:10:16 +0000 Received: from localhost ([127.0.0.1]:55582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eO63M-0002IV-LO for submit@debbugs.gnu.org; Sun, 10 Dec 2017 13:10:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eO63L-0002IH-C5 for 29456@debbugs.gnu.org; Sun, 10 Dec 2017 13:10:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eO63D-00072i-4K for 29456@debbugs.gnu.org; Sun, 10 Dec 2017 13:10:10 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eO62s-0006q0-D3; Sun, 10 Dec 2017 13:09:46 -0500 Received: from [176.228.60.248] (port=2360 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eO62r-00046w-Rn; Sun, 10 Dec 2017 13:09:46 -0500 Date: Sun, 10 Dec 2017 20:09:32 +0200 Message-Id: <83a7yqtpyb.fsf@gnu.org> From: Eli Zaretskii To: Simen =?iso-8859-1?Q?Heggest=F8yl?= In-reply-to: <1512909974.15208.0@smtp.gmail.com> (message from Simen =?iso-8859-1?Q?Heggest=F8yl?= on Sun, 10 Dec 2017 13:46:14 +0100) Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats References: <87lgiqmex1.fsf@gmail.com> <1512909974.15208.0@smtp.gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29456 Cc: 29456@debbugs.gnu.org, tom@tromey.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Sun, 10 Dec 2017 13:46:14 +0100 > From: Simen Heggestyl > Cc: eliz@gnu.org, 29456@debbugs.gnu.org, tom@tromey.com, > monnier@iro.umontreal.ca > > I've updated the patch to support switching between #RGBA/#RRGGBBAA and > rgba() too, fixing a bug in `css--hex-color' along the way for handling > the #RGBA case. If you agree, I think that fix should go into the > emacs-26 branch as well. It's OK to put the css--hex-color bugfix on emacs-26, but then please remove it from the changeset you push to master, so that it could be merged from emacs-26. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 17 04:32:11 2017 Received: (at 29456-done) by debbugs.gnu.org; 17 Dec 2017 09:32:11 +0000 Received: from localhost ([127.0.0.1]:38074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQVIp-0003Qy-DF for submit@debbugs.gnu.org; Sun, 17 Dec 2017 04:32:11 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:34125) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQVIo-0003Ql-8d for 29456-done@debbugs.gnu.org; Sun, 17 Dec 2017 04:32:10 -0500 Received: by mail-lf0-f47.google.com with SMTP id y78so9038911lfd.1 for <29456-done@debbugs.gnu.org>; Sun, 17 Dec 2017 01:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=mCiTt9sGH7Sfd4grM0AVIIenHIa8svU2EO4lIvHOtLQ=; b=kl2cOFdOyNrVhvbbAe2JPk5PfBuu60fUyay7GpFlVHntroainBLUiZMlytJvMYe3tU JzgmZVi6c6PmlGX69qAgr+Sc2X0jjxD8CIK7cAG+91UsoLSlWEwbandUXmH5/rPE9VFc J4FA1/dvYPpblnoqw0CGnqAK4FwWi/5+FI2ojwt850uhEDq2stUCmBIa9R/KvwXpRCpm XDl1O14MdZLKA+U5sdhiAPEaqmhi/yC9nV8Q8jYB6uavRyw6I7A7b/bIBEXqD3F3jpby 1X73T6o5pT/6Dz0Km5Gjw30t97IFxi2xcV2FyWkn4EIts4FFsbKZqp/W9eIgEyGmgoiI UEgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=mCiTt9sGH7Sfd4grM0AVIIenHIa8svU2EO4lIvHOtLQ=; b=MgfEK0duPWvcFcKmEVEGikDYlXzQW7/ZRYLGzqjoLXzgcrMhtBKleAL+hAeSzsqSF6 WwhTJWL7RgdwKpXd7ZT/WLVto/dTRcK3hvRee4GC/XS5kP2iIvc0do8ED+ca67YhqttE d/2TMkWMQIgOSO26K4BCeu9WvLtVpnk7T5xnqmpIyKuyDAxWOgWGLj8O7BMkUwrP192P iWFFSOvuzZWNRGLM/K7Bky/aGVfyd1atWWm3zTqvUb0eXZtig/RQl+ztmJ2dh8Jc9I/M yYLgPC2xz4qZL6JTJRACvYsXEMTIXIgJ8x6ZgyHO25x5yDGlQ+EqPkXPCAM9LIb41PKS 1EBQ== X-Gm-Message-State: AKGB3mIQNOjbn9oWMNkzvw5kpjgUe37e16GmDvlSaWu1tZK5pfbdgKH1 eZWyhdzxTUI26UnYCfp1/Dk= X-Google-Smtp-Source: ACJfBouBTpozwwEysAKUrLG7vITQhPRHF+Mvz0+ZP3pgOTqL+/DuQ/zLjKRpzom/p6PGKmEUY0kclg== X-Received: by 10.25.38.145 with SMTP id m139mr8465222lfm.122.1513503124434; Sun, 17 Dec 2017 01:32:04 -0800 (PST) Received: from [10.0.0.178] (97.89-11-246.nextgentel.com. [89.11.246.97]) by smtp.gmail.com with ESMTPSA id i18sm2022453ljb.45.2017.12.17.01.32.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Dec 2017 01:32:03 -0800 (PST) Date: Sun, 17 Dec 2017 10:32:01 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#29456: [PATCH] Add command for cycling between CSS color formats To: Eli Zaretskii Message-Id: <1513503121.2406.0@smtp.gmail.com> In-Reply-To: <83a7yqtpyb.fsf@gnu.org> References: <87lgiqmex1.fsf@gmail.com> X-Mailer: geary/0.12-dev MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-f8uvx2WImTbRfmW4hZI3" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29456-done Cc: tom@tromey.com, 29456-done@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-f8uvx2WImTbRfmW4hZI3 Content-Type: text/plain; charset=us-ascii; format=flowed Good, thanks. I've installed the two patches. -- Simen On Sun, Dec 10, 2017 at 7:09 PM, Eli Zaretskii wrote: > It's OK to put the css--hex-color bugfix on emacs-26, but then please > remove it from the changeset you push to master, so that it could be > merged from emacs-26. > > Thanks. --=-f8uvx2WImTbRfmW4hZI3 Content-Type: text/html; charset=us-ascii
Good, thanks. I've installed the two patches.

-- Simen

On Sun, Dec 10, 2017 at 7:09 PM, Eli Zaretskii <eliz@gnu.org> wrote:
It's OK to put the css--hex-color bugfix on emacs-26, but then please remove it from the changeset you push to master, so that it could be merged from emacs-26. Thanks.
--=-f8uvx2WImTbRfmW4hZI3-- From unknown Thu Aug 21 12:10:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 14 Jan 2018 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator