From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Newsgroups: gmane.emacs.help Subject: Working with colors in --batch mode Date: Sun, 25 Dec 2022 18:50:57 +0100 Message-ID: <87fsd3id8e.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36951"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 25 18:51:43 2022 Return-path: Envelope-to: geh-help-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 1p9V9x-0009U7-Sq for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 25 Dec 2022 18:51:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9V9G-0008Go-Fr; Sun, 25 Dec 2022 12:50:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9V9F-0008GQ-5y for help-gnu-emacs@gnu.org; Sun, 25 Dec 2022 12:50:57 -0500 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9V9D-0006WS-C0 for help-gnu-emacs@gnu.org; Sun, 25 Dec 2022 12:50:56 -0500 Original-Received: by mail-wm1-x329.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so6518939wms.2 for ; Sun, 25 Dec 2022 09:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=hMF7XntAV0t3z4jMHJbKmhf8MEDZn5pXMpnB7M5RrNY=; b=gdkLtsETb0yT8XYtLMkcwZEFKne0m4+v4MWe6S7/kc+z/yEoS+aAx2Rc69BqIKDBdu w2I0WptAI879zR7ut6ggKMrhVO9z5iAI9Dx/nid50IoMR+LrxXbolPrQeAMwwdGUVbCR 1mUb6AXk42MOkjKTTjwLPw0PoG1HtZ59SWcNwDmEpVSjMacRM1036S9+Pz80B0Lcc0RO CcUoedR4jKCdGegTQR5Jhg2kBBScNtnjXrnnPxo2JixZG464KOjBn+VRljvgr5YNf02F LoyGNO734sJ6NohT1ZYqiwb9hzs+Nxcuoy8DPVNXwgbgxaj9TbPrHI5/fen3B92c13E9 rCVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hMF7XntAV0t3z4jMHJbKmhf8MEDZn5pXMpnB7M5RrNY=; b=e/YldrYWEUWzCYm89fzKYuyLbWz1G7izPvPcmx84Lob1vLMgLP66AKtPfllTMFtS0P RaUHdnJ8LVvgSgC21/iZoBuSBf/aMBvtPd71eFkAuMf89u6YyNbGzmBNvGgEi94hDawt zcaGgkAVffxdqIy5IEkTv5y2DoK/0g+jGsPM4+hpQkS5gTkgMEGU31nccWlL35xPp471 WkSiazANa6HpZfIoksWhs2UIXJVS9JNliaFu+nkzwtIWPYRFbFBOwi/YNHOx4XiZWdgW 4c8HucaKookF8I4t8zCdui8yH0cXeyA9ZoGG+fVA77D4VIZ/tHmA58WRx+VuYNfds77d Tbzg== X-Gm-Message-State: AFqh2kqJeoJwupoNd7aSLPIJU6FNfmpzZUnfI/GieHyLMW7w16cOAaPp LzRWYK6hGpcMMkfloC30x71u1Z+Xt30= X-Google-Smtp-Source: AMrXdXtaN7EPCPh8f9a7kdjxWCM43TeWvca3liHbAfAlYfotzUyimwEKsKsUXogXSEi8IaUVnQtAhQ== X-Received: by 2002:a05:600c:22ca:b0:3d1:ebdf:d586 with SMTP id 10-20020a05600c22ca00b003d1ebdfd586mr11456702wmg.29.1671990653298; Sun, 25 Dec 2022 09:50:53 -0800 (PST) Original-Received: from hirondell ([2a01:cb14:ac6:6a00:21c2:cad0:cb7c:24c0]) by smtp.gmail.com with ESMTPSA id j30-20020a05600c1c1e00b003c71358a42dsm21138963wms.18.2022.12.25.09.50.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Dec 2022 09:50:52 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=kevin.legouguec@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141936 Archived-At: Hello Emacs, For some reason, today finds me playing with color contrast, and having a devil of a time doing so in --batch mode. Specifically, I'm stumped by=E2=80=A6 $ emacs --batch \ --eval '(message "color-name-to-rgb: %s" (color-name-to-rgb "#abcdef"))' =E2=80=A6 returning=E2=80=A6 > color-name-to-rgb: (0.0 1.0 1.0) =E2=80=A6 whereas in a non-batch session on an X display, I get something m= ore relevant to my usual Emacs experience (i.e. (window-system) =E2=86=A6 x): > color-name-to-rgb: (0.6705882352941176 0.803921568627451 0.93725490196078= 43) The --batch behaviour thwarts my attempts to write a script that calls modus-themes-contrast, since that function relies on color-name-to-rgb. I think I've traced this to (color-values COLOR &optional FRAME) taking a "wrong turn" because emacs --batch does not bother setting up graphical frames; I tried coaxing Emacs into doing that prior to calling any color function, with various combinations of=E2=80=A6 * --display :0 * --eval "(make-frame '((display . \":0\") (window-system . x)))" * --eval '(make-frame-on-display ":0")' =E2=80=A6 to no avail; Emacs merely tells me "I/O possible" then terminates= with code 157 (-128=3D29, which tracks with signal(7) mapping this to SIGIO). It might just be me not finding the right terms, but none of my research (Emacs & Elisp info manuals; some googling) led me to examples of handling graphical frames in batch mode. I'm guessing it's just a matter of finding x such that=E2=80=A6 $ emacs --batch \ --eval "$x" \ --eval '(message "color-name-to-rgb: %s" (color-name-to-rgb "#abcdef"))' =E2=80=A6 sets up enough "graphical terminal" support that display-graphic-p holds, and (color-values "#abcdef") returns (43947 52685 61423) instead of (0 65535 65535), but x eludes me thus far. Alternatively, I could drop --batch and switch to princ + external-debugging-output + kill-emacs, I guess. There's still a bunch of things for me to consult before I feel completely stuck ((elisp) Window Systems, (elisp) Frames, (emacs) Display X, src/emacs.c, lisp/startup.el, ChatGPT); in the meantime, bottling up this message and throwing it at the list in case someone happens to be=E2=80=A6 sailing by? Wishing y'all a merry time =F0=9F=99=8F