[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 6a182658a53 3/7: Add obarray-clear and use it
From: |
Mattias Engdegård |
Subject: |
master 6a182658a53 3/7: Add obarray-clear and use it |
Date: |
Fri, 23 Feb 2024 07:16:11 -0500 (EST) |
branch: master
commit 6a182658a533acab94d8fa0aec3e2b7a4f7d6a93
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Add obarray-clear and use it
* lisp/obarray.el (obarray-clear): New.
* lisp/abbrev.el (clear-abbrev-table):
* lisp/vc/vc.el (vc-clear-context): Use it instead of assuming the
obarray is a vector that can be 0-filled.
* test/lisp/obarray-tests.el (obarray-clear): New test.
---
lisp/abbrev.el | 3 +--
lisp/obarray.el | 5 +++++
lisp/vc/vc.el | 2 +-
test/lisp/obarray-tests.el | 10 ++++++++++
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index b523977fed5..188eeb720c0 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -602,8 +602,7 @@ It is nil if the abbrev has already been unexpanded.")
"Undefine all abbrevs in abbrev table TABLE, leaving TABLE empty."
(setq abbrevs-changed t)
(let* ((sym (obarray-get table "")))
- (dotimes (i (length table))
- (aset table i 0))
+ (obarray-clear table)
;; Preserve the table's properties.
(cl-assert sym)
(let ((newsym (obarray-put table "")))
diff --git a/lisp/obarray.el b/lisp/obarray.el
index a26992df8e2..e1ebb2ade51 100644
--- a/lisp/obarray.el
+++ b/lisp/obarray.el
@@ -66,5 +66,10 @@ Return t on success, nil otherwise."
"Call function FN on every symbol in obarray OB and return nil."
(mapatoms fn ob))
+(defun obarray-clear (ob)
+ "Remove all symbols from obarray OB."
+ ;; FIXME: This doesn't change the symbols to uninterned status.
+ (fillarray ob 0))
+
(provide 'obarray)
;;; obarray.el ends here
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 619b469bebb..3cd17276fa4 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -935,7 +935,7 @@ is sensitive to blank lines."
(defun vc-clear-context ()
"Clear all cached file properties."
(interactive)
- (fillarray vc-file-prop-obarray 0))
+ (obarray-clear vc-file-prop-obarray))
(defmacro with-vc-properties (files form settings)
"Execute FORM, then maybe set per-file properties for FILES.
diff --git a/test/lisp/obarray-tests.el b/test/lisp/obarray-tests.el
index dd8f1c8abd4..dd40d0f4d76 100644
--- a/test/lisp/obarray-tests.el
+++ b/test/lisp/obarray-tests.el
@@ -89,5 +89,15 @@
(obarray-map collect-names table)
(should (equal (sort syms #'string<) '("a" "b" "c")))))
+(ert-deftest obarray-clear ()
+ (let ((o (obarray-make)))
+ (intern "a" o)
+ (intern "b" o)
+ (intern "c" o)
+ (obarray-clear o)
+ (let ((n 0))
+ (mapatoms (lambda (_) (setq n (1+ n))) o)
+ (should (equal n 0)))))
+
(provide 'obarray-tests)
;;; obarray-tests.el ends here
- master updated (32843c7b36b -> a8f167547bc), Mattias Engdegård, 2024/02/23
- master 462d8ba813e 4/7: Add a proper type for obarrays, Mattias Engdegård, 2024/02/23
- master aa82fe99318 1/7: Use obarray-make instead of make-vector to create obarrays, Mattias Engdegård, 2024/02/23
- master 6803b70c197 6/7: Update NEWS and manual after obarray changes, Mattias Engdegård, 2024/02/23
- master 3beaa3131e7 2/7: Use obarrayp, not vectorp, to detect obarrays, Mattias Engdegård, 2024/02/23
- master 6a182658a53 3/7: Add obarray-clear and use it,
Mattias Engdegård <=
- master a8f167547bc 7/7: Replace use of obsolete eshell-kill-output in test, Mattias Engdegård, 2024/02/23
- master 3ea77c735de 5/7: Use the new obarray type for the initial obarray, Mattias Engdegård, 2024/02/23