From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: visual-line-mode Date: Fri, 04 Jul 2008 09:04:53 -0400 Message-ID: <87abgxx0ju.fsf@stupidchicken.com> References: <87zlp4raab.fsf@catnip.gol.com> <87d4lzehq2.fsf@stupidchicken.com> <87skuqbwr8.fsf@stupidchicken.com> <85E9BC5B-7337-4CD4-A783-6B2FAEBAEBCA@gmail.com> <87tzf6c5il.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215176768 23083 80.91.229.12 (4 Jul 2008 13:06:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Jul 2008 13:06:08 +0000 (UTC) Cc: David Reitter , "Lennart Borgman \(gmail\)" , Stefan Monnier , Emacs-Devel devel To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 04 15:06:53 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KEkz8-0006wA-FM for ged-emacs-devel@m.gmane.org; Fri, 04 Jul 2008 15:05:58 +0200 Original-Received: from localhost ([127.0.0.1]:35317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KEkyH-000322-JT for ged-emacs-devel@m.gmane.org; Fri, 04 Jul 2008 09:05:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KEkyB-0002yf-47 for emacs-devel@gnu.org; Fri, 04 Jul 2008 09:04:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KEkyA-0002xg-CW for emacs-devel@gnu.org; Fri, 04 Jul 2008 09:04:58 -0400 Original-Received: from [199.232.76.173] (port=35301 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KEkyA-0002xW-A3 for emacs-devel@gnu.org; Fri, 04 Jul 2008 09:04:58 -0400 Original-Received: from c-24-63-201-57.hsd1.ma.comcast.net ([24.63.201.57]:16197 helo=furry) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KEky6-0000DH-2N; Fri, 04 Jul 2008 09:04:54 -0400 Original-Received: by furry (Postfix, from userid 1000) id 9416C16DC02; Fri, 4 Jul 2008 09:04:53 -0400 (EDT) In-Reply-To: (Miles Bader's message of "Fri, 04 Jul 2008 19:58:08 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100342 Archived-At: Okay, how about this amended patch? *** trunk/src/xdisp.c.~1.1227.~ 2008-07-04 06:35:40.000000000 -0400 --- trunk/src/xdisp.c 2008-07-04 09:02:58.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,6861 ---- /* 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; ! atpos_it.current_x = x; ! } } ! 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; --- 6865,6879 ---- /* 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 **** --- 6930,6936 ---- { *it = wrap_it; atpos_it.sp = -1; + atx_it.sp = -1; } TRACE_MOVE ((stderr, "move_it_in: continued at %d\n", *************** *** 6918,6924 **** if (wrap_it.sp < 0) goto buffer_pos_reached; if (atpos_it.sp < 0) ! atpos_it = *it; } else goto buffer_pos_reached; --- 6946,6955 ---- if (wrap_it.sp < 0) goto buffer_pos_reached; if (atpos_it.sp < 0) ! { ! atpos_it = *it; ! atpos_it.current_x = x; ! } } else goto buffer_pos_reached; *************** *** 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. */ --- 7026,7038 ---- #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; } } --- 16657,16673 ---- } } #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; } }