From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Variable-width font indentation Date: Mon, 5 Mar 2018 22:36:55 -0500 Message-ID: <428aac15-f216-61ea-3d28-7211e7fc8cfd@gmail.com> 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> <8b94336f-1bb4-84ab-263b-af5ba40bfca4@cs.ucla.edu> <673d6612-f0d4-5d34-c6ee-a276dbba3068@cs.ucla.edu> <087fdedd-a7c5-f7f6-f3a5-b1700fb6e516@gmail.com> <1ebcaf39-fc03-b178-d45b-e99bf3e94172@cs.ucla.edu> 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 1520307350 31035 195.159.176.226 (6 Mar 2018 03:35:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Mar 2018 03:35:50 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 To: Paul Eggert , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 06 04:35:46 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 1et3O6-0006Vz-IP for ged-emacs-devel@m.gmane.org; Tue, 06 Mar 2018 04:35:38 +0100 Original-Received: from localhost ([::1]:52714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et3Q7-0003Uq-GL for ged-emacs-devel@m.gmane.org; Mon, 05 Mar 2018 22:37:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et3PP-0003Uc-Gl for emacs-devel@gnu.org; Mon, 05 Mar 2018 22:37:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et3PO-0001hi-Hq for emacs-devel@gnu.org; Mon, 05 Mar 2018 22:36:59 -0500 Original-Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]:43922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1et3PO-0001hc-C8 for emacs-devel@gnu.org; Mon, 05 Mar 2018 22:36:58 -0500 Original-Received: by mail-qk0-x230.google.com with SMTP id j4so23316992qke.10 for ; Mon, 05 Mar 2018 19:36:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=W3fWl9UC4+8krYwzxk9R+GEFDyytq1DqjyGOFx74v7w=; b=G5Yt0gIvIfPdwPvi0o9NE2+CLV3/vgFfJZfqi5yucPtx4CaeXvlb/LAbL8z8k9uUDh uK+jVkXOMYGSmrGlhoMa8uDB42T+QOydPlnN267g75cJZMWPoSyTL3nIe6caFJx5p+l8 61ctQMRbEwLnvCy8M3gWVnbSQqUhzhzSf+Ri2sLVFtZaDyt7O3+EIGNtnfM2LPlMJ0gV LA08mYWsNQHL5Is3fV38dsYOLJu4F5xbsyo8d7DFFja2OALOgEqaaxIJjUtEvT1pG4bl AVFp07Bf5+cpDPm448sR+YMh+NtRg2k8ZoCFjpyQdEIH558hc56prGoQ3MOX0nEJmeon xDWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=W3fWl9UC4+8krYwzxk9R+GEFDyytq1DqjyGOFx74v7w=; b=XObxsDwFWuL5piwChCbr7KateHv0yvok6E5ecmkYRZAGeVXVuNk52iTSByKepla33L PmdmwnFt4EAgjyTkIrWoOpwQgbRiJZ26X3Fg+rzb3CtNF/H+Q8TguWQqInaD6EA9O3+B ofULGA8yWwqrYJTDo1aSLbFaLT3VpAwile5IQg1RzpwNc93yKvXqbgcaItaO5Bkr1fU2 tVq9p/7/8HhW4Tz4igVXHLY/LHlFEUgdfFNr9jI55VkGLG1j8iCFjL55QefAtb3u2R2/ cnX2xT1xm9XOhzEHz3saXTWbUY4FC8LTF7axZ1n+lo9C/iXk1uTujNfFi5DPY2mQX7s7 hsJA== X-Gm-Message-State: AElRT7FS0deCryzxFCnTcFRHP/MrJU8vSbTbktErEP3STLQHOXjb2zT3 4zZO1me7CuVA41R+xj/Gj4rC1ROQ X-Google-Smtp-Source: AG47ELsgT3fkIP1VUk4XOwMhAcY5FXaFpoK+/tJQNFPYLK101zlJ+8f1omCAEmWVU/vFEOj7JU7cMw== X-Received: by 10.55.215.21 with SMTP id m21mr26717084qki.123.1520307417558; Mon, 05 Mar 2018 19:36:57 -0800 (PST) Original-Received: from ?IPv6:2601:184:4180:66e7:2829:cb05:cef:e671? ([2601:184:4180:66e7:2829:cb05:cef:e671]) by smtp.gmail.com with ESMTPSA id a73sm9214957qkb.14.2018.03.05.19.36.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 19:36:57 -0800 (PST) In-Reply-To: <1ebcaf39-fc03-b178-d45b-e99bf3e94172@cs.ucla.edu> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::230 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:223318 Archived-At: 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.