diff options
| author | Stefan Monnier | 2018-03-23 11:29:06 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-06-03 12:48:14 -0400 |
| commit | ed962f2b8a2f63c7dbf31ec5df3c915703dd571d (patch) | |
| tree | 880aa4dab830e5e7699e6eace5c0a1097a091baa /test | |
| parent | 3ba5fc2bbec3f0f64c7afc1b05c9016710805463 (diff) | |
| download | emacs-ed962f2b8a2f63c7dbf31ec5df3c915703dd571d.tar.gz emacs-ed962f2b8a2f63c7dbf31ec5df3c915703dd571d.zip | |
Fix bug#30846, along with misc cleanups found along the way
* test/src/data-tests.el (data-tests-kill-all-local-variables): New test.
* src/buffer.c (swap_out_buffer_local_variables): Remove.
Fuse the body of its loop into that of reset_buffer_local_variables.
(Fkill_buffer, Fkill_all_local_variables): Don't call it any more.
(reset_buffer_local_variables): Make sure the buffer's local binding
is swapped out before removing it from the alist (bug#30846).
Call watchers before actually killing the var.
* src/data.c (Fmake_local_variable): Simplify.
Use swap_in_global_binding to swap out any local binding, instead of
a mix of find_symbol_value followed by messing with where&found.
Don't call swap_in_symval_forwarding since the currently swapped
binding is never one we've modified.
(Fkill_local_variable): Use swap_in_global_binding rather than messing
with where&found to try and trick find_symbol_value into doing the same.
* src/alloc.c (mark_localized_symbol): 'where' can't be a frame any more.
(cherry picked from commit 3ddff080341580eb6fc18d907181e9cc2301f62d)
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/data-tests.el | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index dda1278b6d4..91463db113c 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; data-tests.el --- tests for src/data.c | 1 | ;;; data-tests.el --- tests for src/data.c -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2013-2018 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2013-2018 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -484,3 +484,20 @@ comparing the subr with a much slower lisp implementation." | |||
| 484 | (remove-variable-watcher 'data-tests-lvar collect-watch-data) | 484 | (remove-variable-watcher 'data-tests-lvar collect-watch-data) |
| 485 | (setq data-tests-lvar 6) | 485 | (setq data-tests-lvar 6) |
| 486 | (should (null watch-data))))) | 486 | (should (null watch-data))))) |
| 487 | |||
| 488 | (ert-deftest data-tests-kill-all-local-variables () ;bug#30846 | ||
| 489 | (with-temp-buffer | ||
| 490 | (setq-local data-tests-foo1 1) | ||
| 491 | (setq-local data-tests-foo2 2) | ||
| 492 | (setq-local data-tests-foo3 3) | ||
| 493 | (let ((oldfoo2 nil)) | ||
| 494 | (add-variable-watcher 'data-tests-foo2 | ||
| 495 | (lambda (&rest _) | ||
| 496 | (setq oldfoo2 (bound-and-true-p data-tests-foo2)))) | ||
| 497 | (kill-all-local-variables) | ||
| 498 | (should (equal oldfoo2 '2)) ;Watcher is run before changing the var. | ||
| 499 | (should (not (or (bound-and-true-p data-tests-foo1) | ||
| 500 | (bound-and-true-p data-tests-foo2) | ||
| 501 | (bound-and-true-p data-tests-foo3))))))) | ||
| 502 | |||
| 503 | ;;; data-tests.el ends here | ||