From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#11133: 24.0.94; Cursor gets "stuck" on an indented line with wrapped overlay Date: Fri, 06 Apr 2012 18:48:15 +0300 Message-ID: <8362dcc14w.fsf@gnu.org> References: <5871DE9D-63E6-40A5-9D1D-6D07F4AA2343@gmail.com> <83y5qiyso5.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1333728715 5484 80.91.229.3 (6 Apr 2012 16:11:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Apr 2012 16:11:55 +0000 (UTC) Cc: 11133@debbugs.gnu.org To: darthandrus@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 06 18:11:52 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SGBlI-0006QS-8i for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Apr 2012 18:11:44 +0200 Original-Received: from localhost ([::1]:53481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGBQw-0006j3-AR for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Apr 2012 11:50:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGBQo-0006bC-0t for bug-gnu-emacs@gnu.org; Fri, 06 Apr 2012 11:50:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SGBQd-0001MD-Na for bug-gnu-emacs@gnu.org; Fri, 06 Apr 2012 11:50:31 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGBQd-0001M9-JW for bug-gnu-emacs@gnu.org; Fri, 06 Apr 2012 11:50:23 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SGBRG-0005as-Dd for bug-gnu-emacs@gnu.org; Fri, 06 Apr 2012 11:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Apr 2012 15:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11133-submit@debbugs.gnu.org id=B11133.133372743121463 (code B ref 11133); Fri, 06 Apr 2012 15:51:02 +0000 Original-Received: (at 11133) by debbugs.gnu.org; 6 Apr 2012 15:50:31 +0000 Original-Received: from localhost ([127.0.0.1]:42749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SGBQl-0005a7-3y for submit@debbugs.gnu.org; Fri, 06 Apr 2012 11:50:31 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:58928) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SGBQi-0005Zz-IY for 11133@debbugs.gnu.org; Fri, 06 Apr 2012 11:50:30 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0M2200100DQK1S00@a-mtaout22.012.net.il> for 11133@debbugs.gnu.org; Fri, 06 Apr 2012 18:49:47 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.229.252.114]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M2200M9IEMYLS91@a-mtaout22.012.net.il>; Fri, 06 Apr 2012 18:49:47 +0300 (IDT) In-reply-to: <83y5qiyso5.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:58562 Archived-At: > Date: Fri, 30 Mar 2012 19:12:10 +0300 > From: Eli Zaretskii > Cc: 11133@debbugs.gnu.org > > > From: Ivan Andrus > > 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; }