From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Variable-width font indentation Date: Tue, 06 Mar 2018 18:11:45 +0200 Message-ID: <838tb5rxoe.fsf@gnu.org> References: <87inaiss6l.fsf@web.de> <6FCF6ACA-4F29-4B6B-BE9D-D7130C6E9495@gnu.org> <87fu5moe4c.fsf@web.de> <877eqyocro.fsf@web.de> <83zi3uz4nb.fsf@gnu.org> <0b1dd3fa-e0b0-ed20-a256-dd92d1c1826f@dancol.org> <8bc3c4c7-dfc7-987a-95e7-bd309e2326c6@cs.ucla.edu> <03118DC0-39DA-4AB5-980E-A33809B9A5EE@raeburn.org> <83vaeas8uz.fsf@gnu.org> <83lgf6s3aa.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1520352622 5697 195.159.176.226 (6 Mar 2018 16:10:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Mar 2018 16:10:22 +0000 (UTC) Cc: eggert@cs.ucla.edu, emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 06 17:10:18 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1etFA8-0007LR-Jj for ged-emacs-devel@m.gmane.org; Tue, 06 Mar 2018 17:10:00 +0100 Original-Received: from localhost ([::1]:56669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etFCB-0006G7-Dk for ged-emacs-devel@m.gmane.org; Tue, 06 Mar 2018 11:12:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etFC4-0006FS-Ke for emacs-devel@gnu.org; Tue, 06 Mar 2018 11:12:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etFC3-0005sF-NX for emacs-devel@gnu.org; Tue, 06 Mar 2018 11:12:00 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etFC0-0005pW-1Q; Tue, 06 Mar 2018 11:11:56 -0500 Original-Received: from [176.228.60.248] (port=1843 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1etFBz-00061W-Ea; Tue, 06 Mar 2018 11:11:55 -0500 In-reply-to: (message from =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel on Mon, 5 Mar 2018 15:28:05 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223337 Archived-At: > From: Clément Pit-Claudel > Date: Mon, 5 Mar 2018 15:28:05 -0500 > Cc: Paul Eggert > > 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, right? Also note that Richard was specifically talking about text modes, not about programming modes. Indentation in text modes has a slightly different goal.