aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-05-31 07:38:44 +0000
committerRichard M. Stallman1997-05-31 07:38:44 +0000
commita7fa233fe7cdaf7ae15973ecc3c93286af093ea4 (patch)
tree6eb9157021062f5dd94a859d399c2df658648201
parent06b296ce1f5ebdb2372dd25469bc874273f9b3cf (diff)
downloademacs-a7fa233fe7cdaf7ae15973ecc3c93286af093ea4.tar.gz
emacs-a7fa233fe7cdaf7ae15973ecc3c93286af093ea4.zip
(move_if_not_intangible): New function.
-rw-r--r--src/intervals.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/intervals.c b/src/intervals.c
index e93c2b495a5..ce2adc375f3 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1853,6 +1853,62 @@ temp_set_point (position, buffer)
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
1859void
1860move_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. */