ChristopherHGreen · 2022-09-22 19:53
Now that I have tamed end of line comments to line up with proportional fonts (using the display attribute :halign-to, which lets you make text display at a particular physical column), I'm wondering if I might be able to do the same for c++ lines which are indented because of being continuations of a statement for a previous line.
This isn't such a big deal as the comment thing was, as it only affects continued lines, and looks OK anyway the way it is. But it would be nice - normally emacs will line things like an argument on a continuation line with the enclosing parenthesis from the function call, but with a proportional font it only ends up approximating that.
​
It seems like what I would have to do, is in the code that calculates what character from the line above to line this line up with, calculate the physical position of that character and add the spaces, but also visually indent the next line using :halign-to.
amareshjoshi · 2022-09-22 21:04
just curious, but, why do you want to use proportional (not fixed width) fonts to display source code?
ChristopherHGreen · 2022-09-22 21:13
I'm been doing it for a decade or so..cant' even stand to look at fixed width source code these days - it looks like its laid out on graph paper.
​
attractiveness, fitting more text while gaining readability (I use fairly large fonts) ...
Also, I make heavy use of multiple fonts, different font-sizes for things, unicode math symbols, displaying de-emphasized keywords in a smaller font, and more (I posted a screenshot of my setup in another post), which means blowing away the concept of every character being the same width.
Also our coding standard is spaces around most operators, which I like, but I don't like it to be a \_whole\_ space so I use unicode half-spaces for that.
eli-zaretskii · 2022-09-23 11:03
It shouldn't be hard. You should be able to use the same ideas we have in filling and justification code we already have, just do the calculations in pixels instead of in columns, and put `:align-to` display properties on spaces instead of adding/removing literal space characters.
See also `pixel-fill.el`.
Patches are welcome. This is a long-standing item in our TODO.
ChristopherHGreen · 2022-09-23 14:48
Thanks, are you taking about how to do it in emacs itself or in an elisp extension?
I'd still want to add/remove the white space characters so that the code would line up well for people not using emacs
eli-zaretskii · 2022-09-24 08:35
> are you taking about how to do it in emacs itself or in an elisp extension?
In Lisp.
> I'd still want to add/remove the white space characters
That's not a contradiction: the `:align-to` properties should be put on whitespace characters.