[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What happens with text properties in batch mode?
From: |
Marcin Borkowski |
Subject: |
Re: What happens with text properties in batch mode? |
Date: |
Sat, 08 Dec 2018 21:08:53 +0100 |
User-agent: |
mu4e 1.1.0; emacs 27.0.50 |
On 2018-12-08, at 19:31, andlind@gmail.com <andlind@gmail.com> wrote:
> 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
> highlighted text stdout and expecting it to be shown with colors doesn't work.
I was just curious what happens to the properties after princ.
>> 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 millions
> colors, or in a black-and-white tty". (This part is placed in a stand alone
> 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 available
> to elisp, so I had to implement everything from scratch.
>
> Fortunately, you can use e2ansi as a library in your own packages. For
> example `e2ansi-string-to-ansi' converts a string with face information to
> ANSI. See `face-explorer-number-of-colors' and friends to control which
> features of ANSI will be used. (They have sane defaults, though.)
Thanks a lot for the details (and for e2ansi)! I'll try to look into it some
day.
Best,
--
Marcin Borkowski
http://mbork.pl