GNU bug report logs - #66942
move-to-column behavior when newlines have a display property

Previous Next

Package: emacs;

Reported by: Sebastian Wålinder <s.walinder <at> gmail.com>

Date: Sun, 5 Nov 2023 05:45:03 UTC

Severity: normal

Tags: notabug, wontfix

Merged with 64988

Found in version 30.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 66942 in the body.
You can then email your comments to 66942 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#66942; Package emacs. (Sun, 05 Nov 2023 05:45:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sebastian Wålinder <s.walinder <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 05 Nov 2023 05:45:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sebastian Wålinder <s.walinder <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: move-to-column behavior when newlines have a display property
Date: Sun, 05 Nov 2023 09:14:05 +1100
Hello! 

There was a bug that I encountered in a downstream Emacs package relating to setting line-move-visual to nil and running line-move when the package has created overlays on newlines.

The maintainer of the package has tracked down the bug to some incorrect behavior in the function move-to-column when overlays are present on newlines.

Here's a link to the issue that describes the issue with move-to-column:
https://github.com/jdtsmith/indent-bars/issues/22

Thoughts?

Thank you!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66942; Package emacs. (Sun, 05 Nov 2023 06:01:01 GMT) Full text and rfc822 format available.

Message #8 received at 66942 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sebastian Wålinder <s.walinder <at> gmail.com>
Cc: 66942 <at> debbugs.gnu.org
Subject: Re: bug#66942: move-to-column behavior when newlines have a display
 property
Date: Sun, 05 Nov 2023 07:59:45 +0200
unarchive 64988
forcemerge 66942 64988
thanks

> From: Sebastian Wålinder <s.walinder <at> gmail.com>
> Date: Sun, 05 Nov 2023 09:14:05 +1100
> 
> There was a bug that I encountered in a downstream Emacs package relating to setting line-move-visual to nil and running line-move when the package has created overlays on newlines.
> 
> The maintainer of the package has tracked down the bug to some incorrect behavior in the function move-to-column when overlays are present on newlines.
> 
> Here's a link to the issue that describes the issue with move-to-column:
> https://github.com/jdtsmith/indent-bars/issues/22
> 
> Thoughts?

It's the intended behavior.  It is the best Emacs can do given the
limitations posed by such overlay strings, see the detailed
explanation in bug#64988.

My best recommendation is not to use overlay strings with embedded
newlines, if accurate movement by columns is important.




Forcibly Merged 64988 66942. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 05 Nov 2023 06:01:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66942; Package emacs. (Sun, 05 Nov 2023 17:20:02 GMT) Full text and rfc822 format available.

Message #13 received at 66942 <at> debbugs.gnu.org (full text, mbox):

From: JD Smith <jdtsmith <at> gmail.com>
To: 66942 <at> debbugs.gnu.org
Subject: bug#66942: move-to-column behavior when newlines have a display
 property
Date: Sun, 5 Nov 2023 12:18:12 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

> ...unless someone comes with an idea for how to handle these situations in a sensible way (and I thought long and hard about it, but couldn't find such ideas), this will remain a limitation of move-to-column, and one of the complications introduced by display strings with embedded newlines in general.

Would it not make more sense to place the cursor _before_ the first character with a `\n` in its replacing-display property, if move-to-column attempts to move past it?  It is true that neither that position nor a position on a subsequent line is “correct”, but the former at least preserves the expected move-to-column semantics of “stay on this line”.  

The final newline is the only place to add display on blank lines, so this will be a general problem for any package attempting to do that.  Here’s a simple test of this for people wanting to investigate:

(progn
  (insert "\n>>>>\n" (propertize "\n" 'display "xxxxx\n") "SHOULD NOT MOVE HERE\n<<<<")
  (forward-line -2) ; at beginning of xxxxx\n line
  (move-to-column 10)) ; should not move past the line



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66942; Package emacs. (Sun, 05 Nov 2023 17:49:01 GMT) Full text and rfc822 format available.

Message #16 received at 66942 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: JD Smith <jdtsmith <at> gmail.com>
Cc: 66942 <at> debbugs.gnu.org
Subject: Re: bug#66942: move-to-column behavior when newlines have a display
 property
Date: Sun, 05 Nov 2023 19:47:27 +0200
> From: JD Smith <jdtsmith <at> gmail.com>
> Date: Sun, 5 Nov 2023 12:18:12 -0500
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > ...unless someone comes with an idea for how to handle these situations in a sensible way (and I thought long and hard about it, but couldn't find such ideas), this will remain a limitation of move-to-column, and one of the complications introduced by display strings with embedded newlines in general.
> 
> Would it not make more sense to place the cursor _before_ the first character with a `\n` in its replacing-display property, if move-to-column attempts to move past it?  It is true that neither that position nor a position on a subsequent line is “correct”, but the former at least preserves the expected move-to-column semantics of “stay on this line”.  

"Stay on this line" has one meaning when the text is displayed in some
window and move-to-column is used for positioning the cursors, and
another meaning when move-to-column is used as part of a Lisp program
where move-to-column is used to move point (where "this line" is
generally the line of buffer text).

In addition, what you suggest will cause the behavior to change
drastically when a newline is added to the display property.

Moreover, did you also consider what should current-column return in
those cases?  These two must work in sync, as much as possible.

And finally, when neither behavior is 100% correct, I think we should
generally prefer the behavior we had for some time, because any
changes in that could break someone's code.  Whereas if someone wants
the behavior you describe, they can have that for the price of
relatively simple changes in their Lisp programs.




bug closed, send any further explanations to 66942 <at> debbugs.gnu.org and Sebastian Wålinder <s.walinder <at> gmail.com> Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 10 Jan 2024 11:06:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 07 Feb 2024 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 92 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.