GNU bug report logs -
#23079
25.0.92; Movement commands leave cursor in invisible line
Previous Next
Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>
Date: Mon, 21 Mar 2016 20:20:01 UTC
Severity: normal
Tags: notabug
Found in version 25.0.92
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23079 in the body.
You can then email your comments to 23079 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Mon, 21 Mar 2016 20:20:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Michael Heerdegen <michael_heerdegen <at> web.de>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 21 Mar 2016 20:20:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
I try to give a recipe resembling a bug in Magit concerning hidden lines
and cursor movement. In some buffer (emacs -Q) do
(insert "111" "\n222\n"
(propertize "333\n444\n\n" 'invisible t)
"555\n666\n")
and move around with C-n, C-p. Then the cursor will appear over the
first "5" but point is actually located inside the invisible area. This
is the cause of our trouble.
(setq line-move-visual t) helps, but setting (setq goal-column 0) makes
it appear again.
For reference, this is the original report in Magit (including
screenshots):
https://github.com/magit/magit/issues/2592
Thanks,
Michael.
In GNU Emacs 25.0.92.11 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
of 2016-03-21 built on drachen
Repository revision: 76ef52267cf887e3e1aa6d25b3b16dd0601dd459
Windowing system distributor 'The X.Org Foundation', version 11.0.11802000
System Description: Debian GNU/Linux testing (stretch)
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Mon, 21 Mar 2016 20:27:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Hi,
I forgot to CC Jonas who cares about the bug in Magit.
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Hello,
>
> I try to give a recipe resembling a bug in Magit concerning hidden lines
> and cursor movement. In some buffer (emacs -Q) do
>
>
> (insert "111" "\n222\n"
> (propertize "333\n444\n\n" 'invisible t)
> "555\n666\n")
>
> and move around with C-n, C-p. Then the cursor will appear over the
> first "5" but point is actually located inside the invisible area. This
> is the cause of our trouble.
>
> (setq line-move-visual t) helps, but setting (setq goal-column 0) makes
> it appear again.
>
> For reference, this is the original report in Magit (including
> screenshots):
>
> https://github.com/magit/magit/issues/2592
>
>
> Thanks,
>
> Michael.
>
>
>
> In GNU Emacs 25.0.92.11 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
> of 2016-03-21 built on drachen
> Repository revision: 76ef52267cf887e3e1aa6d25b3b16dd0601dd459
> Windowing system distributor 'The X.Org Foundation', version 11.0.11802000
> System Description: Debian GNU/Linux testing (stretch)
>
> Configured features:
> XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY
> LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Mon, 21 Mar 2016 21:12:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 23079 <at> debbugs.gnu.org (full text, mbox):
tags 23079 notabug
thanks
> I try to give a recipe resembling a bug in Magit concerning hidden lines
> and cursor movement. In some buffer (emacs -Q) do
> (insert "111" "\n222\n"
> (propertize "333\n444\n\n" 'invisible t)
> "555\n666\n")
> and move around with C-n, C-p. Then the cursor will appear over the
> first "5" but point is actually located inside the invisible area.
That's normal: (get-pos-property <pos> 'invisible) returns nil in front
of "333" but t in front of "555", so point adjustment will try to move
point to right before "333" when we're in that invisible chunk.
IOW the position "right before 555" is actually considered as being
"inside the invisible area" whereas the position "right before 333" is
considered as being outside of it.
If you want point adjustment to move point to right before "555"
instead, you should change the stickiness of the `invisible' property so
as to change which boundary position is considered "inside" and which is
considered "outside".
Stefan
Added tag(s) notabug.
Request was from
Stefan Monnier <monnier <at> IRO.UMontreal.CA>
to
control <at> debbugs.gnu.org
.
(Mon, 21 Mar 2016 21:12:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Mon, 21 Mar 2016 22:31:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> That's normal: (get-pos-property <pos> 'invisible) returns nil in front
> of "333" but t in front of "555", so point adjustment will try to move
> point to right before "333" when we're in that invisible chunk.
Hmm, that perfectly makes sense.
> IOW the position "right before 555" is actually considered as being
> "inside the invisible area" whereas the position "right before 333" is
> considered as being outside of it.
>
> If you want point adjustment to move point to right before "555"
> instead, you should change the stickiness of the `invisible' property so
> as to change which boundary position is considered "inside" and which is
> considered "outside".
Seems that works only for the invisible text property. In Magit, they
use overlays to make text invisible, and stickiness of text properties
has not effect there.
This is what I tried:
(add-text-properties (point-min) (point-max)
'(front-sticky t rear-nonsticky t))
That helps for the recipe I gave here, but unfortunately not in Magit.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Mon, 21 Mar 2016 22:55:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> That's normal: (get-pos-property <pos> 'invisible) returns nil in front
> of "333" but t in front of "555", so point adjustment will try to move
> point to right before "333" when we're in that invisible chunk.
BTW, we also discussed whether we could hide the newline "before the
first invisible lines", and don't hide the newline following the last
line to make invisible instead. But we apparently can't do this because
(from "https://github.com/magit/magit/issues/2592"):
"e.g. the background color of headings of collapsed sections would not
be in affect all the way to the right edge of the window anymore"
and other drawbacks.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Tue, 22 Mar 2016 01:28:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 23079 <at> debbugs.gnu.org (full text, mbox):
> Seems that works only for the invisible text property. In Magit, they
> use overlays to make text invisible, and stickiness of text properties
> has not effect there.
For overlays, you need to use the insertion-type of the beg/end marker.
See the FRONT-ADVANCE and REAR-ADVANCE args of make-overlay.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Tue, 22 Mar 2016 16:03:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> > Seems that works only for the invisible text property. In Magit,
> > they use overlays to make text invisible, and stickiness of text
> > properties has not effect there.
>
> For overlays, you need to use the insertion-type of the beg/end marker.
> See the FRONT-ADVANCE and REAR-ADVANCE args of make-overlay.
Hmm, that doesn't seem to work:
(progn
(insert "111" "\n222\n")
(let ((beg (point)) end)
(insert "333\n444\n")
(setq end (point))
(insert "555\n666\n")
(overlay-put
(make-overlay beg end nil t t)
'invisible t)
(goto-char 1)
(hl-line-mode +1)))
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Tue, 22 Mar 2016 16:17:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 23079 <at> debbugs.gnu.org (full text, mbox):
>> > Seems that works only for the invisible text property. In Magit,
>> > they use overlays to make text invisible, and stickiness of text
>> > properties has not effect there.
>> For overlays, you need to use the insertion-type of the beg/end marker.
>> See the FRONT-ADVANCE and REAR-ADVANCE args of make-overlay.
> Hmm, that doesn't seem to work:
> (progn
> (insert "111" "\n222\n")
> (let ((beg (point)) end)
> (insert "333\n444\n")
> (setq end (point))
> (insert "555\n666\n")
> (overlay-put
> (make-overlay beg end nil t t)
> 'invisible t)
> (goto-char 1)
> (hl-line-mode +1)))
The default "stickiness" of overlay boundaries is the inverse of that if
text-properties, for some reason. So, this test above suffers from the
bug#19200, but other than that, it seems to work correctly for me
(i.e. it prefers putting point in front of "333" rather than in front
of "555").
And if I remove the "nil t t" args to make-overlay, then
point-adjustment correctly tries to put point in front of "555" instead
of putting it in front of "333".
At least, in my tests,
Stefan
PS: Notice that the hl-line-highlighting is sometimes off, because it's
performed in post-command-hook, which is run *before* point-adjustment.
hl-line-mode should probably be changed to use pre-redisplay-function to
try and avoid this problem.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Tue, 22 Mar 2016 16:49:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> The default "stickiness" of overlay boundaries is the inverse of that if
> text-properties, for some reason. So, this test above suffers from the
> bug#19200, but other than that, it seems to work correctly for me
> (i.e. it prefers putting point in front of "333" rather than in front
> of "555").
>
> And if I remove the "nil t t" args to make-overlay, then
> point-adjustment correctly tries to put point in front of "555" instead
> of putting it in front of "333".
Ok, we are coming closer...
They use the default stickiness for their overlays. Nonetheless, the
behavior is the same as with "nil t t".
_But_ their local binding of post-command-hook looks like (t
magit-section-update-highlight).
When I set it to (t) only, the issue is fixed (but the highlighting
update doesn't work anymore, of course)!
magit-section-update-highlight is
#+begin_src emacs-lisp
(defun magit-section-update-highlight ()
(let ((section (magit-current-section)))
(unless (eq section magit-section-highlighted-section)
(let ((inhibit-read-only t)
(deactivate-mark nil)
(selection (magit-region-sections)))
(mapc #'delete-overlay magit-section-highlight-overlays)
(setq magit-section-unhighlight-sections
magit-section-highlighted-sections
magit-section-highlighted-sections nil)
(unless (eq section magit-root-section)
(run-hook-with-args-until-success
'magit-section-highlight-hook section selection))
(--each magit-section-unhighlight-sections
(run-hook-with-args-until-success
'magit-section-unhighlight-hook it selection))
(restore-buffer-modified-p nil)
(unless (eq magit-section-highlighted-section section)
(setq magit-section-highlighted-section
(unless (magit-section-hidden section) section))))
(setq deactivate-mark nil))))
#+end_src
This function doesn't move point, but it somehow interferes with point
adjustment in another way.
Michael
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Wed, 23 Mar 2016 02:00:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 23079 <at> debbugs.gnu.org (full text, mbox):
> (let ((inhibit-read-only t)
> (deactivate-mark nil)
> (selection (magit-region-sections)))
> (mapc #'delete-overlay magit-section-highlight-overlays)
> (setq magit-section-unhighlight-sections
> magit-section-highlighted-sections
> magit-section-highlighted-sections nil)
> (unless (eq section magit-root-section)
> (run-hook-with-args-until-success
> 'magit-section-highlight-hook section selection))
> (--each magit-section-unhighlight-sections
> (run-hook-with-args-until-success
> 'magit-section-unhighlight-hook it selection))
> (restore-buffer-modified-p nil)
Hmm... what kind of buffer modifications might happen in here?
I think this might be the problem: point-adjustment is only applied after
"movement commands" and is disabled if the buffer was modified during
the course of the command (including post-command-hook).
[ This is mostly due to the simplistic way we keep track of the
"previous state", which we can't trust if the buffer was modified. ]
> This function doesn't move point, but it somehow interferes with point
> adjustment in another way.
It's difficult to adjust point without risking adverse effects in corner
cases (typically problems like "repeated C-n gets stuck" or "forward-foo
moves backward"), so point-adjustment is conservative to try and make
sure it's only done when we're sure it's "safe".
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Wed, 23 Mar 2016 03:42:01 GMT)
Full text and
rfc822 format available.
Message #37 received at 23079 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Tue, 22 Mar 2016 21:59:38 -0400
> Cc: 23079 <at> debbugs.gnu.org, jonas <at> bernoul.li
>
> > (let ((inhibit-read-only t)
> > (deactivate-mark nil)
> > (selection (magit-region-sections)))
> > (mapc #'delete-overlay magit-section-highlight-overlays)
> > (setq magit-section-unhighlight-sections
> > magit-section-highlighted-sections
> > magit-section-highlighted-sections nil)
> > (unless (eq section magit-root-section)
> > (run-hook-with-args-until-success
> > 'magit-section-highlight-hook section selection))
> > (--each magit-section-unhighlight-sections
> > (run-hook-with-args-until-success
> > 'magit-section-unhighlight-hook it selection))
> > (restore-buffer-modified-p nil)
>
> Hmm... what kind of buffer modifications might happen in here?
Deletion of overlays, perhaps? And there are all those hooks which
might not be nil.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Wed, 23 Mar 2016 11:25:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 23079 <at> debbugs.gnu.org (full text, mbox):
>> Hmm... what kind of buffer modifications might happen in here?
> Deletion of overlays, perhaps?
AFAIK this is not a buffer modification (it doesn't affect MODIFF nor
buffer-modified-p).
> And there are all those hooks which might not be nil.
Yes, that's what my question wants to know ;-)
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Wed, 23 Mar 2016 15:13:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> > And there are all those hooks which might not be nil.
>
> Yes, that's what my question wants to know ;-)
I'll have a look.
Thanks,
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Thu, 24 Mar 2016 02:08:01 GMT)
Full text and
rfc822 format available.
Message #46 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> I'll have a look.
Yes, indeed, at least one of those hooks seems to change text properties.
Can't look into it further, it's already too late.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Thu, 24 Mar 2016 21:33:02 GMT)
Full text and
rfc822 format available.
Message #49 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Yes, indeed, at least one of those hooks seems to change text
> properties. Can't look into it further, it's already too late.
Yes, I verified that it does.
So...what can we do? Can we salvage (sorry if this is the wrong word)
the cursor adjustment somehow?
Thanks,
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Thu, 24 Mar 2016 22:02:01 GMT)
Full text and
rfc822 format available.
Message #52 received at 23079 <at> debbugs.gnu.org (full text, mbox):
>> Yes, indeed, at least one of those hooks seems to change text
>> properties. Can't look into it further, it's already too late.
> Yes, I verified that it does.
> So...what can we do? Can we salvage (sorry if this is the wrong word)
> the cursor adjustment somehow?
Hmm... not without changes either to Emacs's C code (so as to perform
point-adjustment even if some changes were made to the buffer), or to
Magit's code (so as not to touch text-properties during
magit-section-update-highlight, e.g. using overlays instead).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Fri, 25 Mar 2016 11:43:02 GMT)
Full text and
rfc822 format available.
Message #55 received at 23079 <at> debbugs.gnu.org (full text, mbox):
>>> Yes, indeed, at least one of those hooks seems to change text
>>> properties. Can't look into it further, it's already too late.
>> Yes, I verified that it does.
>> So...what can we do? Can we salvage (sorry if this is the wrong word)
>> the cursor adjustment somehow?
>
> Hmm... not without changes either to Emacs's C code (so as to perform
> point-adjustment even if some changes were made to the buffer), or to
> Magit's code (so as not to touch text-properties during
> magit-section-update-highlight, e.g. using overlays instead).
If I remember correctly we started to use text-properties here because
Eli occationally tells us that we should not abuse overlays ;-)
It should easily be possible to go back to text-properties.
(I haven't followed this conversation closely because I am on a break.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Fri, 25 Mar 2016 13:54:02 GMT)
Full text and
rfc822 format available.
Message #58 received at 23079 <at> debbugs.gnu.org (full text, mbox):
> From: Jonas Bernoulli <jonas <at> bernoul.li>
> Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, Eli Zaretskii <eliz <at> gnu.org>, 23079 <at> debbugs.gnu.org
> Date: Fri, 25 Mar 2016 12:42:10 +0100
>
> If I remember correctly we started to use text-properties here because
> Eli occationally tells us that we should not abuse overlays ;-)
Eli also told you not to abuse invisible text in general. (I still
don't understand why Magit wants to hide text it itself produced,
instead of just deleting the part(s) it doesn't want to show.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Sat, 26 Mar 2016 10:22:02 GMT)
Full text and
rfc822 format available.
Message #61 received at 23079 <at> debbugs.gnu.org (full text, mbox):
> I still don't understand why Magit wants to hide text it itself
> produced, instead of just deleting the part(s) it doesn't want to
> show.
It saves us from having to perform potentially expensive calculations
repeatedly when a section is being expanded and collapsed multiple
times. Obviously a cache would help, and that's what I have in mind
for Magit v3.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23079
; Package
emacs
.
(Sat, 15 Aug 2020 04:23:01 GMT)
Full text and
rfc822 format available.
Message #64 received at 23079 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> tags 23079 notabug
> thanks
>
>> I try to give a recipe resembling a bug in Magit concerning hidden lines
>> and cursor movement. In some buffer (emacs -Q) do
>
>> (insert "111" "\n222\n"
>> (propertize "333\n444\n\n" 'invisible t)
>> "555\n666\n")
>
>> and move around with C-n, C-p. Then the cursor will appear over the
>> first "5" but point is actually located inside the invisible area.
>
> That's normal: (get-pos-property <pos> 'invisible) returns nil in front
> of "333" but t in front of "555", so point adjustment will try to move
> point to right before "333" when we're in that invisible chunk.
>
> IOW the position "right before 555" is actually considered as being
> "inside the invisible area" whereas the position "right before 333" is
> considered as being outside of it.
>
> If you want point adjustment to move point to right before "555"
> instead, you should change the stickiness of the `invisible' property so
> as to change which boundary position is considered "inside" and which is
> considered "outside".
This was tagged notabug, then started discussing possible changes in
Magit, and then nothing more happened in 4 years. So is there anything
more to do here or can this be closed?
Best regards,
Stefan Kangas
Reply sent
to
Stefan Kangas <stefan <at> marxist.se>
:
You have taken responsibility.
(Thu, 01 Oct 2020 12:27:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
Michael Heerdegen <michael_heerdegen <at> web.de>
:
bug acknowledged by developer.
(Thu, 01 Oct 2020 12:27:04 GMT)
Full text and
rfc822 format available.
Message #69 received at 23079-done <at> debbugs.gnu.org (full text, mbox):
Stefan Kangas <stefan <at> marxist.se> writes:
> Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
>
>> tags 23079 notabug
>> thanks
>>
>>> I try to give a recipe resembling a bug in Magit concerning hidden lines
>>> and cursor movement. In some buffer (emacs -Q) do
>>
>>> (insert "111" "\n222\n"
>>> (propertize "333\n444\n\n" 'invisible t)
>>> "555\n666\n")
>>
>>> and move around with C-n, C-p. Then the cursor will appear over the
>>> first "5" but point is actually located inside the invisible area.
>>
>> That's normal: (get-pos-property <pos> 'invisible) returns nil in front
>> of "333" but t in front of "555", so point adjustment will try to move
>> point to right before "333" when we're in that invisible chunk.
>>
>> IOW the position "right before 555" is actually considered as being
>> "inside the invisible area" whereas the position "right before 333" is
>> considered as being outside of it.
>>
>> If you want point adjustment to move point to right before "555"
>> instead, you should change the stickiness of the `invisible' property so
>> as to change which boundary position is considered "inside" and which is
>> considered "outside".
>
> This was tagged notabug, then started discussing possible changes in
> Magit, and then nothing more happened in 4 years. So is there anything
> more to do here or can this be closed?
More information was requested, but none was given within 6 weeks, so
I'm closing this bug. If there is anything more to do here, please
reply to this email (use "Reply to all" in your email client) and we can
reopen the bug report.
Best regards,
Stefan Kangas
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 30 Oct 2020 11:24:12 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 294 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.