zprint icon indicating copy to clipboard operation
zprint copied to clipboard

FR or help: 2-up justify ONLY if max space is less than a configurable max?

Open riotrah opened this issue 2 years ago • 6 comments

Hi!

Thank you so much for creating this. It's beautiful.

I tried looking through the reference for the past couple weeks but couldn't figure out how to configure the following - if it isn't already possible, then consider this a feature request for when you have the time:

  1. Only justify a given form containing pairs if the max-gap is less than some configurable n

Thanks so much again

riotrah avatar May 26 '22 18:05 riotrah

Thanks for asking! No, there isn't any way to do this at present. It seems like a reasonable thing to do, and the numbers are sure to be available. I'll see about adding something like this.

Over the past year or so I've put a lot of work into making the justification something that might be more useful, and I'm glad to see that you are using it (or at least interested in using it). It is really quite finicky work, but the results tend to look very nice in many cases.

kkinnear avatar May 26 '22 19:05 kkinnear

As I had a minute, I started looking at implementing this. Have you looked at the {:pair {:justify {:max-variance n}}} configuration parameter? The :max-variance looks at the sizes of all of the elements on the "left" (other than the ones being ignored for variance), and calculates the variance. If the variance is greater than the max-variance, it won't justify. The :max-gap is getting at the same thing, but from a slightly different way. It looks only at the distance between the shortest and the longest things (that aren't being ignored for variance). It isn't bad thing, and it might be easier to adjust to your liking, but it definitely is trying to solve the same problem as the max-variance.

kkinnear avatar May 26 '22 20:05 kkinnear

It wasn't hard, so I just put it in. That has got to be a record for me from issue to commit. It should come out in 1.2.4, which will be a while, I expect, as it has some other big features in it.

kkinnear avatar May 26 '22 21:05 kkinnear

So, I did this, but it has been a while. It is in 1.2.4, just out now. Thanks for the idea!

From the CHANGELOG.md:

Another way to prevent justification of things that will look bad. In addition to {:pair {:justify {:max-variance 20}}} there is now the, perhaps easier to understand, {:pair {:justify {:max-gap n}}}, where n is maximum number spaces which will show up between the left and right columns of a bunch of pairs being justified. Note that the :max-gap is calculated after the:no-justify and :ignore-for-variance elements are removed. So if you want them included when calculating the :max-gap, you need to adjust these parameters as well.

kkinnear avatar Aug 02 '22 16:08 kkinnear

Awesome, thanks so so so much. Will test it out over the next couple weeks ❤️

riotrah avatar Aug 04 '22 05:08 riotrah

Ah, nevermind, the vscode version hasn't updated yet, but I hope it does soon!

riotrah avatar Aug 13 '22 19:08 riotrah