branch: externals/compat
commit 0b4f2eafa49bff012adfe0178a366a2780b653a8
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    compat-30: Add obarray-clear
---
 NEWS.org        |  1 +
 compat-30.el    |  6 ++++++
 compat-tests.el | 13 +++++++++++++
 compat.texi     |  5 +++++
 4 files changed, 25 insertions(+)

diff --git a/NEWS.org b/NEWS.org
index 58ba37abed..5520cf13b4 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -4,6 +4,7 @@
 
 * Development
 
+- compat-30: New function =obarray-clear=.
 - compat-30: New function =interpreted-function-p=.
 - compat-30: New function =primitive-function-p=.
 - compat-30: New function =closurep=.
diff --git a/compat-30.el b/compat-30.el
index 570ba46d1e..81b8fefc8d 100644
--- a/compat-30.el
+++ b/compat-30.el
@@ -27,6 +27,12 @@
 ;; TODO Update to 30.1 as soon as the Emacs emacs-30 branch version bumped
 (compat-version "30.0.50")
 
+;;;; Defined in lread.c
+
+(compat-defun obarray-clear (ob) ;; <compat-tests:obarray>
+  "Remove all symbols from obarray OB."
+  (fillarray ob 0))
+
 ;;;; Defined in buffer.c
 
 (compat-defun find-buffer (variable value) ;; <compat-tests:find-buffer>
diff --git a/compat-tests.el b/compat-tests.el
index ece115c2d7..ec6f95ed73 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1005,6 +1005,19 @@
       (should-equal compat-tests--local 2)
       (should-not (boundp 'compat-tests--unexist)))))
 
+(ert-deftest compat-obarray-clear ()
+  ;; obarray APIs are only available since 26
+  (static-if (> emacs-major-version 25)
+      (progn
+        (let ((ob (obarray-make)))
+          (should-not (obarray-get ob "sym1"))
+          (should (intern "sym1" ob))
+          (should (obarray-get ob "sym1"))
+          (obarray-clear ob)
+          (should-not (obarray-get ob "sym1"))
+          (should (intern "sym2" ob))
+          (should (obarray-get ob "sym2"))))))
+
 (ert-deftest compat-gensym ()
   (let ((orig gensym-counter))
     (should (integerp gensym-counter))
diff --git a/compat.texi b/compat.texi
index 381232c3fb..8d6dd5089a 100644
--- a/compat.texi
+++ b/compat.texi
@@ -3330,6 +3330,11 @@ older than 30.1.  Note that due to upstream changes, it 
might happen
 that there will be the need for changes, so use these functions with
 care.
 
+@c copied from lispref/symbols.texi
+@defun obarray-clear obarray
+This function removes all symbols from @var{obarray}.
+@end defun
+
 @c copied from lispref/functions.texi
 @defun closurep object
 This function returns @code{t} if @var{object} is a closure, which is

Reply via email to