GNU bug report logs - #79495
30.2; vertical-motion returns wrong value with word-wrap and display property

Previous Next

Package: emacs;

Reported by: Shingo Tanaka <shingo.fg8 <at> gmail.com>

Date: Tue, 23 Sep 2025 02:39:02 UTC

Severity: normal

Found in version 30.2

To reply to this bug, email your comments to 79495 AT debbugs.gnu.org.

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#79495; Package emacs. (Tue, 23 Sep 2025 02:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Shingo Tanaka <shingo.fg8 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 23 Sep 2025 02:39:02 GMT) Full text and rfc822 format available.

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

From: Shingo Tanaka <shingo.fg8 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.2; vertical-motion returns wrong value with word-wrap and display
 property
Date: Tue, 23 Sep 2025 11:37:24 +0900
[Message part 1 (text/plain, inline)]
Hi,

I found vertical-motion returns wrong value when word-wrap is t and there is a
display property at the end of visual line.

Here is how to reproduce.
[reproduce.el (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]

1. Run Emacs with no init file (> emacs --no-init-file)
2. Goto *scratch* buffer
3. Load attached file with M-x load-file reproduce.el
4. Go to the end of buffer
5. Type C-p (`previous-line')
6. You will see Emacs unexpectedly signals "Beginning of buffer"
   (This is the bug reported)

Through my diagnosis, the reason why Emacs signals here is because
vertical-motion in line-move-visual unexpectedly returns 0
even though the expected value is -1.

If you have any question, please let me know.

Regards,
Shingo

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79495; Package emacs. (Sun, 28 Sep 2025 05:26:04 GMT) Full text and rfc822 format available.

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

From: Shingo Tanaka <shingo.fg8 <at> gmail.com>
To: 79495 <at> debbugs.gnu.org
Subject: Re: bug#79495: 30.2;
 vertical-motion returns wrong value with word-wrap and display
 property
Date: Sun, 28 Sep 2025 14:25:00 +0900
Sorry it looks like file attachment was not convenient.  Let me rewrite it.

I found vertical-motion returns wrong value when word-wrap is t and there is a
display property at the end of visual line.

Here is how to reproduce.

0. Save below as reproduce.el
;; -*- lexical-binding: t; -*-
(setq word-wrap t)
(erase-buffer)
(insert "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
(insert "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
(goto-char 78) ;; the 3rd "z" in the 2nd visual line
(let* ((beg (point)) (end (1+ beg)))
  (put-text-property beg end 'display
                     (concat (buffer-substring-no-properties beg end) " ")))

1. Run Emacs with no init file (> emacs --no-init-file)

2. Goto *scratch* buffer

3. Load attached file with M-x load-file reproduce.el

4. Go to the end of buffer

5. Type C-p (`previous-line')

6. You will see Emacs unexpectedly signals "Beginning of buffer" even though
   the point was in the 2nd line.  (This is the bug reported)
   
Through my diagnosis, the reason why Emacs signals here is because
vertical-motion in line-move-visual unexpectedly returns 0
even though the expected value is -1.

If you have any question, please let me know.

Regards,
Shingo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79495; Package emacs. (Sun, 28 Sep 2025 08:36:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Shingo Tanaka <shingo.fg8 <at> gmail.com>
Cc: 79495 <at> debbugs.gnu.org
Subject: Re: bug#79495: 30.2;
 vertical-motion returns wrong value with word-wrap and display
 property
Date: Sun, 28 Sep 2025 11:34:46 +0300
> Date: Sun, 28 Sep 2025 14:25:00 +0900
> From: Shingo Tanaka <shingo.fg8 <at> gmail.com>
> 
> Sorry it looks like file attachment was not convenient.  Let me rewrite it.

There was nothing wrong with your original submission.

The word-wrap mode is always tricky in vertical-motion, especially
when display properties or overlays are involved.  I hope someone will
be able to debug this; if not, I will get to it when I have time.

Thanks.




This bug report was last modified 38 days ago.

Previous Next


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