emacs-devel
[Top][All Lists]
Advanced

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

Re: Variable-width font indentation


From: Clément Pit-Claudel
Subject: Re: Variable-width font indentation
Date: Mon, 5 Mar 2018 22:36:55 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2018-03-05 21:04, Paul Eggert wrote:
> On 03/05/2018 05:40 PM, Clément Pit-Claudel wrote:
>> I've tested it on two files: src/termcap.c and lisp/dabbrev.el.  To try it 
>> out, open one of these files in emacs -Q, then run M-x 
>> ~/variable-pitch-indent, and then M-x variable-pitch-mode.
>>
>> I do agree that it doesn't look too bad, and presumably a C implementation 
>> of the algorithm above would be very fast, since it could build the "spine" 
>> above during redisplay.
> 
> Thanks, that was fast! Yes, it should work fast.
> 
> I saw one easily-fixable minor glitch (on my screen lisp/dabbr.el line 533 
> had the wrong indent, presumably since the "user-error" on the previous line 
> was in a fatter-than usual font).

Yes, that's due to the implementation trick that I used, which doesn't preserve 
faces on the "spine", the string used for indentation.

The biggest trickier minor glitch was that indenting of #if and #else subparts 
were annoyingly different because the "#" violates the usual indentation rule. 
Personally I've always thought that we should indent "#" like anything else -- 
the only reason we don't is that it didn't work with K&R C and so we got used 
to bad style -- but even if we stick with the bad "#if" indenting it still 
looks pretty reasonable.

Indeed.  It does look fairly OK, actually — much better than I expected it to 
be.

I guess the next step would be to make a minor mode to apply this 
variable-pitch indentation on the fly and see how well it works in real life.

Some difficulties:

* Changing a line will cause all lines below it to get reindented; this will 
make redisplay costly, and I'm not sure how good it'll look — and we won't be 
able to tell until we get a C implementation, since an ELisp implementation 
likely won't update indentation for following lines on the fly.
* I'm not aware of a way to get a specified space whose width equals that of a 
particular string, without measuring the string beforehand.  Is there a way?

Clément.




reply via email to

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