GNU bug report logs - #11133
24.0.94; Cursor gets "stuck" on an indented line with wrapped overlay

Previous Next

Package: emacs;

Reported by: Ivan Andrus <darthandrus <at> gmail.com>

Date: Fri, 30 Mar 2012 15:20:02 UTC

Severity: normal

Found in version 24.0.94

Done: Eli Zaretskii <eliz <at> gnu.org>

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 11133 in the body.
You can then email your comments to 11133 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#11133; Package emacs. (Fri, 30 Mar 2012 15:20:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Andrus <darthandrus <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 30 Mar 2012 15:20:02 GMT) Full text and rfc822 format available.

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

From: Ivan Andrus <darthandrus <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.94; Cursor gets "stuck" on an indented line with wrapped overlay
Date: Fri, 30 Mar 2012 16:47:05 +0200
Put the following (including comments) in a buffer and evaluate.

#+begin_src emacs-lisp
;; Note that the next line is indented
 ;; This buffer is for notes you don't want to save, and for Lisp evaluation.;; If you want to create a file, visit that file with C-x C-f,;; then enter the text in that file's own buffer.

;; evaluate this
(let ((ov (make-overlay
	   (progn (goto-char (point-min))
		  (forward-line)
		  (back-to-indentation)
		  (point))
	   (progn (end-of-line)
		  (point))
	   nil t nil)))
 (overlay-put ov 'display
	       (make-string 500 ?b)))

#+end_src

Now run `previous-line' several times and it will get stuck at the
indentation of the bbbbb line.  If you have an extremely wide screen you
may need to shrink the emacs window so that the bbbb line wraps.  Also
note that running `previous-line' with a large prefix-argument will
move past the line, and once it is stuck, running with a prefix-argument of 2 or
greater will allow you to move past.

FWIW, I ran into this while writing a LaTeX file with preview-mode and a
large equation that wrapped on my screen.

This does not seem to be a problem in Emacs 22.1.1 in a terminal which
is the only other emacs I have easy access to.

Thanks,
Ivan

In GNU Emacs 24.0.94.10 (i386-apple-darwin10.8.0, NS apple-appkit-1038.36)
of 2012-03-30 on oroszlan.local
Windowing system distributor `Apple', version 10.3.1038
Configured using:
`configure '--with-ns' '-C''

Important settings:
 value of $LC_ALL: nil
 value of $LC_COLLATE: nil
 value of $LC_CTYPE: UTF-8
 value of $LC_MESSAGES: nil
 value of $LC_MONETARY: nil
 value of $LC_NUMERIC: nil
 value of $LC_TIME: nil
 value of $LANG: nil
 value of $XMODIFIERS: nil
 locale-coding-system: utf-8-unix
 default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
 tooltip-mode: t
 mouse-wheel-mode: t
 tool-bar-mode: t
 menu-bar-mode: t
 file-name-shadow-mode: t
 global-font-lock-mode: t
 font-lock-mode: t
 blink-cursor-mode: t
 auto-composition-mode: t
 auto-encryption-mode: t
 auto-compression-mode: t
 line-number-mode: t
 transient-mark-mode: t

