unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: Miles Bader <miles@gnu.org>
Cc: David Reitter <david.reitter@gmail.com>,
	"Lennart Borgman \(gmail\)" <lennart.borgman@gmail.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: visual-line-mode
Date: Thu, 03 Jul 2008 15:20:11 -0400	[thread overview]
Message-ID: <87skuqbwr8.fsf@stupidchicken.com> (raw)
In-Reply-To: <buotzfbqzcw.fsf@dhapc248.dev.necel.com> (Miles Bader's message of "Mon, 30 Jun 2008 14:13:35 +0900")

Could someone please test the following patch to xdisp.c?  It should fix
some bugs in the word-wrapping code, but there are probably still
lurking issues.


*** trunk/src/xdisp.c.~1.1227.~	2008-07-03 11:54:01.000000000 -0400
--- trunk/src/xdisp.c	2008-07-03 15:16:08.000000000 -0400
***************
*** 6664,6670 ****
  {
    enum move_it_result result = MOVE_UNDEFINED;
    struct glyph_row *saved_glyph_row;
!   struct it wrap_it, atpos_it;
    int may_wrap = 0;
  
    /* Don't produce glyphs in produce_glyphs.  */
--- 6664,6670 ----
  {
    enum move_it_result result = MOVE_UNDEFINED;
    struct glyph_row *saved_glyph_row;
!   struct it wrap_it, atpos_it, atx_it;
    int may_wrap = 0;
  
    /* Don't produce glyphs in produce_glyphs.  */
***************
*** 6672,6682 ****
    it->glyph_row = NULL;
  
    /* Use wrap_it to save a copy of IT wherever a word wrap could
!      occur.  Use atpos_it to save a copy of IT at the desired
       position, if found, so that we can scan ahead and check if the
!      word later overshoots the window edge.  */
    wrap_it.sp = -1;
    atpos_it.sp = -1;
  
  #define BUFFER_POS_REACHED_P()					\
    ((op & MOVE_TO_POS) != 0					\
--- 6672,6684 ----
    it->glyph_row = NULL;
  
    /* Use wrap_it to save a copy of IT wherever a word wrap could
!      occur.  Use atpos_it to save a copy of IT at the desired buffer
       position, if found, so that we can scan ahead and check if the
!      word later overshoots the window edge.  Use atx_it similarly, for
!      pixel positions.  */
    wrap_it.sp = -1;
    atpos_it.sp = -1;
+   atx_it.sp = -1;
  
  #define BUFFER_POS_REACHED_P()					\
    ((op & MOVE_TO_POS) != 0					\
***************
*** 6705,6718 ****
  	{
  	  if (it->line_wrap == WORD_WRAP)
  	    {
- 	      /* If wrap_it is valid, the current position might be in
- 		 a word that is wrapped to the next line, so continue
- 		 to see if that happens.  */
  	      if (wrap_it.sp < 0)
  		{
  		  result = MOVE_POS_MATCH_OR_ZV;
  		  break;
  		}
  	      if (atpos_it.sp < 0)
  		atpos_it = *it;
  	    }
--- 6707,6720 ----
  	{
  	  if (it->line_wrap == WORD_WRAP)
  	    {
  	      if (wrap_it.sp < 0)
  		{
  		  result = MOVE_POS_MATCH_OR_ZV;
  		  break;
  		}
+ 	      /* If wrap_it is valid, the current position might be in
+ 		 a word that is wrapped to the next line, so continue
+ 		 to see if that happens.  */
  	      if (atpos_it.sp < 0)
  		atpos_it = *it;
  	    }
***************
*** 6759,6766 ****
  		  if (atpos_it.sp >= 0)
  		    {
  		      *it = atpos_it;
! 		      atpos_it.sp = -1;
! 		      goto buffer_pos_reached;
  		    }
  		  wrap_it = *it;
  		  may_wrap = 0;
--- 6761,6774 ----
  		  if (atpos_it.sp >= 0)
  		    {
  		      *it = atpos_it;
! 		      result = MOVE_POS_MATCH_OR_ZV;
! 		      goto done;
! 		    }
! 		  if (atx_it.sp >= 0)
! 		    {
! 		      *it = atx_it;
! 		      result = MOVE_X_REACHED;
! 		      goto done;
  		    }
  		  wrap_it = *it;
  		  may_wrap = 0;
***************
*** 6816,6836 ****
  	      /* We want to leave anything reaching TO_X to the caller.  */
  	      if ((op & MOVE_TO_X) && new_x > to_x)
  		{
! 		  if (BUFFER_POS_REACHED_P ())
  		    {
! 		      if (it->line_wrap == WORD_WRAP)
  			{
  			  if (wrap_it.sp < 0)
  			    goto buffer_pos_reached;
! 			  if (atpos_it.sp < 0)
  			    atpos_it = *it;
  			}
! 		      else
  			goto buffer_pos_reached;
  		    }
- 		  it->current_x = x;
- 		  result = MOVE_X_REACHED;
- 		  break;
  		}
  
  	      if (/* Lines are continued.  */
--- 6824,6858 ----
  	      /* We want to leave anything reaching TO_X to the caller.  */
  	      if ((op & MOVE_TO_X) && new_x > to_x)
  		{
! 		  if (it->line_wrap == WORD_WRAP)
  		    {
! 		      if (BUFFER_POS_REACHED_P ())
  			{
  			  if (wrap_it.sp < 0)
  			    goto buffer_pos_reached;
! 			  else if (atpos_it.sp < 0)
  			    atpos_it = *it;
  			}
! 		      else if (wrap_it.sp < 0)
! 			{
! 			  it->current_x = x;
! 			  result = MOVE_X_REACHED;
! 			  break;
! 			}
! 		      else if (atx_it.sp < 0)
! 			{
! 			  atx_it = *it;
! 			  atx_it.current_x = x;
! 			}
! 		    }
! 		  else
! 		    {
! 		      if (BUFFER_POS_REACHED_P ())
  			goto buffer_pos_reached;
+ 		      it->current_x = x;
+ 		      result = MOVE_X_REACHED;
+ 		      break;
  		    }
  		}
  
  	      if (/* Lines are continued.  */
***************
*** 6840,6852 ****
  		      /* Or it fits exactly and we're on a window
  			 system frame.  */
  		      || (new_x == it->last_visible_x
! 			  && FRAME_WINDOW_P (it->f))))
  		{
  		  if (/* IT->hpos == 0 means the very first glyph
  			 doesn't fit on the line, e.g. a wide image.  */
  		      it->hpos == 0
  		      || (new_x == it->last_visible_x
! 			  && FRAME_WINDOW_P (it->f)))
  		    {
  		      ++it->hpos;
  		      it->current_x = new_x;
--- 6862,6876 ----
  		      /* Or it fits exactly and we're on a window
  			 system frame.  */
  		      || (new_x == it->last_visible_x
! 			  && FRAME_WINDOW_P (it->f)
! 			  && it->line_wrap == WINDOW_WRAP)))
  		{
  		  if (/* IT->hpos == 0 means the very first glyph
  			 doesn't fit on the line, e.g. a wide image.  */
  		      it->hpos == 0
  		      || (new_x == it->last_visible_x
! 			  && FRAME_WINDOW_P (it->f)
! 			  && it->line_wrap == WINDOW_WRAP))
  		    {
  		      ++it->hpos;
  		      it->current_x = new_x;
***************
*** 6903,6908 ****
--- 6927,6933 ----
  		    {
  		      *it = wrap_it;
  		      atpos_it.sp = -1;
+ 		      atx_it.sp = -1;
  		    }
  
  		  TRACE_MOVE ((stderr, "move_it_in: continued at %d\n",
***************
*** 6995,7003 ****
  #undef BUFFER_POS_REACHED_P
  
    /* If we scanned beyond to_pos and didn't find a point to wrap at,
!      return iterator at to_pos.  */
    if (atpos_it.sp >= 0)
      *it = atpos_it;
  
    /* Restore the iterator settings altered at the beginning of this
       function.  */
--- 7020,7032 ----
  #undef BUFFER_POS_REACHED_P
  
    /* If we scanned beyond to_pos and didn't find a point to wrap at,
!      restore the saved iterator.  */
    if (atpos_it.sp >= 0)
      *it = atpos_it;
+   else if (atx_it.sp >= 0)
+     *it = atx_it;
+ 
+  done:
  
    /* Restore the iterator settings altered at the beginning of this
       function.  */
***************
*** 16622,16628 ****
  				}
  			    }
  #endif /* HAVE_WINDOW_SYSTEM */
! 			  if (wrap_row_used > 0)
  			    goto back_to_wrap;
  			}
  		    }
--- 16651,16667 ----
  				}
  			    }
  #endif /* HAVE_WINDOW_SYSTEM */
! 
! 			  /* If line-wrap is on, consider returning to
! 			     a previously set wrap point, if there is
! 			     one.  Be sure to handle the case where
! 			     the last character on the line is a
! 			     space, as well as the case where the
! 			     following character is also a space.  */
! 			  if (wrap_row_used > 0
! 			      && (!may_wrap
! 				  || (it->what == IT_CHARACTER
! 				      && (it->c == ' ' || it->c == '\t'))))
  			    goto back_to_wrap;
  			}
  		    }




  parent reply	other threads:[~2008-07-03 19:20 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-29  6:30 visual-line-mode David Reitter
2008-06-29  7:05 ` visual-line-mode Miles Bader
2008-06-29  7:19   ` visual-line-mode Miles Bader
2008-06-29 14:01   ` visual-line-mode Stefan Monnier
2008-06-29 15:29     ` visual-line-mode Chong Yidong
2008-06-30  3:07     ` visual-line-mode Miles Bader
2008-06-30  3:15       ` visual-line-mode Chong Yidong
2008-06-30  5:13         ` visual-line-mode Miles Bader
2008-06-30  5:15           ` visual-line-mode Miles Bader
2008-06-30 10:39             ` visual-line-mode Miles Bader
2008-06-30 11:20               ` visual-line-mode Miles Bader
2008-06-30 14:01               ` visual-line-mode Chong Yidong
2008-06-30 16:10                 ` visual-line-mode Chong Yidong
2008-07-01  9:10               ` visual-line-mode David Reitter
2008-07-03 19:20           ` Chong Yidong [this message]
2008-07-03 23:56             ` visual-line-mode David Reitter
2008-07-04 10:23               ` visual-line-mode Chong Yidong
2008-07-04 10:58                 ` visual-line-mode Miles Bader
2008-07-04 13:04                   ` visual-line-mode Chong Yidong
2008-07-04 15:04                     ` visual-line-mode David Reitter
2008-07-04 15:49                       ` visual-line-mode Stefan Monnier
2008-07-04 16:21                         ` visual-line-mode David Reitter
2008-07-05 18:41                       ` visual-line-mode Chong Yidong
2008-07-06  1:29                         ` visual-line-mode Miles Bader
2008-07-09 14:28                         ` visual-line-mode David Reitter
2008-07-10  3:05                           ` visual-line-mode Chong Yidong
2008-07-10 12:39                             ` visual-line-mode David Reitter
2008-07-10 13:55                               ` visual-line-mode Chong Yidong
2008-08-03 13:47                                 ` visual-line-mode David Reitter
2008-08-11 13:38                                   ` word-wrap in echo area (was Re: visual-line-mode) David Reitter
2008-08-11 16:03                                     ` word-wrap in echo area Chong Yidong
2008-07-10 16:37                               ` visual-line-mode Chong Yidong
2008-07-10 17:32                                 ` visual-line-mode Miles Bader
2008-07-10 17:40                                   ` visual-line-mode Miles Bader
2008-07-10 20:23                                   ` visual-line-mode Stefan Monnier
2008-07-10 23:23                                     ` visual-line-mode Chong Yidong
2008-07-10 23:44                                       ` visual-line-mode Miles Bader
2008-07-10 23:49                                         ` visual-line-mode Chong Yidong
2008-07-11 13:10                                         ` visual-line-mode David Reitter
2008-07-14  3:58                                           ` visual-line-mode Miles Bader
2008-07-14  3:59                                             ` visual-line-mode Miles Bader
2008-07-11  1:36                                       ` visual-line-mode Stefan Monnier
2008-07-11  2:30                                         ` visual-line-mode Miles Bader
2008-07-11  4:36                                         ` visual-line-mode Chong Yidong
2008-07-11 14:56                                           ` visual-line-mode David Reitter
2008-07-11 15:57                                             ` visual-line-mode Chong Yidong
2008-07-11 18:27                                               ` visual-line-mode Chong Yidong
2008-07-11 20:36                                             ` visual-line-mode Miles Bader
2008-07-11 21:18                                               ` visual-line-mode Stefan Monnier
2008-07-11 21:23                                                 ` visual-line-mode David Kastrup
2008-07-11 21:41                                                   ` visual-line-mode David Reitter
2008-07-12  1:49                                                   ` visual-line-mode Stefan Monnier
2008-07-12  8:09                                                     ` visual-line-mode David Kastrup
2008-07-12 16:35                                                       ` visual-line-mode Richard M Stallman
2008-07-12 17:42                                                         ` visual-line-mode Chong Yidong
2008-07-16  4:21                                                     ` visual-line-mode Chong Yidong
2008-07-16  4:37                                                       ` visual-line-mode Miles Bader
2008-07-11 21:10                                     ` visual-line-mode Chong Yidong
2008-07-12  1:43                                       ` visual-line-mode Stefan Monnier
2008-07-10 18:08                                 ` visual-line-mode David Reitter
2008-07-10 23:18                                   ` visual-line-mode Miles Bader
2008-07-10 23:35                                     ` visual-line-mode Chong Yidong
2008-07-10 23:49                               ` visual-line-mode Chong Yidong
2008-07-09 14:31                         ` visual-line-mode David Reitter
2008-07-04 11:09                 ` visual-line-mode David Reitter
2008-07-04 12:39                   ` visual-line-mode Paul R
2008-06-30  7:32   ` visual-line-mode David Reitter
2008-06-30  7:43     ` visual-line-mode Miles Bader
2008-06-30  7:58       ` visual-line-mode David Reitter
2008-06-30  8:05         ` visual-line-mode Miles Bader
2008-06-30  8:25           ` visual-line-mode David Reitter
2008-06-30  8:30             ` visual-line-mode Miles Bader
2008-07-10  4:53 ` visual-line-mode 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87skuqbwr8.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=david.reitter@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).