diff options
| author | Richard M. Stallman | 1995-04-06 06:58:50 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-04-06 06:58:50 +0000 |
| commit | 2f3f993bdf26e374627d311309086acc3418385a (patch) | |
| tree | 49ff79c20a75e65f6005aaef0aacce35aa09800a /src/buffer.c | |
| parent | 94f949720320da01fd4a04bc74f0fb1bfabc9600 (diff) | |
| download | emacs-2f3f993bdf26e374627d311309086acc3418385a.tar.gz emacs-2f3f993bdf26e374627d311309086acc3418385a.zip | |
(Fkill_buffer): Call reset_buffer_local_variables
and swap_out_buffer_local_variables.
(swap_out_buffer_local_variables): New subroutine.
(Fkill_all_local_variables): Use that subroutine.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 83 |
1 files changed, 53 insertions, 30 deletions
diff --git a/src/buffer.c b/src/buffer.c index c8e949b6da3..34503939a3c 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -101,6 +101,7 @@ struct buffer buffer_local_types; | |||
| 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 | static void call_overlay_mod_hooks (); |
| 104 | static void swap_out_buffer_local_variables (); | ||
| 104 | 105 | ||
| 105 | /* Alist of all buffer names vs the buffers. */ | 106 | /* Alist of all buffer names vs the buffers. */ |
| 106 | /* This used to be a variable, but is no longer, | 107 | /* This used to be a variable, but is no longer, |
| @@ -1010,6 +1011,13 @@ with `delete-process'.") | |||
| 1010 | /* Perhaps we should explicitly free the interval tree here... */ | 1011 | /* Perhaps we should explicitly free the interval tree here... */ |
| 1011 | } | 1012 | } |
| 1012 | 1013 | ||
| 1014 | /* Reset the local variables, so that this buffer's local values | ||
| 1015 | won't be protected from GC. They would be protected | ||
| 1016 | if they happened to remain encached in their symbols. | ||
| 1017 | This gets rid of them for certain. */ | ||
| 1018 | swap_out_buffer_local_variables (b); | ||
| 1019 | reset_buffer_local_variables (b); | ||
| 1020 | |||
| 1013 | b->name = Qnil; | 1021 | b->name = Qnil; |
| 1014 | 1022 | ||
| 1015 | BLOCK_INPUT; | 1023 | BLOCK_INPUT; |
| @@ -1445,37 +1453,10 @@ the normal hook `change-major-mode-hook'.") | |||
| 1445 | call1 (Vrun_hooks, intern ("change-major-mode-hook")); | 1453 | call1 (Vrun_hooks, intern ("change-major-mode-hook")); |
| 1446 | oalist = current_buffer->local_var_alist; | 1454 | oalist = current_buffer->local_var_alist; |
| 1447 | 1455 | ||
| 1448 | /* Make sure no local variables remain set up with this buffer | 1456 | /* Make sure none of the bindings in oalist |
| 1449 | for their current values. */ | 1457 | remain swapped in, in their symbols. */ |
| 1450 | 1458 | ||
| 1451 | for (alist = oalist; !NILP (alist); alist = XCONS (alist)->cdr) | 1459 | swap_out_buffer_local_variables (current_buffer); |
| 1452 | { | ||
| 1453 | sym = XCONS (XCONS (alist)->car)->car; | ||
| 1454 | |||
| 1455 | /* Need not do anything if some other buffer's binding is now encached. */ | ||
| 1456 | tem = XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->car; | ||
| 1457 | if (XBUFFER (tem) == current_buffer) | ||
| 1458 | { | ||
| 1459 | /* Symbol is set up for this buffer's old local value. | ||
| 1460 | Set it up for the current buffer with the default value. */ | ||
| 1461 | |||
| 1462 | tem = XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->cdr; | ||
| 1463 | /* Store the symbol's current value into the alist entry | ||
| 1464 | it is currently set up for. This is so that, if the | ||
| 1465 | local is marked permanent, and we make it local again below, | ||
| 1466 | we don't lose the value. */ | ||
| 1467 | XCONS (XCONS (tem)->car)->cdr | ||
| 1468 | = do_symval_forwarding (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car); | ||
| 1469 | /* Switch to the symbol's default-value alist entry. */ | ||
| 1470 | XCONS (tem)->car = tem; | ||
| 1471 | /* Mark it as current for the current buffer. */ | ||
| 1472 | XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->car | ||
| 1473 | = Fcurrent_buffer (); | ||
| 1474 | /* Store the current value into any forwarding in the symbol. */ | ||
| 1475 | store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car, | ||
| 1476 | XCONS (tem)->cdr); | ||
| 1477 | } | ||
| 1478 | } | ||
| 1479 | 1460 | ||
| 1480 | /* Actually eliminate all local bindings of this buffer. */ | 1461 | /* Actually eliminate all local bindings of this buffer. */ |
| 1481 | 1462 | ||
| @@ -1505,6 +1486,48 @@ the normal hook `change-major-mode-hook'.") | |||
| 1505 | 1486 | ||
| 1506 | return Qnil; | 1487 | return Qnil; |
| 1507 | } | 1488 | } |
| 1489 | |||
| 1490 | /* Make sure no local variables remain set up with buffer B | ||
| 1491 | for their current values. */ | ||
| 1492 | |||
| 1493 | static void | ||
| 1494 | swap_out_buffer_local_variables (b) | ||
| 1495 | struct buffer *b; | ||
| 1496 | { | ||
| 1497 | Lisp_Object oalist, alist, sym, tem, buffer; | ||
| 1498 | |||
| 1499 | XSETBUFFER (buffer, b); | ||
| 1500 | oalist = b->local_var_alist; | ||
| 1501 | |||
| 1502 | for (alist = oalist; !NILP (alist); alist = XCONS (alist)->cdr) | ||
| 1503 | { | ||
| 1504 | sym = XCONS (XCONS (alist)->car)->car; | ||
| 1505 | |||
| 1506 | /* Need not do anything if some other buffer's binding is now encached. */ | ||
| 1507 | tem = XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->car; | ||
| 1508 | if (XBUFFER (tem) == current_buffer) | ||
| 1509 | { | ||
| 1510 | /* Symbol is set up for this buffer's old local value. | ||
| 1511 | Set it up for the current buffer with the default value. */ | ||
| 1512 | |||
| 1513 | tem = XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->cdr; | ||
| 1514 | /* Store the symbol's current value into the alist entry | ||
| 1515 | it is currently set up for. This is so that, if the | ||
| 1516 | local is marked permanent, and we make it local again | ||
| 1517 | later in Fkill_all_local_variables, we don't lose the value. */ | ||
| 1518 | XCONS (XCONS (tem)->car)->cdr | ||
| 1519 | = do_symval_forwarding (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car); | ||
| 1520 | /* Switch to the symbol's default-value alist entry. */ | ||
| 1521 | XCONS (tem)->car = tem; | ||
| 1522 | /* Mark it as current for buffer B. */ | ||
| 1523 | XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->car | ||
| 1524 | = buffer; | ||
| 1525 | /* Store the current value into any forwarding in the symbol. */ | ||
| 1526 | store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car, | ||
| 1527 | XCONS (tem)->cdr); | ||
| 1528 | } | ||
| 1529 | } | ||
| 1530 | } | ||
| 1508 | 1531 | ||
| 1509 | /* Find all the overlays in the current buffer that contain position POS. | 1532 | /* Find all the overlays in the current buffer that contain position POS. |
| 1510 | Return the number found, and store them in a vector in *VEC_PTR. | 1533 | Return the number found, and store them in a vector in *VEC_PTR. |