From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: Should invisible imply intangible? Date: Tue, 05 Mar 2002 18:34:38 -0500 Message-ID: <200203052334.g25NYcY04427@rum.cs.yale.edu> References: <200202232019.g1NKJoG14638@aztec.santafe.edu> <200202250510.g1P5A3714156@rum.cs.yale.edu> <200202262013.g1QKDef16683@aztec.santafe.edu> <200203010130.g211UDG05790@rum.cs.yale.edu> <200203031440.g23EeN200619@aztec.santafe.edu> <200203031711.g23HBI623254@rum.cs.yale.edu> <200203042341.g24NfiH00596@aztec.santafe.edu> <200203052158.g25Lw7A01243@wijiji.santafe.edu> <200203052304.g25N4pI03908@rum.cs.yale.edu> NNTP-Posting-Host: quimby2.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: quimby2.netfonds.no 1015371886 17370 195.204.10.66 (5 Mar 2002 23:44:46 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 5 Mar 2002 23:44:46 GMT Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16iObt-0004W4-00 for ; Wed, 06 Mar 2002 00:44:45 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16iOTU-0006eA-00; Tue, 05 Mar 2002 18:36:04 -0500 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16iOSL-0006Zk-00 for ; Tue, 05 Mar 2002 18:34:53 -0500 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g25NYcY04427; Tue, 5 Mar 2002 18:34:38 -0500 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: quimby.gnus.org gmane.emacs.devel:1756 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1756 > > I wrote > > > > The change in adjust_point_for_property seems ok, and it might solve > > this problem. > > > > However, subsequently I realized it should be somewhat different. The > > buffer position just after the invisible text should be treated as > > part of the range where point cannot be. (This is how invisible, > > intangible text is handled now.) > > But that would make it very awkward for the user to insert text > immediately after the invisible area. > > If we still want to provide the illusion that the text really isn't > there at all, then we should treat either the buffer position > immediately before or immediately after as part of the intangible text, > depending on the direction of the motion (so that both positions > can still be reached "easily"). And here is a patch that does just that. Note that there are two (related) problems left: - when the text is replaced by an ellipsis, the cursor is always drawn after the ellipsis even if point is immediately *before* the invisible text. - I feel like this new "pretend the text isn't there at all" behavior works well for completely invisible text, but not for text with an elipsis where it makes sense for C-f or C-b to only skip over the hidden text rather than "the hidden text + 1". Of course, the second point would be even more relevant if the first point was addressed. Stefan Index: keyboard.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v retrieving revision 1.660 diff -u -u -b -r1.660 keyboard.c *** keyboard.c 4 Mar 2002 23:40:59 -0000 1.660 --- keyboard.c 5 Mar 2002 23:28:44 -0000 *************** *** 1741,1788 **** /* Adjust point to a boundary of a region that has such a property that should be treated intangible. For the moment, we check ! `composition' and `display' property. LAST_PT is the last position ! of point. */ static void adjust_point_for_property (last_pt) int last_pt; { int start, end; ! Lisp_Object val; ! int check_composition = 1, check_display = 1; ! while (check_composition || check_display) { ! if (check_composition ! && PT > BEGV && PT < ZV ! && get_property_and_range (PT, Qcomposition, &val, &start, &end, Qnil) ! && COMPOSITION_VALID_P (start, end, val) ! && start < PT && end > PT && (last_pt <= start || last_pt >= end)) { ! if (PT < last_pt) ! SET_PT (start); ! else ! SET_PT (end); ! check_display = 1; } - check_composition = 0; - if (check_display - && PT > BEGV && PT < ZV - && get_property_and_range (PT, Qdisplay, &val, &start, &end, Qnil) - && display_prop_intangible_p (val) - && start < PT && end > PT - && (last_pt <= start || last_pt >= end)) - { - if (PT < last_pt) - SET_PT (start); - else - SET_PT (end); - check_composition = 1; - } - check_display = 0; } } /* Subroutine for safe_run_hooks: run the hook HOOK. */ --- 1741,1814 ---- /* Adjust point to a boundary of a region that has such a property that should be treated intangible. For the moment, we check ! `composition', `display' and `invisible' properties. ! LAST_PT is the last position of point. */ ! ! static int ! adjust_composition_valid_p (start, end, val) ! int start, end; ! Lisp_Object val; ! { ! return COMPOSITION_VALID_P (start, end, val); ! } ! ! static int ! adjust_text_prop_means_invisible (start, end, val) ! int start, end; ! Lisp_Object val; ! { ! return TEXT_PROP_MEANS_INVISIBLE (val); ! } ! ! static int ! adjust_display_prop_intangible_p (start, end, val) ! int start, end; ! Lisp_Object val; ! { ! return display_prop_intangible_p (val); ! } static void adjust_point_for_property (last_pt) int last_pt; { int start, end; ! Lisp_Object val, overlay; ! struct { ! Lisp_Object prop; int (*pred) (int, int, Lisp_Object); int overlays; ! } proptable[] = ! { { Qcomposition, adjust_composition_valid_p, 0 }, ! { Qinvisible, adjust_text_prop_means_invisible, 1 }, ! { Qdisplay, adjust_display_prop_intangible_p, 1 } }; ! int i = 0, lastdone = 0; ! do { ! int textprop = 1; ! while (PT > BEGV && PT < ZV ! && ((proptable[i].overlays ! && (val = get_char_property_and_overlay (make_number (PT), ! proptable[i].prop, ! Qnil, &overlay), ! start = NILP (overlay) ! ? 0 : XINT (Foverlay_start (overlay)), ! end = NILP (overlay) ? 0 : XINT (Foverlay_end (overlay)), ! !NILP (val) && !NILP (overlay)) ! && (textprop = 1)) ! || (textprop ! && (textprop = 0, ! get_property_and_range (PT, proptable[i].prop, ! &val, &start, &end, Qnil)))) ! && proptable[i].pred (start, end, val) ! && (PT < last_pt ! ? (start <= PT && end > PT) : (start < PT && end >= PT)) && (last_pt <= start || last_pt >= end)) { ! SET_PT (PT < last_pt ? max (start - 1, BEGV) : min (end + 1, ZV)); ! lastdone = i; } } + while (lastdone != (i = (i + 1) % 3)); } /* Subroutine for safe_run_hooks: run the hook HOOK. */ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel