diff options
| author | Karl Heuer | 1994-09-17 01:51:30 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-09-17 01:51:30 +0000 |
| commit | 9d7608b719ab073898414d20ffd87c0f2ea19706 (patch) | |
| tree | 735e7a1deec04d41759b6d02c563922a23d8e62b /src/buffer.c | |
| parent | 3a7cf11581608e09a3d41e44ebe51ba30714dad9 (diff) | |
| download | emacs-9d7608b719ab073898414d20ffd87c0f2ea19706.tar.gz emacs-9d7608b719ab073898414d20ffd87c0f2ea19706.zip | |
(Qevaporate): New symbol.
(syms_of_buffer): Initialize it.
(Fmove_overlay): Check if overlay is empty.
(Foverlay_put): Check if setting evaporate property on empty overlay.
(evaporate_overlays): New function.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 85 |
1 files changed, 65 insertions, 20 deletions
diff --git a/src/buffer.c b/src/buffer.c index 35177382dde..8ade7e82199 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -139,7 +139,7 @@ Lisp_Object Qget_file_buffer; | |||
| 139 | 139 | ||
| 140 | Lisp_Object Qoverlayp; | 140 | Lisp_Object Qoverlayp; |
| 141 | 141 | ||
| 142 | Lisp_Object Qpriority, Qwindow; | 142 | Lisp_Object Qpriority, Qwindow, Qevaporate; |
| 143 | 143 | ||
| 144 | Lisp_Object Qmodification_hooks; | 144 | Lisp_Object Qmodification_hooks; |
| 145 | Lisp_Object Qinsert_in_front_hooks; | 145 | Lisp_Object Qinsert_in_front_hooks; |
| @@ -1833,7 +1833,8 @@ buffer.") | |||
| 1833 | CHECK_NUMBER_COERCE_MARKER (beg, 1); | 1833 | CHECK_NUMBER_COERCE_MARKER (beg, 1); |
| 1834 | CHECK_NUMBER_COERCE_MARKER (end, 1); | 1834 | CHECK_NUMBER_COERCE_MARKER (end, 1); |
| 1835 | 1835 | ||
| 1836 | specbind (Qinhibit_quit, Qt); | 1836 | if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate))) |
| 1837 | return Fdelete_overlay (overlay); | ||
| 1837 | 1838 | ||
| 1838 | if (XINT (beg) > XINT (end)) | 1839 | if (XINT (beg) > XINT (end)) |
| 1839 | { | 1840 | { |
| @@ -1841,6 +1842,8 @@ buffer.") | |||
| 1841 | temp = beg; beg = end; end = temp; | 1842 | temp = beg; beg = end; end = temp; |
| 1842 | } | 1843 | } |
| 1843 | 1844 | ||
| 1845 | specbind (Qinhibit_quit, Qt); | ||
| 1846 | |||
| 1844 | obuffer = Fmarker_buffer (OVERLAY_START (overlay)); | 1847 | obuffer = Fmarker_buffer (OVERLAY_START (overlay)); |
| 1845 | b = XBUFFER (buffer); | 1848 | b = XBUFFER (buffer); |
| 1846 | ob = XBUFFER (obuffer); | 1849 | ob = XBUFFER (obuffer); |
| @@ -2118,6 +2121,7 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, | |||
| 2118 | Lisp_Object overlay, prop, value; | 2121 | Lisp_Object overlay, prop, value; |
| 2119 | { | 2122 | { |
| 2120 | Lisp_Object plist, tail, buffer; | 2123 | Lisp_Object plist, tail, buffer; |
| 2124 | int changed; | ||
| 2121 | 2125 | ||
| 2122 | CHECK_OVERLAY (overlay, 0); | 2126 | CHECK_OVERLAY (overlay, 0); |
| 2123 | 2127 | ||
| @@ -2130,27 +2134,27 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, | |||
| 2130 | tail = XCONS (XCONS (tail)->cdr)->cdr) | 2134 | tail = XCONS (XCONS (tail)->cdr)->cdr) |
| 2131 | if (EQ (XCONS (tail)->car, prop)) | 2135 | if (EQ (XCONS (tail)->car, prop)) |
| 2132 | { | 2136 | { |
| 2133 | /* If actually changing the property, mark redisplay needed. */ | 2137 | changed = !EQ (XCONS (XCONS (tail)->cdr)->car, value); |
| 2134 | if (! NILP (buffer) && !EQ (XCONS (XCONS (tail)->cdr)->car, value)) | 2138 | XCONS (XCONS (tail)->cdr)->car = value; |
| 2135 | redisplay_region (XBUFFER (buffer), | 2139 | goto found; |
| 2136 | marker_position (OVERLAY_START (overlay)), | ||
| 2137 | marker_position (OVERLAY_END (overlay))); | ||
| 2138 | |||
| 2139 | return XCONS (XCONS (tail)->cdr)->car = value; | ||
| 2140 | } | 2140 | } |
| 2141 | 2141 | /* It wasn't in the list, so add it to the front. */ | |
| 2142 | /* Actually changing the property; mark redisplay needed. */ | 2142 | changed = !NILP (value); |
| 2143 | if (! NILP (buffer)) | ||
| 2144 | redisplay_region (XBUFFER (buffer), | ||
| 2145 | marker_position (OVERLAY_START (overlay)), | ||
| 2146 | marker_position (OVERLAY_END (overlay))); | ||
| 2147 | |||
| 2148 | if (! CONSP (XCONS (overlay)->cdr)) | 2143 | if (! CONSP (XCONS (overlay)->cdr)) |
| 2149 | XCONS (overlay)->cdr = Fcons (Qnil, Qnil); | 2144 | XCONS (overlay)->cdr = Fcons (Qnil, Qnil); |
| 2150 | 2145 | XCONS (XCONS (overlay)->cdr)->cdr = Fcons (prop, Fcons (value, plist)); | |
| 2151 | XCONS (XCONS (overlay)->cdr)->cdr | 2146 | found: |
| 2152 | = Fcons (prop, Fcons (value, plist)); | 2147 | if (! NILP (buffer)) |
| 2153 | 2148 | { | |
| 2149 | if (changed) | ||
| 2150 | redisplay_region (XBUFFER (buffer), | ||
| 2151 | marker_position (OVERLAY_START (overlay)), | ||
| 2152 | marker_position (OVERLAY_END (overlay))); | ||
| 2153 | if (EQ (prop, Qevaporate) && ! NILP (value) | ||
| 2154 | && (OVERLAY_POSITION (OVERLAY_START (overlay)) | ||
| 2155 | == OVERLAY_POSITION (OVERLAY_END (overlay)))) | ||
| 2156 | Fdelete_overlay (overlay); | ||
| 2157 | } | ||
| 2154 | return value; | 2158 | return value; |
| 2155 | } | 2159 | } |
| 2156 | 2160 | ||
| @@ -2295,6 +2299,45 @@ call_overlay_mod_hooks (list, overlay, start, end) | |||
| 2295 | } | 2299 | } |
| 2296 | UNGCPRO; | 2300 | UNGCPRO; |
| 2297 | } | 2301 | } |
| 2302 | |||
| 2303 | /* Delete any zero-sized overlays at position POS, if the `evaporate' | ||
| 2304 | property is set. */ | ||
| 2305 | void | ||
| 2306 | evaporate_overlays (pos) | ||
| 2307 | int pos; | ||
| 2308 | { | ||
| 2309 | Lisp_Object tail, overlay, hit_list; | ||
| 2310 | |||
| 2311 | hit_list = Qnil; | ||
| 2312 | if (pos <= XFASTINT (current_buffer->overlay_center)) | ||
| 2313 | for (tail = current_buffer->overlays_before; CONSP (tail); | ||
| 2314 | tail = XCONS (tail)->cdr) | ||
| 2315 | { | ||
| 2316 | int endpos; | ||
| 2317 | overlay = XCONS (tail)->car; | ||
| 2318 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | ||
| 2319 | if (endpos < pos) | ||
| 2320 | break; | ||
| 2321 | if (endpos == pos && OVERLAY_POSITION (OVERLAY_START (overlay)) == pos | ||
| 2322 | && Foverlay_get (overlay, Qevaporate)) | ||
| 2323 | hit_list = Fcons (overlay, hit_list); | ||
| 2324 | } | ||
| 2325 | else | ||
| 2326 | for (tail = current_buffer->overlays_after; CONSP (tail); | ||
| 2327 | tail = XCONS (tail)->cdr) | ||
| 2328 | { | ||
| 2329 | int startpos; | ||
| 2330 | overlay = XCONS (tail)->cdr; | ||
| 2331 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | ||
| 2332 | if (startpos > pos) | ||
| 2333 | break; | ||
| 2334 | if (startpos == pos && OVERLAY_POSITION (OVERLAY_END (overlay)) == pos | ||
| 2335 | && Foverlay_get (overlay, Qevaporate)) | ||
| 2336 | hit_list = Fcons (overlay, hit_list); | ||
| 2337 | } | ||
| 2338 | for (; CONSP (hit_list); hit_list = XCONS (hit_list)->cdr) | ||
| 2339 | Fdelete_overlay (XCONS (hit_list)->car); | ||
| 2340 | } | ||
| 2298 | 2341 | ||
| 2299 | /* Somebody has tried to store NEWVAL into the buffer-local slot with | 2342 | /* Somebody has tried to store NEWVAL into the buffer-local slot with |
| 2300 | offset XUINT (valcontents), and NEWVAL has an unacceptable type. */ | 2343 | offset XUINT (valcontents), and NEWVAL has an unacceptable type. */ |
| @@ -2480,6 +2523,8 @@ syms_of_buffer () | |||
| 2480 | staticpro (&Qpermanent_local); | 2523 | staticpro (&Qpermanent_local); |
| 2481 | staticpro (&Qkill_buffer_hook); | 2524 | staticpro (&Qkill_buffer_hook); |
| 2482 | staticpro (&Qoverlayp); | 2525 | staticpro (&Qoverlayp); |
| 2526 | Qevaporate = intern ("evaporate"); | ||
| 2527 | staticpro (&Qevaporate); | ||
| 2483 | staticpro (&Qmodification_hooks); | 2528 | staticpro (&Qmodification_hooks); |
| 2484 | Qmodification_hooks = intern ("modification-hooks"); | 2529 | Qmodification_hooks = intern ("modification-hooks"); |
| 2485 | staticpro (&Qinsert_in_front_hooks); | 2530 | staticpro (&Qinsert_in_front_hooks); |