GNU bug report logs - #20701
25.0.50; [PATCH] (vertical-motion 0) broken at display strings after newline

Previous Next

Package: emacs;

Reported by: Wolfgang Jenkner <wjenkner <at> inode.at>

Date: Sun, 31 May 2015 14:51:04 UTC

Severity: normal

Tags: patch

Found in version 25.0.50

Fixed in version 25.1

Done: Wolfgang Jenkner <wjenkner <at> inode.at>

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 20701 in the body.
You can then email your comments to 20701 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 eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org:
bug#20701; Package emacs. (Sun, 31 May 2015 14:51:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wolfgang Jenkner <wjenkner <at> inode.at>:
New bug report received and forwarded. Copy sent to eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org. (Sun, 31 May 2015 14:51:05 GMT) Full text and rfc822 format available.

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

From: Wolfgang Jenkner <wjenkner <at> inode.at>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50;
 [PATCH] (vertical-motion 0) broken at display strings after newline
Date: Sun, 31 May 2015 16:19:46 +0200
If you run the following snippet in emacs -Q point will end up at the
first line of the "Test" buffer, but it should stay at the second line.

(with-current-buffer (generate-new-buffer "Test")
  (pop-to-buffer (current-buffer))
  (insert "x\n")
  (save-excursion
    (insert (propertize "x" 'display "x")))
  (sit-for 1)
  (vertical-motion 0))

On the other hand, non-zero arguments for vertical-motion seem to work
correctly, as long as the buffer contains only ASCII characters before
the propertized "x".

Otherwise

(with-current-buffer (generate-new-buffer "Test")
  (pop-to-buffer (current-buffer))
  (insert "\né\n")
  (save-excursion
    (insert (propertize "x" 'display "x")))
  (sit-for 1)
  (vertical-motion -1))

Here, point should go to the second line but it goes to the first line.

The following patch tries to fix both issues.

-- >8 --
Subject: [PATCH] * src/indent.c (Fvertical_motion): Fix a case of motion by 0
 lines.

Starting from a display string after a newline, point went to the
previous line.

Also, correct an inadvertent use of a buffer position with FETCH_BYTE.
---
 src/indent.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/indent.c b/src/indent.c
index ce78308..b4e6d74 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2134,17 +2134,20 @@ whether or not it is currently displayed in some window.  */)
 	  overshoot_handled = 1;
 	}
       else if (IT_CHARPOS (it) == PT - 1
-	       && FETCH_BYTE (PT - 1) == '\n'
-	       && nlines < 0)
+	       && FETCH_BYTE (PT_BYTE - 1) == '\n'
+	       && nlines <= 0)
 	{
 	  /* The position we started from was covered by a display
 	     property, so we moved to position before the string, and
-	     backed up one line, because the character at PT - 1 is a
-	     newline.  So we need one less line to go up.  */
+	     backed up one line, because the character at PT - 1 is
+	     a newline.  So we need one less line to go up (or exactly
+	     one line to go down if nlines == 0).  */
 	  nlines++;
 	  /* But we still need to record that one line, in order to
 	     return the correct value to the caller.  */
 	  vpos_init = -1;
+
+	  overshoot_handled = 1;
 	}
       if (lcols_given)
 	to_x = window_column_x (w, window, extract_float (lcols), lcols);
@@ -2159,7 +2162,7 @@ whether or not it is currently displayed in some window.  */)
 	}
       else if (overshoot_handled)
 	{
-	  it.vpos = 0;
+	  it.vpos = vpos_init;
 	  move_it_by_lines (&it, min (PTRDIFF_MAX, nlines));
 	}
       else
-- 
2.4.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20701; Package emacs. (Sun, 31 May 2015 15:09:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Wolfgang Jenkner <wjenkner <at> inode.at>
Cc: 20701 <at> debbugs.gnu.org
Subject: Re: bug#20701: 25.0.50;
 [PATCH] (vertical-motion 0) broken at display strings after newline
Date: Sun, 31 May 2015 18:08:20 +0300
> Cc: Eli Zaretskii <eliz <at> gnu.org>
> From: Wolfgang Jenkner <wjenkner <at> inode.at>
> Date: Sun, 31 May 2015 16:19:46 +0200
> 
> If you run the following snippet in emacs -Q point will end up at the
> first line of the "Test" buffer, but it should stay at the second line.
> 
> (with-current-buffer (generate-new-buffer "Test")
>   (pop-to-buffer (current-buffer))
>   (insert "x\n")
>   (save-excursion
>     (insert (propertize "x" 'display "x")))
>   (sit-for 1)
>   (vertical-motion 0))
> 
> On the other hand, non-zero arguments for vertical-motion seem to work
> correctly, as long as the buffer contains only ASCII characters before
> the propertized "x".
> 
> Otherwise
> 
> (with-current-buffer (generate-new-buffer "Test")
>   (pop-to-buffer (current-buffer))
>   (insert "\né\n")
>   (save-excursion
>     (insert (propertize "x" 'display "x")))
>   (sit-for 1)
>   (vertical-motion -1))
> 
> Here, point should go to the second line but it goes to the first line.
> 
> The following patch tries to fix both issues.
> 
> -- >8 --
> Subject: [PATCH] * src/indent.c (Fvertical_motion): Fix a case of motion by 0
>  lines.
> 
> Starting from a display string after a newline, point went to the
> previous line.
> 
> Also, correct an inadvertent use of a buffer position with FETCH_BYTE.

Looks good to me, please push.

Thanks.




Reply sent to Wolfgang Jenkner <wjenkner <at> inode.at>:
You have taken responsibility. (Wed, 03 Jun 2015 13:58:03 GMT) Full text and rfc822 format available.

Notification sent to Wolfgang Jenkner <wjenkner <at> inode.at>:
bug acknowledged by developer. (Wed, 03 Jun 2015 13:58:04 GMT) Full text and rfc822 format available.

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

From: Wolfgang Jenkner <wjenkner <at> inode.at>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20701-done <at> debbugs.gnu.org
Subject: Re: bug#20701: 25.0.50;
 [PATCH] (vertical-motion 0) broken at display strings after newline
Date: Wed, 03 Jun 2015 15:56:12 +0200
Version: 25.1

On Sun, May 31 2015, Eli Zaretskii wrote:

>> Subject: [PATCH] * src/indent.c (Fvertical_motion): Fix a case of motion by 0
>>  lines.
>> 
>> Starting from a display string after a newline, point went to the
>> previous line.
>> 
>> Also, correct an inadvertent use of a buffer position with FETCH_BYTE.
>
> Looks good to me, please push.

Thank you very much for reviewing the patch.

Pushed to master.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 02 Jul 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 359 days ago.

Previous Next


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