comparison src/intervals.c @ 18076:1a2e6b512688

(move_if_not_intangible): New function.
author Richard M. Stallman <rms@gnu.org>
date Sat, 31 May 1997 07:38:44 +0000
parents c6ba5208968b
children cd5f9bda791e
comparison
equal deleted inserted replaced
18075:0e7d01cc4fa8 18076:1a2e6b512688
1851 struct buffer *buffer; 1851 struct buffer *buffer;
1852 { 1852 {
1853 BUF_PT (buffer) = position; 1853 BUF_PT (buffer) = position;
1854 } 1854 }
1855 1855
1856 /* Move point to POSITION, unless POSITION is inside an intangible
1857 segment that reaches all the way to point. */
1858
1859 void
1860 move_if_not_intangible (position)
1861 int position;
1862 {
1863 Lisp_Object pos;
1864 Lisp_Object intangible_propval;
1865
1866 XSETINT (pos, position);
1867
1868 if (! NILP (Vinhibit_point_motion_hooks))
1869 /* If intangible is inhibited, always move point to POSITION. */
1870 ;
1871 else if (PT < position)
1872 {
1873 /* We want to move forward, so check the text before POSITION. */
1874
1875 intangible_propval = Fget_char_property (pos,
1876 Qintangible, Qnil);
1877
1878 /* If following char is intangible,
1879 skip back over all chars with matching intangible property. */
1880 if (! NILP (intangible_propval))
1881 while (XINT (pos) > BEGV
1882 && EQ (Fget_char_property (make_number (XINT (pos) - 1),
1883 Qintangible, Qnil),
1884 intangible_propval))
1885 pos = Fprevious_char_property_change (pos, Qnil);
1886 }
1887 else
1888 {
1889 /* We want to move backward, so check the text after POSITION. */
1890
1891 intangible_propval = Fget_char_property (make_number (XINT (pos) - 1),
1892 Qintangible, Qnil);
1893
1894 /* If following char is intangible,
1895 skip back over all chars with matching intangible property. */
1896 if (! NILP (intangible_propval))
1897 while (XINT (pos) < ZV
1898 && EQ (Fget_char_property (pos, Qintangible, Qnil),
1899 intangible_propval))
1900 pos = Fnext_char_property_change (pos, Qnil);
1901
1902 }
1903
1904 /* If the whole stretch between PT and POSITION isn't intangible,
1905 try moving to POSITION (which means we actually move farther
1906 if POSITION is inside of intangible text). */
1907
1908 if (XINT (pos) != PT)
1909 SET_PT (position);
1910 }
1911
1856 /* Return the proper local map for position POSITION in BUFFER. 1912 /* Return the proper local map for position POSITION in BUFFER.
1857 Use the map specified by the local-map property, if any. 1913 Use the map specified by the local-map property, if any.
1858 Otherwise, use BUFFER's local map. */ 1914 Otherwise, use BUFFER's local map. */
1859 1915
1860 Lisp_Object 1916 Lisp_Object