Mercurial > emacs
comparison src/buffer.c @ 8839:41981db9ad8e
(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.
| author | Karl Heuer <kwzh@gnu.org> |
|---|---|
| date | Sat, 17 Sep 1994 01:51:30 +0000 |
| parents | 0996472bb39d |
| children | b58ea8cae183 |
comparison
equal
deleted
inserted
replaced
| 8838:3f629c277e6b | 8839:41981db9ad8e |
|---|---|
| 137 | 137 |
| 138 Lisp_Object Qget_file_buffer; | 138 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; |
| 146 Lisp_Object Qinsert_behind_hooks; | 146 Lisp_Object Qinsert_behind_hooks; |
| 147 | 147 |
| 1831 error ("Marker points into wrong buffer"); | 1831 error ("Marker points into wrong buffer"); |
| 1832 | 1832 |
| 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 { |
| 1840 Lisp_Object temp; | 1841 Lisp_Object temp; |
| 1841 temp = beg; beg = end; end = temp; | 1842 temp = beg; beg = end; end = temp; |
| 1842 } | 1843 } |
| 1844 | |
| 1845 specbind (Qinhibit_quit, Qt); | |
| 1843 | 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); |
| 1847 | 1850 |
| 2116 "Set one property of overlay OVERLAY: give property PROP value VALUE.") | 2119 "Set one property of overlay OVERLAY: give property PROP value VALUE.") |
| 2117 (overlay, prop, value) | 2120 (overlay, prop, value) |
| 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 |
| 2124 buffer = Fmarker_buffer (OVERLAY_START (overlay)); | 2128 buffer = Fmarker_buffer (OVERLAY_START (overlay)); |
| 2125 | 2129 |
| 2128 for (tail = plist; | 2132 for (tail = plist; |
| 2129 CONSP (tail) && CONSP (XCONS (tail)->cdr); | 2133 CONSP (tail) && CONSP (XCONS (tail)->cdr); |
| 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 |
| 2157 /* Run the modification-hooks of overlays that include | 2161 /* Run the modification-hooks of overlays that include |
| 2158 any part of the text in START to END. | 2162 any part of the text in START to END. |
| 2293 call3 (Fcar (list), overlay, start, end); | 2297 call3 (Fcar (list), overlay, start, end); |
| 2294 list = Fcdr (list); | 2298 list = Fcdr (list); |
| 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. */ |
| 2301 void | 2344 void |
| 2302 buffer_slot_type_mismatch (valcontents, newval) | 2345 buffer_slot_type_mismatch (valcontents, newval) |
| 2478 staticpro (&Vbuffer_alist); | 2521 staticpro (&Vbuffer_alist); |
| 2479 staticpro (&Qprotected_field); | 2522 staticpro (&Qprotected_field); |
| 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); |
| 2486 Qinsert_in_front_hooks = intern ("insert-in-front-hooks"); | 2531 Qinsert_in_front_hooks = intern ("insert-in-front-hooks"); |
| 2487 staticpro (&Qinsert_behind_hooks); | 2532 staticpro (&Qinsert_behind_hooks); |
