From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: highlight-indent-guides in display engine Date: Thu, 11 Jul 2019 21:06:51 +0200 Message-ID: <20190711190651.b2kg64fg2ole2i5d@Ergus> References: <20190706211716.semd47fksgh66rug@Ergus> <83sgrh7uol.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="150707"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: NeoMutt/20180716 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 11 21:07:14 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hlePQ-000d3A-Hw for ged-emacs-devel@m.gmane.org; Thu, 11 Jul 2019 21:07:12 +0200 Original-Received: from localhost ([::1]:44726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlePP-0002FB-FX for ged-emacs-devel@m.gmane.org; Thu, 11 Jul 2019 15:07:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36673) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlePL-0002Es-Ov for emacs-devel@gnu.org; Thu, 11 Jul 2019 15:07:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlePK-0002a5-9c for emacs-devel@gnu.org; Thu, 11 Jul 2019 15:07:07 -0400 Original-Received: from sonic302-21.consmr.mail.ir2.yahoo.com ([87.248.110.84]:44664) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlePI-0002TU-Ny for emacs-devel@gnu.org; Thu, 11 Jul 2019 15:07:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1562872022; bh=/ufa7+yJv6qx0CliytQD6nj5Io737jEuC8ZiZJy2VVA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=tdHEUGAmOh5KLdUwKESNlLWFMn3oPXD8t1rgSi32UxEl3bAvXip/iyeFs04GA1oXbQB1HJ3FAuWZQWOuFkF8eUL69sh/QBzLY9hGWtmaU7XH1h8it5XWt6e7i78wxFF5/+hy8CAr67yoH6zg7hMDAKFqNxurivC3wT+KnjnbDoTuCzRYmk+DOkY7Ap9//26chiQdk1UeBVqYss6aBYCQicjChGXyRi99qlFYmC7xvUKLdIBLLmmdFHdYcLwtF6dkCwaa7SZsV/TB0+BOMdZ6z4gxBeDWVC6niHqZdEEcLhE1cRKfGHUMFvYYgiITf7l15Jy8OApIC1RGKpinRVbO4w== X-YMail-OSG: pdqG..sVM1ku5eVNI9Zg5xyCtgT.5rc1AnInAhX6LeWtIXjeYAZjWdrQDsN8h5j 3sV6ba3hM4aQz4tzUz2hfqlfUDI1fxdphliAs3T.MTkQG5PFNNF.mg.abN0LCWqywrLy1t7AIn1V .aW7Ymgh8GS6RnXyyceLfP.B8hFTOuaNY5Bj6UEMGg34xTqXzxLOocfi8U8EXSZa85gh9ZT63GA. iXUfyUqkMr6xskfDBKfkjqQ..v6VfbH2seELp3dwc0OnpdsC0EtK_Z2LDuV5NSrIj5v9uvbLxy1U ZpsFJB_akjHgPyQFy5ZUTA3TXKFW3p2CBEfls3vQHC7P53Jw207Rz63idlsZlQU.ghMDzLDNs8Yf lFwNTbksUXRr6zt7UjR4FOIHoKQm9roNJXCUjCEsvnpb..eFDQ8azkgJq7snMhj7lNAV3v7rAlkN NmhvWeOkeosu9UneLa3kRytaQKpew845wI3BojEldjRWYeE5bO5wLYjbaHulsxyDtQOtNZW_P4z. 7HLHTVjvmQjE2vgWQt8mwYbOpv77GTYHntGgNX_Yg2teBDMJaKksq832TATf.nzyfLQlQD2Ifjgf PGpuw47wcRheaqPqKV9MZKGOfMAodeSN7aUOb3VgyGLdKgBcFjDYrb0X5gy8hpKjyH.eeDvPsnhF p936zXi6wHaE9v7d2PE_l4829nYZANDIHhCvY6ZjZ2Nz3cQZLtGLM.0y5v611A.PJn35UeLTKUiS Z54TI4BNu5.btaES1hGWIuBBTwXGAKaEIeDo2zhU2XXgLpJCGQl2Fn9QNRaf__Vxc7mPwf_85LcZ kXf92NDz2lQPcabjQopVX6VBiXJ563EMSKtWWKOXA1 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ir2.yahoo.com with HTTP; Thu, 11 Jul 2019 19:07:02 +0000 Original-Received: by smtp427.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID ebfc600a7cab8ed93e31805c392f280d; Thu, 11 Jul 2019 19:06:59 +0000 (UTC) Content-Disposition: inline In-Reply-To: <83sgrh7uol.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 87.248.110.84 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:238513 Archived-At: On Sun, Jul 07, 2019 at 06:04:10PM +0300, Eli Zaretskii wrote: >> Date: Sat, 6 Jul 2019 23:17:16 +0200 >> From: Ergus >> >> This email is a question about the highlight-indent-guides because some >> people find that functionality very useful (and it is very common in >> ides/editors around). >> >> I am using the package with that name [1] but It affects performance a >> lot. Specially scrolling and responsiveness in general. Even when >> disabling the animations. >> >> So my question is in two parts: >> >> 1) Does emacs already provides a way to reproduce this functionality >> that does not kill performance so much, even if we sacrifice some >> functionality? > >Not that I know of. But there are some alternatives mentioned in the >README of that package -- aren't some of them faster? > >> 2) Does it make sense to implement it in the display engine as we did >> with the fill-column-indicator? > Hi Eli: Sorry for the delay, but I've been very busy. >Hard to answer this question because the requirements aren't clear. >The description of highlight-indent-guides doesn't include any >systematic explanations of what the package does, only some quite >terse description of some options. Do you want to have all of what >that package does, or only part (and if the latter, which part)? > Actually I like simplicity, so I will only support the simplest possible approach that affects performance as least as possible. I don't care to sacrifice functionality. Actually if there is not an efficient way to do this it is better no implement it at all. (In my opinion) >In general, I see potential difficulties in making this entirely part >of the display code, because what is displayed in the indentation of >each line depends directly and indirectly on what happens in preceding >lines. This means, for example, that when the display engine is >invoked to lay out a single line, it might need to look backwards, >potentially very far backwards, to find indentation on previous lines, >If I'm not missing something, and this is indeed so, then such >searches will almost certainly slow down redisplay considerably. > >Maybe someone will have clever ideas for how to avoid this problem. > Actually I had something like: (defun my/whitespace-mode () "My whitespace mode." (setq whitespace-style '(face tabs tab-mark trailing) whitespace-display-mappings '((tab-mark 9 [?\u2502 9] [?\u2502 9]))) (custom-set-faces '(whitespace-tab ((t (:foreground "#444444"))))) (whitespace-mode 1)) As a prog-mode hook and with it's obvious limitations it used to be enough for me. It is actually the approach that most of the editors around implement more or less. The only extra consideration it needs are: 1) What to do when people indent with spaces instead of tabs. 2) And how to avoid the tabs to be highlighted when not in the indentation. (beginning of the line) But none of them seems to be unsolvable. >From the packages: I specially I don't want the dynamic part of the package that changes colors when moving the cursor. But this is a personal choice (and obviously there will appear people asking for it in a while) As a background I should mention that some time ago I was asking for the indent-with-tabs align-with-spaces functionality to work out of the box, specially because this code used to work perfectly fine for me with that (And because I strongly believe that indent-with-tabs align-with-spaces is much better than what provides indent-tabs-mode by default, because it already mixes tabs with spaces but in a way that always produces the wrong effect when changing the editor tab-width ...) >Alternatively, we could implement part of the feature in Lisp, and the >other part in C. For example, determining what indentation levels >should be displayed on a given line could be a job of the Lisp part. >But before we decide that this is a viable alternative, we should >profile the current Lisp implementation and find out which of its >parts are responsible for slowdown. Then we could decide whether this >or that reimplementation will make the feature significantly faster. > I totally agree, I don't thing it is possible to implement this efficiently enough purely in the lisp side with all the checks it does. Which in spite of useful and accurate seems to be a bit expensive and unneeded in most of the cases. So lets go for the simplest case: Check if indenting with spaces or tabs && add the indicator for those character (or every tab-width spaces) from the beginning of the line until the first different character of the line. And that's it... Maybe add an option to highlight tabs when using spaces to indent and vice-versa but that's a minor detail I don't really care too much. Usually the users don't need more.