[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable-width font indentation

From: Eli Zaretskii
Subject: Re: Variable-width font indentation
Date: Tue, 06 Mar 2018 18:11:45 +0200

> From: Clément Pit-Claudel <address@hidden>
> Date: Mon, 5 Mar 2018 15:28:05 -0500
> Cc: Paul Eggert <address@hidden>
> On 2018-03-05 14:58, Eli Zaretskii wrote:
> > How does it know that today, when we only support well the
> > fixed-pitch fonts?  Or are you talking about a different problem?
> A different problem, IIUC.  The problem is the following:
> Assume you wrote the following C code, then changed to variable-pitch:
> void pr () {
>   printf ("hello, world\n");
> }
> int main (int argc, 
>           char** argv) {
>   pr ();
>   return 0;
> }
> Depending on which font you use (and the width of a space in that font), the 
> `char** argv' part will move right or left, instead of remaining aligned.  
> The usual solution is to proceed as Paul suggested:
> > It assumes the input is fixed-width, and that leading white space is
> > intended to indent with respect to previous lines.
> IOW, you scale the spaces preceding `char** argv' to make the `c' of `char' 
> line up with the `i' of int.

I think I'm still missing something, because I don't understand why we
need to invent/use a strategy different from what we do now in code
indentation.  All we need to do to extend the existing machinery to
variable-pitch fonts is (1) to replace current-column with a function
that returns floats instead of integers (or teach current-column do
that given some optional argument), and (b) place a 'space' display
property on the leading whitespace with an :align-to attribute
computed to align the first non-white character at the "column number"
returned as result of (a) above.  All the rest is already in place,

Also note that Richard was specifically talking about text modes, not
about programming modes.  Indentation in text modes has a slightly
different goal.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]