Stream: SerAPI

Topic: Modifying pp_margin in Alectyron?


view this post on Zulip Yann Régis Gianas (Jun 02 2021 at 21:47):

I am using Alectryon to render some coq source file but I would love the pretty-printer to use more characters in a single line before inserting a newline. Is it possible?

view this post on Zulip Yann Régis Gianas (Jun 02 2021 at 21:48):

Set Printing Width does not seem to have an impact on sertop output.

view this post on Zulip Emilio Jesús Gallego Arias (Jun 02 2021 at 22:40):

@Yann Régis Gianas indeed SerAPI printing protocol is stateless

view this post on Zulip Emilio Jesús Gallego Arias (Jun 02 2021 at 22:40):

each Print call takes the full set of format parameters, so likely you need to tweak Alectryon so it increases the Width

view this post on Zulip Emilio Jesús Gallego Arias (Jun 02 2021 at 22:42):

Indeed this https://github.com/cpitclaudel/alectryon/blob/df5664e71c1026af4aaf69e6b227d427a728e7c6/alectryon/core.py#L81 looks like very limited in terms of width

view this post on Zulip Emilio Jesús Gallego Arias (Jun 02 2021 at 22:42):

@Clément Pit-Claudel may know more

view this post on Zulip Clément Pit-Claudel (Jun 02 2021 at 22:57):

I can add a user-level setting if you want; otherwise you can use the following custom driver:

#!/usr/bin/env python3
from alectryon.cli import main
from alectryon.core import SerAPI

SerAPI.DEFAULT_PP_ARGS['pp_margin'] = 55

if __name__ == "__main__":
    main()

view this post on Zulip Clément Pit-Claudel (Jun 02 2021 at 22:58):

(This assumes that Alectryon is in your python path; if it's not, then you can add the following:)

import sys
from os.path import join, dirname

root = join(dirname(__file__), "alectryon") # Or wherever Alectryon is
sys.path.insert(0, root)

view this post on Zulip Yann Régis Gianas (Jun 03 2021 at 09:01):

It worked like a charm. Thank you very much!

view this post on Zulip Emilio Jesús Gallego Arias (Jun 03 2021 at 10:29):

Note that work on a new printer that is layout-friendly is getting ready, this will allow for direct reflow-friendly display


Last updated: May 31 2023 at 03:30 UTC