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 20:40:14 -0500 Message-ID: <087fdedd-a7c5-f7f6-f3a5-b1700fb6e516@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> 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 1520300303 5365 195.159.176.226 (6 Mar 2018 01:38:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Mar 2018 01:38:23 +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 02:38:19 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 1et1YW-0000Sb-H1 for ged-emacs-devel@m.gmane.org; Tue, 06 Mar 2018 02:38:16 +0100 Original-Received: from localhost ([::1]:52454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et1aZ-00016H-5q for ged-emacs-devel@m.gmane.org; Mon, 05 Mar 2018 20:40:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et1aT-00016A-6R for emacs-devel@gnu.org; Mon, 05 Mar 2018 20:40:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et1aS-0001n7-AM for emacs-devel@gnu.org; Mon, 05 Mar 2018 20:40:17 -0500 Original-Received: from mail-qt0-x234.google.com ([2607:f8b0:400d:c0d::234]:46295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1et1aS-0001mx-5e for emacs-devel@gnu.org; Mon, 05 Mar 2018 20:40:16 -0500 Original-Received: by mail-qt0-x234.google.com with SMTP id m13so22757749qtg.13 for ; Mon, 05 Mar 2018 17:40:16 -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=HNdn11srPNqIOhHYdU1oVSD+Lc5FsJy9q167l5wXSlM=; b=EgcGFUvOm3dqBYuv9fTR+BwTU0BYZel/AyxGFH0gfKona/y1YecFd6ulxmWxRtaCfx A+2FJLgCjTezIIryHR+wAc/imI2iR/95oKynkzPMrrosa+QHKRNIWNDeJBjaFuBvszfQ hq0ZWETJacu8qAzPhvgwd3at5x/iZB9wRKyNCmHfWeupkP1/6woFnMwxD1vHFqnvs2cZ rXyrOV09ITq4iLls5SkJ72E3n7tmc0e59hSEVh0sU6Np0BXL3l244PXzPYPnTBDH7PoM k1BJiwfaoKNS65z+Mh55JBPf7GzjWsIV/P/FADOeMjxkwbWtneypF2JA1P86at6c7Xfp O1aw== 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=HNdn11srPNqIOhHYdU1oVSD+Lc5FsJy9q167l5wXSlM=; b=arg9FHp8SaR8YVewfcBwjbAubBcLG4agIAnuurJ0BoqfgYrX1zJ13RDVv/JDyhdydz mHcZorFsFYiMb+ZvVWXAldFRVNgl2OxR0WBmTLgVU6fa8r2SoQwzONE8YCJacwG7TJ9w f7/3T96YRE0kMscmiDHF04Or/MYCwfxF9T/+yd+BjpMkrEJOkyo5cMl8ejcB77kqhMjL GAj/gf36ucgmBYgnB9GO+ynw345d1Q0Uh03WZVPSU7gxtWQKYzk4AbT1O3VbfGvsssDx psKRMNOkRr3uEi7AAfDfhsIDpzWdRMixSW9qluvgyFnVTsY71A+26EJZG4nEjgRwr8BO R6fA== X-Gm-Message-State: AElRT7H0xdnZUzPY5XHI/0rn4FNjInTkesSmPt9g3pFgm+q/zpMTWzIf UnrHBwFW9RGAmy58QxolxWHhcWxa X-Google-Smtp-Source: AG47ELunR0p2jw6K51PZBiRPgHzH2yHXBoYvzJo5O9hyuEWt8cGNt2CsNNId0v6tbOTNbu9ok7tMhQ== X-Received: by 10.200.30.9 with SMTP id n9mr26338273qtl.118.1520300415429; Mon, 05 Mar 2018 17:40:15 -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 h29sm9875148qtk.94.2018.03.05.17.40.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 17:40:14 -0800 (PST) In-Reply-To: <673d6612-f0d4-5d34-c6ee-a276dbba3068@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:c0d::234 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:223315 Archived-At: On 2018-03-05 20:30, Paul Eggert wrote: > On 03/05/2018 05:06 PM, Clément Pit-Claudel wrote: >> In variable-pitch mode, each new indentation level has a >> slightly-different width, instead of a regular progression of 4 >> spaces (in Python) and 2 spaces (in Elisp) at each level. > > That's fine. Although it's only a small thing, to me it's even a > small plus, as having every indent level be the same number of pixels > unnaturally focuses the reader on a distracting regularity that is > not intrinsic to the code. I've been playing with this a bit more; until now, I'd mostly stopped at my previous objection. The following code gives a preview of what the algorithm that we've been discussing produces: (defun ~/variable-pitch-indent () (interactive) (save-excursion (let ((spine "") (face `(:foreground ,(face-attribute 'default :background nil)))) (goto-char (point-min)) (while (not (eobp)) (back-to-indentation) (unless (eolp) (let* ((indentation-amount (current-column)) (spine-cut (min (length spine) indentation-amount)) (spine-prefix (substring spine 0 spine-cut)) (spine-padding (make-string (- indentation-amount spine-cut) ?\s)) (spine-end (buffer-substring (point) (point-at-eol)))) (setq spine (with-temp-buffer ;; HACK: expand spaces (setq-local tab-width 8) (insert spine-prefix spine-padding spine-end) (untabify (point-min) (point-max)) (buffer-string))) (put-text-property (point-at-bol) (point) 'display (propertize (concat spine-prefix spine-padding) 'face face)))) (forward-line 1))))) 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. Clément.