all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: highlight-indent-guides in display engine
Date: Thu, 11 Jul 2019 21:06:51 +0200	[thread overview]
Message-ID: <20190711190651.b2kg64fg2ole2i5d@Ergus> (raw)
In-Reply-To: <83sgrh7uol.fsf@gnu.org>

On Sun, Jul 07, 2019 at 06:04:10PM +0300, Eli Zaretskii wrote:
>> Date: Sat, 6 Jul 2019 23:17:16 +0200
>> From: Ergus <spacibba@aol.com>
>>
>> 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.




  reply	other threads:[~2019-07-11 19:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-06 21:17 highlight-indent-guides in display engine Ergus
2019-07-07 15:04 ` Eli Zaretskii
2019-07-11 19:06   ` Ergus [this message]
2019-07-11 19:15     ` Eli Zaretskii
2019-07-12  0:21       ` Ergus
2019-07-12  6:57         ` Eli Zaretskii
2019-07-12  9:58           ` Ergus
2019-07-12 10:36             ` Ergus
2019-07-12 13:45             ` Eli Zaretskii
2019-07-12 18:51               ` Ergus
2019-07-12 19:35                 ` Drew Adams
2019-07-13  6:59                 ` Eli Zaretskii
2019-07-13  8:32                   ` Joost Kremers
2019-07-13  8:38                     ` Eli Zaretskii
2019-07-13 21:37                       ` Joost Kremers
2019-07-14  5:37                         ` Eli Zaretskii
2019-07-15  5:44                           ` Joost Kremers
2019-07-14 12:56                         ` Ergus
2019-07-15 12:58                           ` Stefan Monnier
2019-07-15 14:11                             ` Ergus
2019-07-15 14:49                               ` Stefan Monnier
2019-07-15 17:10                                 ` Ergus
2019-07-15 18:43                                   ` Stefan Monnier
2019-07-16  8:06                                     ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2019-07-07 17:50 Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190711190651.b2kg64fg2ole2i5d@Ergus \
    --to=spacibba@aol.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.