all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org
Subject: Re: [kobayays@otsukakj.co.jp: vertical-motion]
Date: Mon, 28 Aug 2006 18:00:43 -0400	[thread overview]
Message-ID: <874pvwy0z8.fsf@stupidchicken.com> (raw)
In-Reply-To: <E1GHGBJ-0002qW-AM@fencepost.gnu.org> (Richard Stallman's message of "Sun, 27 Aug 2006 04:39:49 -0400")

> From: KOBAYASHI Yasuhiro <kobayays@otsukakj.co.jp>
> Subject: vertical-motion
>
> It seems that vertical-motion is not right in the case which
> some propertized texts are included in the line.
>
> (defun test-case (n)
>   ;; Preparate the test buffer.
>   (switch-to-buffer (get-buffer-create "test"))
>   (erase-buffer)
>   (let ((pos (point-min)))
>     (dotimes (i 3) (insert "\t\t\t\t\t\n"))
>     (while (< pos (point-max))
>       (and (= (char-after pos) ?\t)
> 	   (put-text-property pos (1+ pos) 'display (propertize "   >")))
>       (setq pos (1+ pos))))
>   ;; The following is the test case.
>   (goto-char (point-min))
>   (while (< (point) (point-max))
>     (beginning-of-line)
>     (forward-char n)
>     ;; If POINT is not on the edge of the line,
>     ;; POINT move to the beginning of the save line.
>     (vertical-motion 1)))
>
> - - Strange actions.
> (test-case 1)

The problem is that when the iterator method at PT is GET_FROM_STRING,
the value of it.current after calling move_it_to is PT + 1.  This is
because the call to set_iterator_to_next in xdisp.c:6607 (inside
move_it_in_display_line_to), upon reaching the end of the display
string at PT, sees that there are no more strings to display at PT and
calls pop_it, which automagically advances the iterator to PT + 1.
The code in Fvertical_motion then misfires:

      /* Move back if we got too far.  This may happen if
	 truncate-lines is on and PT is beyond right margin.
	 It may also happen if it_start is on an image or a stretch
	 glyph -- in that case, don't go back.  */
      if (IT_CHARPOS (it) > it_start && XINT (lines) > 0
	  && !start_on_image_or_stretch_p)
	move_it_by_lines (&it, -1, 0);

I propose the following fix.  It fixes the bug described in the above
bug report.

*** emacs/src/indent.c.~1.183.~	2006-02-25 13:07:18.000000000 -0500
--- emacs/src/indent.c	2006-08-28 17:54:41.000000000 -0400
***************
*** 2074,2080 ****
      {
        int it_start;
        int oselective;
!       int start_on_image_or_stretch_p;
  
        SET_TEXT_POS (pt, PT, PT_BYTE);
        start_display (&it, w, pt);
--- 2074,2080 ----
      {
        int it_start;
        int oselective;
!       int start_on_image_or_stretch_or_string_p;
  
        SET_TEXT_POS (pt, PT, PT_BYTE);
        start_display (&it, w, pt);
***************
*** 2086,2093 ****
  	 while the end position is really at some X > 0, the same X that
  	 PT had.  */
        it_start = IT_CHARPOS (it);
!       start_on_image_or_stretch_p = (it.method == GET_FROM_IMAGE
! 				     || it.method == GET_FROM_STRETCH);
        reseat_at_previous_visible_line_start (&it);
        it.current_x = it.hpos = 0;
        /* Temporarily disable selective display so we don't move too far */
--- 2086,2094 ----
  	 while the end position is really at some X > 0, the same X that
  	 PT had.  */
        it_start = IT_CHARPOS (it);
!       start_on_image_or_stretch_or_string_p = (it.method == GET_FROM_IMAGE
! 					       || it.method == GET_FROM_STRETCH
! 					       || it.method == GET_FROM_STRING);
        reseat_at_previous_visible_line_start (&it);
        it.current_x = it.hpos = 0;
        /* Temporarily disable selective display so we don't move too far */
***************
*** 2098,2107 ****
  
        /* Move back if we got too far.  This may happen if
  	 truncate-lines is on and PT is beyond right margin.
! 	 It may also happen if it_start is on an image or a stretch
! 	 glyph -- in that case, don't go back.  */
        if (IT_CHARPOS (it) > it_start && XINT (lines) > 0
! 	  && !start_on_image_or_stretch_p)
  	move_it_by_lines (&it, -1, 0);
  
        it.vpos = 0;
--- 2099,2108 ----
  
        /* Move back if we got too far.  This may happen if
  	 truncate-lines is on and PT is beyond right margin.
! 	 It may also happen if it_start is on an image, stretch
! 	 glyph, or string -- in that case, don't go back.  */
        if (IT_CHARPOS (it) > it_start && XINT (lines) > 0
! 	  && !start_on_image_or_stretch_or_string_p)
  	move_it_by_lines (&it, -1, 0);
  
        it.vpos = 0;

  parent reply	other threads:[~2006-08-28 22:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-27  8:39 [kobayays@otsukakj.co.jp: vertical-motion] Richard Stallman
2006-08-27  8:49 ` David Kastrup
2006-08-27 21:51   ` Kim F. Storm
2006-08-27 22:10     ` David Kastrup
2006-08-27 22:41       ` Kim F. Storm
2006-08-28 22:10       ` Richard Stallman
2006-08-28  9:52   ` Richard Stallman
2006-08-28 22:00 ` Chong Yidong [this message]
2006-08-29 22:17   ` Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874pvwy0z8.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.