[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] Convention for multi-line pretty-printed output
From: |
Jose E. Marchesi |
Subject: |
Re: [RFC] Convention for multi-line pretty-printed output |
Date: |
Sun, 03 May 2020 10:28:08 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Hi people!
>
> So I am suggesting to extend the convention: in case you want the
> pretty-printed representation to span for more than one line, you should
> place first the `#<' starting at the column 0, then the lines with the
> data, and finally `>' in its own line starting at column 0.
>
> I used this convention for id3v1 tags, and this is the result:
>
> (poke) .file eclipse.mp3
> The current IOS is now `./eclipse.mp3'.
> (poke) load id3v1
> (poke) ID3V1_Tag @ (iosize (get_ios) - 128#B)
> #<
> genre: 255
> title: 01 - Eclipse De Mar
> artist: Joaqun Sabina
> album: Mentiras Piadosas
> year:
> comment:
> track: 1
> >
> (poke)
>
> Comments?
Sounds good to me!
Thanks for your feeback! :)
Is there any particular reason for using #< > and not #< #>?
I guess it is my Lisp bias :)
In lisp systems it is common to use #<foo> as the printed representation
of non-printable objects.
Speaking of pretty printers: how would I add one? I've glanced over the
poke manual, but couldn't find anything obvious.
All you have to do is to add a method called _print to your struct type,
that should get no arguments and should return no value. When the user
has pretty-print set to `yes' (I have that setting in my .pokerc file)
then _print will be called to obtain the textual representation of
values of that struct.
Example:
deftype BPF_Reg =
struct
{
uint<4> code;
defun _print = void:
{
print "#<";
if (code < BPF_R9)
printf "%<insn-register:%sr%i32d%>", "%", code;
else
printf "%<insn-register:fp%>";
print ">";
}
};
Note how this pretty printer uses the #<> convention, and also uses
styling classes.