From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "andlind@gmail.com" Newsgroups: gmane.emacs.help Subject: Re: What happens with text properties in batch mode? Date: Sat, 8 Dec 2018 10:31:36 -0800 (PST) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1544294010 8686 195.159.176.226 (8 Dec 2018 18:33:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Dec 2018 18:33:30 +0000 (UTC) Injection-Date: Sat, 08 Dec 2018 18:31:37 +0000 User-Agent: G2/1.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 08 19:33:26 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gVhPp-00028i-0a for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Dec 2018 19:33:25 +0100 Original-Received: from localhost ([::1]:51764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVhRv-0006pW-Eg for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Dec 2018 13:35:35 -0500 X-Received: by 2002:aed:3e88:: with SMTP id n8mr5045392qtf.42.1544293897196; Sat, 08 Dec 2018 10:31:37 -0800 (PST) X-Received: by 2002:ac8:5356:: with SMTP id d22mr91600qto.3.1544293897022; Sat, 08 Dec 2018 10:31:37 -0800 (PST) Original-Path: usenet.stanford.edu!v55no3867008qtk.0!news-out.google.com!h3ni2114qtk.1!nntp.google.com!v55no3867006qtk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=90.227.126.54; posting-account=k77ESQoAAABOHZ-xdSiC_Gs4kD0z8QFO Original-NNTP-Posting-Host: 90.227.126.54 Original-Xref: usenet.stanford.edu gnu.emacs.help:224790 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118919 Archived-At: On Friday, 7 December 2018 08:58:38 UTC+1, Marcin Borkowski wrote: > it seems that when I `princ' something with text properties (e.g., > colored faces) in batch mode, the colors disappear. Is it documented > anywhere? Can I disable this behavior? Can you tell me what you are trying to accomplish? Simply printing a highli= ghted text stdout and expecting it to be shown with colors doesn't work. > I found this: https://github.com/Lindydancer/e2ansi, and its existence > suggests that outputting colored stuff (using ANSI codes) is > non-trivial. Am I right? It is non-trivial, I can assure you, I spent many months writing it. One problem is that even though strings have face properties in batch mode,= the faces themselves often fail to specify anything useful in batch mode. = e2ansi contains a system for playing the "what if" game by allowing you to = query things like "what would face X look like when in a gui with 16 millio= ns colors, or in a black-and-white tty". (This part is placed in a stand al= one library "face-explorer", along with tons of useful tools.) The second problem is to translate the face information to ANSI. Note that = Emacs internal system for rendering things in terminal mode is not availabl= e to elisp, so I had to implement everything from scratch. Fortunately, you can use e2ansi as a library in your own packages. For exam= ple `e2ansi-string-to-ansi' converts a string with face information to ANSI= . See `face-explorer-number-of-colors' and friends to control which feature= s of ANSI will be used. (They have sane defaults, though.) -- Anders Lindgren