GNU bug report logs -
#60692
29.0.60; current-indentation wrong without outline ellipsis
Previous Next
To reply to this bug, email your comments to 60692 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Mon, 09 Jan 2023 17:36:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 09 Jan 2023 17:36:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
When there is an outline ellipsis displayed at the end of outline headings,
then the correct indentation 2 is returned in this test case:
(progn
(switch-to-buffer (get-buffer-create "test1"))
(insert "* h\n .\n")
(outline-mode)
(outline-hide-sublevels 1)
(goto-char 8)
(current-indentation))
But when the ellipsis is disabled with invisibility-spec:
(progn
(switch-to-buffer (get-buffer-create "test2"))
(insert "* h\n .\n")
(outline-mode)
(remove-from-invisibility-spec '(outline . t))
(add-to-invisibility-spec 'outline)
(outline-hide-sublevels 1)
(goto-char 8)
(current-indentation))
then the returned indentation is 0 that is incorrect.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Mon, 09 Jan 2023 18:35:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 60692 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Date: Mon, 09 Jan 2023 19:34:07 +0200
>
> When there is an outline ellipsis displayed at the end of outline headings,
> then the correct indentation 2 is returned in this test case:
>
> (progn
> (switch-to-buffer (get-buffer-create "test1"))
> (insert "* h\n .\n")
> (outline-mode)
> (outline-hide-sublevels 1)
> (goto-char 8)
> (current-indentation))
How is 2 correct in this case? I'd expect 6. 2 is correct when point
is on 'h'.
> But when the ellipsis is disabled with invisibility-spec:
>
> (progn
> (switch-to-buffer (get-buffer-create "test2"))
> (insert "* h\n .\n")
> (outline-mode)
> (remove-from-invisibility-spec '(outline . t))
> (add-to-invisibility-spec 'outline)
> (outline-hide-sublevels 1)
> (goto-char 8)
> (current-indentation))
>
> then the returned indentation is 0 that is incorrect.
I think they are both incorrect, because the algorithm in
current-indentation doesn't expect that the current line is entirely
made of invisible text.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Mon, 09 Jan 2023 19:11:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 60692 <at> debbugs.gnu.org (full text, mbox):
> Cc: 60692 <at> debbugs.gnu.org
> Date: Mon, 09 Jan 2023 20:34:50 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
>
> > From: Juri Linkov <juri <at> linkov.net>
> > Date: Mon, 09 Jan 2023 19:34:07 +0200
> >
> > When there is an outline ellipsis displayed at the end of outline headings,
> > then the correct indentation 2 is returned in this test case:
> >
> > (progn
> > (switch-to-buffer (get-buffer-create "test1"))
> > (insert "* h\n .\n")
> > (outline-mode)
> > (outline-hide-sublevels 1)
> > (goto-char 8)
> > (current-indentation))
>
> How is 2 correct in this case? I'd expect 6. 2 is correct when point
> is on 'h'.
Sorry, I was confused. I thought we were talking about
current-column.
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Tue, 10 Jan 2023 08:26:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 60692 <at> debbugs.gnu.org (full text, mbox):
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.
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.
Forcibly Merged 56837 56838 60692.
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Tue, 10 Jan 2023 08:26:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Tue, 10 Jan 2023 13:29:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 60692 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 60692 <at> 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?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Tue, 10 Jan 2023 17:58:03 GMT)
Full text and
rfc822 format available.
Message #22 received at 60692 <at> debbugs.gnu.org (full text, mbox):
> 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.
But when an ellipsis is used, current-indentation
works correctly in invisible text.
>> (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?
I don't understand how text properties could be used to get
the indentation.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60692
; Package
emacs
.
(Tue, 10 Jan 2023 18:13:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 60692 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 60692 <at> debbugs.gnu.org
> Date: Tue, 10 Jan 2023 19:54:11 +0200
>
> > 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.
>
> But when an ellipsis is used, current-indentation
> works correctly in invisible text.
Because the ellipsis replaces the invisible text, and
current-indentation accounts for the ellipsis. When the ellipsis
isn't present, there's nothing to account for.
In any case, if you want to know the indentation disregarding
invisible property, current-indentation is not what you want.
>
> >> (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?
>
> I don't understand how text properties could be used to get
> the indentation.
Before you hide anything, analyze the indentation and assign to each
outline level the value of the property that equals the level. Then
you can know the level of any piece of text just by accessing the
property value.
This bug report was last modified 2 years and 158 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.