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: Mon, 04 Mar 2002 20:40:48 -0500 Message-ID: <200203050140.g251em831456@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.g24Nffq00590@aztec.santafe.edu> NNTP-Posting-Host: quimby2.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: quimby2.netfonds.no 1015292921 28681 195.204.10.66 (5 Mar 2002 01:48:41 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 5 Mar 2002 01:48:41 GMT Cc: monnier+gnu/emacs@rum.cs.yale.edu, emacs-devel@gnu.org Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16i44G-0007SV-00 for ; Tue, 05 Mar 2002 02:48:40 +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 16i3xt-0001cI-00; Mon, 04 Mar 2002 20:42:05 -0500 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16i3wf-0001Yc-00; Mon, 04 Mar 2002 20:40:49 -0500 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g251em831456; Mon, 4 Mar 2002 20:40:48 -0500 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Richard Stallman 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:1731 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1731 > > Also, as David Kastrup has mentioned repeatedly, intangible text tends > > to break lots of things... > > > > I don't think so. > > Please, Richard, try to remember the lengthy discussion we've had about that. > > You seem to agree with my conclusion: > > In practice, it's generally a non-issue because most uses of intangible > text are restricted to a particular context so that this intangible > text is only accessed by a small body of elisp code. As for the patch to adjust_point_for_property, it not only suffers from the minor problem you mentioned but from the fact that adjust_point_for_property currently does not take overlays into account, which makes it useless for outline-style invisible text. See the attached patch. It's rather ugly and I'm not convinced it works 100%, although superficial tests show it does work at least in simple cases (but with overlapping overlays and text properties, it's less sure). The code's logic is fairly intricate because it tries (just like the original code) to avoid redundant work (such as checking the `composition' property even tho we haven't moved since last time we checked it). Maybe I shouldn't be trying so hard ? 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 01:36:36 -0000 *************** *** 1741,1748 **** /* 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) --- 1741,1817 ---- /* 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 int ! get_property_overlay_and_range (posn, prop, val, start, end) ! int posn; ! Lisp_Object prop, *val; ! int *start, *end; ! { ! int noverlays; ! Lisp_Object *overlay_vec, tem; ! int next_overlay; ! int len; ! ! /* First try with room for 40 overlays. */ ! len = 40; ! overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); ! ! noverlays = overlays_at (posn, 0, &overlay_vec, &len, ! &next_overlay, NULL, 0); ! ! /* If there are more than 40, ! make enough space for all, and try again. */ ! if (noverlays > len) ! { ! len = noverlays; ! overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); ! noverlays = overlays_at (posn, 0, &overlay_vec, &len, ! &next_overlay, NULL, 0); ! } ! noverlays = sort_overlays (overlay_vec, noverlays, NULL); ! ! /* Now check the overlays in order of decreasing priority. */ ! while (--noverlays >= 0) ! { ! tem = Foverlay_get (overlay_vec[noverlays], prop); ! if (!NILP (tem)) ! { ! /* Return the overlay we got the property from. */ ! *val = tem; ! *start = XINT (Foverlay_start (overlay_vec[noverlays])); ! *end = XINT (Foverlay_end (overlay_vec[noverlays])); ! return 1; ! } ! } ! return 0; ! } static void adjust_point_for_property (last_pt) *************** *** 1750,1788 **** { 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. */ --- 1819,1853 ---- { int start, end; Lisp_Object val; ! 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 ! && get_property_overlay_and_range (PT, proptable[i].prop, ! &val, &start, &end, Qnil) ! && (textprop = 1)) ! || (textprop ! && (textprop = 0, ! get_property_and_range (PT, proptable[i].prop, ! &val, &start, &end, Qnil)))) ! && proptable[i].pred (start, end, val) && start < PT && end > PT && (last_pt <= start || last_pt >= end)) { ! SET_PT (PT < last_pt ? start : end); ! 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