bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60692: 29.0.60; current-indentation wrong without outline ellipsis


From: Eli Zaretskii
Subject: bug#60692: 29.0.60; current-indentation wrong without outline ellipsis
Date: Tue, 10 Jan 2023 15:29:00 +0200

> From: Juri Linkov <juri@linkov.net>
> Cc: 60692@debbugs.gnu.org
> Date: Tue, 10 Jan 2023 10:20:20 +0200
> 
> forcemerge 56837 60692
> thanks
> 
> > About current-indentation: it skips invisible text, so it's unclear to
> > me why you expected to see 2.  The doc string says:
> >
> >   Text that has an invisible property is considered as having width 0, 
> > unless
> >   `buffer-invisibility-spec' specifies that it is replaced by an ellipsis.
> >
> > The "current indentation" on the line of buffer position 8 is entirely
> > in invisible text, and current-indentation only accounts for _visible_
> > whitespace, per the above documentation.
> 
> Thanks for the reference, it explains the problem.
> But this is a very strange logic.  I don't get it.
> Why it depends on the presence of the ellipsis
> and fails without it?
> 
> Now I see this bug report is a duplicate of bug#56837.

If you've read the discussion of bug#56837, then I explained there why
this is how it is.  In a nutshell, indentation is regarded as
display-related aspect, so asking about indentation of invisible text
makes no sense.

I added that note to the doc string because Ihor asked for that, not
in order to describe some algorithmic logic.

> This is a problem because modes use 'current-indentation'
> to get an outline level in 'outline-level' function, e.g.
> 
>   (setq-local outline-level
>               (lambda ()
>                 "`outline-level' function for Python mode."
>                 (1+ (/ (current-indentation) python-indent-offset))))
> 
>   (setq-local outline-level (lambda () (1+ (/ (current-indentation)
>                                          ruby-indent-level))))
> 
> But this fails when users want to remove an ellipsis.

I'm surprised the indentation is used for this purpose when it is
known that text will be sometimes hidden.  May I suggest to use text
properties for this purpose?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]