diff options
| author | Richard M. Stallman | 1993-07-13 21:05:26 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-13 21:05:26 +0000 |
| commit | 173f2a642c9013639212cbfe952d21719e423a81 (patch) | |
| tree | 90a2dd198f5a681b67faf29ce47ace3da088336b /src/buffer.c | |
| parent | f7a9275a0e5752cdfe367c63096775b98e9af831 (diff) | |
| download | emacs-173f2a642c9013639212cbfe952d21719e423a81.tar.gz emacs-173f2a642c9013639212cbfe952d21719e423a81.zip | |
(verify_overlay_modification): New function.
(call_overlay_mod_hooks): New function.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index 403d1ef22b0..ce07c2a21d3 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -100,6 +100,7 @@ struct buffer buffer_local_types; | |||
| 100 | 100 | ||
| 101 | Lisp_Object Fset_buffer (); | 101 | Lisp_Object Fset_buffer (); |
| 102 | void set_buffer_internal (); | 102 | void set_buffer_internal (); |
| 103 | static void call_overlay_mod_hooks (); | ||
| 103 | 104 | ||
| 104 | /* Alist of all buffer names vs the buffers. */ | 105 | /* Alist of all buffer names vs the buffers. */ |
| 105 | /* This used to be a variable, but is no longer, | 106 | /* This used to be a variable, but is no longer, |
| @@ -1868,6 +1869,100 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, | |||
| 1868 | return value; | 1869 | return value; |
| 1869 | } | 1870 | } |
| 1870 | 1871 | ||
| 1872 | /* Run the modification-hooks of overlays that include | ||
| 1873 | any part of the text in START to END. | ||
| 1874 | Run the insert-before-hooks of overlay starting at END, | ||
| 1875 | and the insert-after-hooks of overlay ending at START. */ | ||
| 1876 | |||
| 1877 | void | ||
| 1878 | verify_overlay_modification (start, end) | ||
| 1879 | Lisp_Object start, end; | ||
| 1880 | { | ||
| 1881 | Lisp_Object prop, overlay, tail; | ||
| 1882 | int insertion = EQ (start, end); | ||
| 1883 | |||
| 1884 | for (tail = current_buffer->overlays_before; | ||
| 1885 | CONSP (tail); | ||
| 1886 | tail = XCONS (tail)->cdr) | ||
| 1887 | { | ||
| 1888 | int startpos, endpos; | ||
| 1889 | int ostart, oend; | ||
| 1890 | |||
| 1891 | overlay = XCONS (tail)->car; | ||
| 1892 | |||
| 1893 | ostart = OVERLAY_START (overlay); | ||
| 1894 | oend = OVERLAY_END (overlay); | ||
| 1895 | endpos = OVERLAY_POSITION (oend); | ||
| 1896 | if (XFASTINT (start) > endpos) | ||
| 1897 | break; | ||
| 1898 | startpos = OVERLAY_POSITION (ostart); | ||
| 1899 | if (XFASTINT (end) == startpos && insertion) | ||
| 1900 | { | ||
| 1901 | prop = Foverlay_get (overlay, Qinsert_in_front_hooks); | ||
| 1902 | call_overlay_mod_hooks (prop, overlay, start, end); | ||
| 1903 | } | ||
| 1904 | if (XFASTINT (start) == endpos && insertion) | ||
| 1905 | { | ||
| 1906 | prop = Foverlay_get (overlay, Qinsert_behind_hooks); | ||
| 1907 | call_overlay_mod_hooks (prop, overlay, start, end); | ||
| 1908 | } | ||
| 1909 | if (insertion | ||
| 1910 | ? (XFASTINT (start) > startpos && XFASTINT (end) < endpos) | ||
| 1911 | : (XFASTINT (start) >= startpos && XFASTINT (end) <= endpos)) | ||
| 1912 | { | ||
| 1913 | prop = Foverlay_get (overlay, Qmodification_hooks); | ||
| 1914 | call_overlay_mod_hooks (prop, overlay, start, end); | ||
| 1915 | } | ||
| 1916 | } | ||
| 1917 | |||
| 1918 | for (tail = current_buffer->overlays_after; | ||
| 1919 | CONSP (tail); | ||
| 1920 | tail = XCONS (tail)->cdr) | ||
| 1921 | { | ||
| 1922 | int startpos, endpos; | ||
| 1923 | int ostart, oend; | ||
| 1924 | |||
| 1925 | overlay = XCONS (tail)->car; | ||
| 1926 | |||
| 1927 | ostart = OVERLAY_START (overlay); | ||
| 1928 | oend = OVERLAY_END (overlay); | ||
| 1929 | startpos = OVERLAY_POSITION (ostart); | ||
| 1930 | if (XFASTINT (end) < startpos) | ||
| 1931 | break; | ||
| 1932 | if (XFASTINT (end) == startpos && insertion) | ||
| 1933 | { | ||
| 1934 | prop = Foverlay_get (overlay, Qinsert_in_front_hooks); | ||
| 1935 | call_overlay_mod_hooks (prop, overlay, start, end); | ||
| 1936 | } | ||
| 1937 | if (XFASTINT (start) == endpos && insertion) | ||
| 1938 | { | ||
| 1939 | prop = Foverlay_get (overlay, Qinsert_behind_hooks); | ||
| 1940 | call_overlay_mod_hooks (prop, overlay, start, end); | ||
| 1941 | } | ||
| 1942 | if (insertion | ||
| 1943 | ? (XFASTINT (start) > startpos && XFASTINT (end) < endpos) | ||
| 1944 | : (XFASTINT (start) >= startpos && XFASTINT (end) <= endpos)) | ||
| 1945 | { | ||
| 1946 | prop = Foverlay_get (overlay, Qmodification_hooks); | ||
| 1947 | call_overlay_mod_hooks (prop, overlay, start, end); | ||
| 1948 | } | ||
| 1949 | } | ||
| 1950 | } | ||
| 1951 | |||
| 1952 | static void | ||
| 1953 | call_overlay_mod_hooks (list, overlay, start, end) | ||
| 1954 | Lisp_Object list, overlay, start, end; | ||
| 1955 | { | ||
| 1956 | struct gcpro gcpro1; | ||
| 1957 | GCPRO1 (list); | ||
| 1958 | while (!NILP (list)) | ||
| 1959 | { | ||
| 1960 | call3 (Fcar (list), overlay, start, end); | ||
| 1961 | list = Fcdr (list); | ||
| 1962 | } | ||
| 1963 | UNGCPRO; | ||
| 1964 | } | ||
| 1965 | |||
| 1871 | /* Somebody has tried to store NEWVAL into the buffer-local slot with | 1966 | /* Somebody has tried to store NEWVAL into the buffer-local slot with |
| 1872 | offset XUINT (valcontents), and NEWVAL has an unacceptable type. */ | 1967 | offset XUINT (valcontents), and NEWVAL has an unacceptable type. */ |
| 1873 | void | 1968 | void |