Recent input:
f i x SPC <backspace> - a r g u m e n t SPC o f SPC 
2 SPC o r SPC g r e a t e r SPC w i l l SPC a l l o 
w y <backspace> SPC SPC y o u SPC t o SPC m o v e SPC 
p a s t <C-left> <C-left> <C-left> <C-left> <backspace> 
C-e . <C-up> C-x C-e <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <down> <down> <down> 
<down> <down> <C-down> X E <backspace> <backspace> 
C-x C-e <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <down> <down> 
<down> <down> <up> <up> <up> <up> <up> <up> <up> <up> 
<down> <down> <down> <down> <down> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <down> <down> C-3 <C-up> 
<down> <down> <down> C-3 <C-up> <down> <down> <down> 
C-2 <C-up> <down> <down> <down> <down> <C-up> <down> 
<down> <down> <down> <up> C-e C-2 <C-up> <down> <down> 
<down> C-e C-2 <C-up> <down> <down> <down> <down> <up> 
C-2 <C-up> <down-mouse-1> <mouse-1> <down-mouse-1> 
<mouse-movement> <mouse-movement> <drag-mouse-1> C-w 
<C-right> <C-right> . C-k <backspace> , SPC e v e n 
<C-left> <C-left> <C-left> <C-left> <C-left> ( <backspace> 
<C-right> <C-right> <C-right> <C-right> <C-tab> <C-up> 
<C-tab> <up> <down> C-x C-e <up> <up> <up> <down> C-2 
<up> <up> <up> <down> C-2 <up> <up> <up> <down> C-3 
<up> <up> <up> <down> C-3 <up> <down> C-5 <up> <up> 
<up> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <C-right> <C-right> <C-right> <C-right> <C-right> 
SPC l a r e g <backspace> <backspace> g e <C-right> 
<C-right> <C-right> <C-right> C-k , SPC a n d C-l M-l 
<right> <C-right> <C-right> <C-right> , C-e C-x C-s 
M-x r e p o r <tab> <return>

Recent messages:
byte-code: End of buffer
Undo! [3 times]
Auto-saving...done
byte-code: Beginning of buffer [4 times]
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" [2 times]
byte-code: End of buffer [6 times]
Auto-saving...done
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
Saving file /Users/gvol/vcs/emacs/preview-picture-bug.el...
Wrote /Users/gvol/vcs/emacs/preview-picture-bug.el

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr filecache emacsbug message format-spec
rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail regexp-opt rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils vc-hg time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer loaddefs button faces cus-face files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11133; Package emacs. (Fri, 30 Mar 2012 16:44:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ivan Andrus <darthandrus <at> gmail.com>
Cc: 11133 <at> debbugs.gnu.org
Subject: Re: bug#11133: 24.0.94;
	Cursor gets "stuck" on an indented line with wrapped overlay
Date: Fri, 30 Mar 2012 19:12:10 +0300
> From: Ivan Andrus <darthandrus <at> gmail.com>
> Date: Fri, 30 Mar 2012 16:47:05 +0200
> 
> Put the following (including comments) in a buffer and evaluate.
> 
> #+begin_src emacs-lisp
> ;; Note that the next line is indented
>  ;; This buffer is for notes you don't want to save, and for Lisp evaluation.;; If you want to create a file, visit that file with C-x C-f,;; then enter the text in that file's own buffer.
> 
> ;; evaluate this
> (let ((ov (make-overlay
> 	   (progn (goto-char (point-min))
> 		  (forward-line)
> 		  (back-to-indentation)
> 		  (point))
> 	   (progn (end-of-line)
> 		  (point))
> 	   nil t nil)))
>  (overlay-put ov 'display
> 	       (make-string 500 ?b)))
> 
> #+end_src
> 
> Now run `previous-line' several times and it will get stuck at the
> indentation of the bbbbb line.  If you have an extremely wide screen you
> may need to shrink the emacs window so that the bbbb line wraps.  Also
> note that running `previous-line' with a large prefix-argument will
> move past the line

More accurately, "large enough" is the number of screen lines taken by
the overlay string.  In my case, it was 7.

> This does not seem to be a problem in Emacs 22.1.1 in a terminal which
> is the only other emacs I have easy access to.

This is a bug in visual line movement.  Visual line movement was
introduced in Emacs 23, that's why you don't see this in Emacs 22.  In
Emacs 23, the cursor gets stuck similarly, so this is not a regression
wrt Emacs 23.  Disable line-move-visual with the current 24 trunk, and
the problem will go away in Emacs 24 as well.

I will take a look when I have time.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11133; Package emacs. (Fri, 30 Mar 2012 17:22:02 GMT) Full text and rfc822 format available.

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

From: Ivan Andrus <darthandrus <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 11133 <at> debbugs.gnu.org
Subject: Re: bug#11133: 24.0.94;
	Cursor gets "stuck" on an indented line with wrapped overlay
Date: Fri, 30 Mar 2012 18:49:32 +0200
On Mar 30, 2012, at 6:12 PM, Eli Zaretskii wrote:
>> From: Ivan Andrus <darthandrus <at> gmail.com>
>> Date: Fri, 30 Mar 2012 16:47:05 +0200
>> 
>> Put the following (including comments) in a buffer and evaluate.
>> 
>> #+begin_src emacs-lisp
>> ;; Note that the next line is indented
>> ;; This buffer is for notes you don't want to save, and for Lisp evaluation.;; If you want to create a file, visit that file with C-x C-f,;; then enter the text in that file's own buffer.
>> 
>> ;; evaluate this
>> (let ((ov (make-overlay
>> 	   (progn (goto-char (point-min))
>> 		  (forward-line)
>> 		  (back-to-indentation)
>> 		  (point))
>> 	   (progn (end-of-line)
>> 		  (point))
>> 	   nil t nil)))
>> (overlay-put ov 'display
>> 	       (make-string 500 ?b)))
>> 
>> #+end_src
>> 
>> Now run `previous-line' several times and it will get stuck at the
>> indentation of the bbbbb line.  If you have an extremely wide screen you
>> may need to shrink the emacs window so that the bbbb line wraps.  Also
>> note that running `previous-line' with a large prefix-argument will
>> move past the line
> 
> More accurately, "large enough" is the number of screen lines taken by
> the overlay string.  In my case, it was 7.
> 
>> This does not seem to be a problem in Emacs 22.1.1 in a terminal which
>> is the only other emacs I have easy access to.
> 
> This is a bug in visual line movement.  Visual line movement was
> introduced in Emacs 23, that's why you don't see this in Emacs 22.  In
> Emacs 23, the cursor gets stuck similarly, so this is not a regression
> wrt Emacs 23.  Disable line-move-visual with the current 24 trunk, and
> the problem will go away in Emacs 24 as well.
> 
> I will take a look when I have time.

That makes sense.

Thanks,
Ivan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11133; Package emacs. (Fri, 06 Apr 2012 15:51:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: darthandrus <at> gmail.com
Cc: Chong Yidong <cyd <at> stupidchicken.com>,
	Stefan Monnier <monnier <at> iro.umontreal.ca>, 11133 <at> debbugs.gnu.org
Subject: Re: bug#11133: 24.0.94;
	Cursor gets "stuck" on an indented line with wrapped overlay
Date: Fri, 06 Apr 2012 18:48:15 +0300
> Date: Fri, 30 Mar 2012 19:12:10 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 11133 <at> debbugs.gnu.org
> 
> > From: Ivan Andrus <darthandrus <at> gmail.com>
> > Date: Fri, 30 Mar 2012 16:47:05 +0200
> > 
> > Put the following (including comments) in a buffer and evaluate.
> > 
> > #+begin_src emacs-lisp
> > ;; Note that the next line is indented
> >  ;; This buffer is for notes you don't want to save, and for Lisp evaluation.;; If you want to create a file, visit that file with C-x C-f,;; then enter the text in that file's own buffer.
> > 
> > ;; evaluate this
> > (let ((ov (make-overlay
> > 	   (progn (goto-char (point-min))
> > 		  (forward-line)
> > 		  (back-to-indentation)
> > 		  (point))
> > 	   (progn (end-of-line)
> > 		  (point))
> > 	   nil t nil)))
> >  (overlay-put ov 'display
> > 	       (make-string 500 ?b)))
> > 
> > #+end_src
> > 
> > Now run `previous-line' several times and it will get stuck at the
> > indentation of the bbbbb line.  If you have an extremely wide screen you
> > may need to shrink the emacs window so that the bbbb line wraps.  Also
> > note that running `previous-line' with a large prefix-argument will
> > move past the line
> 
> More accurately, "large enough" is the number of screen lines taken by
> the overlay string.  In my case, it was 7.
> 
> > This does not seem to be a problem in Emacs 22.1.1 in a terminal which
> > is the only other emacs I have easy access to.
> 
> This is a bug in visual line movement.  Visual line movement was
> introduced in Emacs 23, that's why you don't see this in Emacs 22.  In
> Emacs 23, the cursor gets stuck similarly, so this is not a regression
> wrt Emacs 23.  Disable line-move-visual with the current 24 trunk, and
> the problem will go away in Emacs 24 as well.

The problem here is that vertical-motion does not consider the case of
a display string that starts at point and takes more than one screen
line (because it's long).  The patch below plumbs that hole.

Stefan and Chong, please tell me whether to install now or wait until
after the Emacs 24.1 branch is cut.

=== modified file 'src/indent.c'
--- src/indent.c	2012-01-19 07:21:25 +0000
+++ src/indent.c	2012-04-06 15:40:43 +0000
@@ -2021,6 +2021,7 @@ whether or not it is currently displayed
       EMACS_INT it_start;
       int first_x, it_overshoot_count = 0;
       int overshoot_handled = 0;
+      int disp_string_at_start_p = 0;
 
       itdata = bidi_shelve_cache ();
       SET_TEXT_POS (pt, PT, PT_BYTE);
@@ -2035,6 +2036,8 @@ whether or not it is currently displayed
 	{
 	  const char *s = SSDATA (it.string);
 	  const char *e = s + SBYTES (it.string);
+
+	  disp_string_at_start_p = it.string_from_display_prop_p;
 	  while (s < e)
 	    {
 	      if (*s++ == '\n')
@@ -2062,19 +2065,29 @@ whether or not it is currently displayed
       /* IT may move too far if truncate-lines is on and PT lies
 	 beyond the right margin.  IT may also move too far if the
 	 starting point is on a Lisp string that has embedded
-	 newlines.  In these cases, backtrack.  */
+	 newlines, or spans several screen lines.  In these cases,
+	 backtrack.  */
       if (IT_CHARPOS (it) > it_start)
 	{
-	  /* We need to backtrack also if the Lisp string contains no
-	     newlines, but there is a newline right after it.  In this
-	     case, IT overshoots if there is an after-string just
-	     before the newline.  */
-	  if (it_overshoot_count < 0
-	      && it.method == GET_FROM_BUFFER
-	      && it.c == '\n')
-	    it_overshoot_count = 1;
-	  if (it_overshoot_count > 0)
-	    move_it_by_lines (&it, -it_overshoot_count);
+	  if (it_overshoot_count < 0)
+	    {
+	      /* We need to backtrack also if the Lisp string contains
+		 no newlines, but there is a newline right after it.
+		 In this case, IT overshoots if there is an
+		 after-string just before the newline.  */
+	      if (it.method == GET_FROM_BUFFER && it.c == '\n')
+		it_overshoot_count = 1;
+	      else if (disp_string_at_start_p && it.vpos > 0)
+		{
+		  /* This is the case of a display string that spans
+		     several screen lines.  In that case, we end up at
+		     the end of the string, and it.vpos tells us how
+		     many screen lines we need to backtrack.  */
+		  it_overshoot_count = it.vpos;
+		}
+	      if (it_overshoot_count > 0)
+		move_it_by_lines (&it, -it_overshoot_count);
+	    }
 
 	  overshoot_handled = 1;
 	}





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11133; Package emacs. (Sat, 07 Apr 2012 04:12:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: darthandrus <at> gmail.com, Chong Yidong <cyd <at> stupidchicken.com>,
	11133 <at> debbugs.gnu.org
Subject: Re: bug#11133: 24.0.94;
	Cursor gets "stuck" on an indented line with wrapped overlay
Date: Sat, 07 Apr 2012 00:10:33 -0400
> The problem here is that vertical-motion does not consider the case of
> a display string that starts at point and takes more than one screen
> line (because it's long).  The patch below plumbs that hole.

> Stefan and Chong, please tell me whether to install now or wait until
> after the Emacs 24.1 branch is cut.

Is it a regression w.r.t 23?  If not, please just install it on the
trunk,


        Stefan




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 07 Apr 2012 08:00:02 GMT) Full text and rfc822 format available.

Notification sent to Ivan Andrus <darthandrus <at> gmail.com>:
bug acknowledged by developer. (Sat, 07 Apr 2012 08:00:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: darthandrus <at> gmail.com, cyd <at> stupidchicken.com, 11133-done <at> debbugs.gnu.org
Subject: Re: bug#11133: 24.0.94;
	Cursor gets "stuck" on an indented line with wrapped overlay
Date: Sat, 07 Apr 2012 10:57:07 +0300
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Cc: darthandrus <at> gmail.com, 11133 <at> debbugs.gnu.org,
>         Chong Yidong <cyd <at> stupidchicken.com>
> Date: Sat, 07 Apr 2012 00:10:33 -0400
> 
> > The problem here is that vertical-motion does not consider the case of
> > a display string that starts at point and takes more than one screen
> > line (because it's long).  The patch below plumbs that hole.
> 
> > Stefan and Chong, please tell me whether to install now or wait until
> > after the Emacs 24.1 branch is cut.
> 
> Is it a regression w.r.t 23?

No.

> If not, please just install it on the trunk,

Done as trunk revision 107782.

Closing this bug.




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

This bug report was last modified 12 years ago.

Previous Next


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