mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-24 07:20:37 +00:00
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.
This commit is contained in:
parent
3beaa3131e
commit
6a182658a5
@ -602,8 +602,7 @@ It is nil if the abbrev has already been unexpanded.")
|
|||||||
"Undefine all abbrevs in abbrev table TABLE, leaving TABLE empty."
|
"Undefine all abbrevs in abbrev table TABLE, leaving TABLE empty."
|
||||||
(setq abbrevs-changed t)
|
(setq abbrevs-changed t)
|
||||||
(let* ((sym (obarray-get table "")))
|
(let* ((sym (obarray-get table "")))
|
||||||
(dotimes (i (length table))
|
(obarray-clear table)
|
||||||
(aset table i 0))
|
|
||||||
;; Preserve the table's properties.
|
;; Preserve the table's properties.
|
||||||
(cl-assert sym)
|
(cl-assert sym)
|
||||||
(let ((newsym (obarray-put table "")))
|
(let ((newsym (obarray-put table "")))
|
||||||
|
@ -66,5 +66,10 @@ Return t on success, nil otherwise."
|
|||||||
"Call function FN on every symbol in obarray OB and return nil."
|
"Call function FN on every symbol in obarray OB and return nil."
|
||||||
(mapatoms fn ob))
|
(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)
|
(provide 'obarray)
|
||||||
;;; obarray.el ends here
|
;;; obarray.el ends here
|
||||||
|
@ -935,7 +935,7 @@ is sensitive to blank lines."
|
|||||||
(defun vc-clear-context ()
|
(defun vc-clear-context ()
|
||||||
"Clear all cached file properties."
|
"Clear all cached file properties."
|
||||||
(interactive)
|
(interactive)
|
||||||
(fillarray vc-file-prop-obarray 0))
|
(obarray-clear vc-file-prop-obarray))
|
||||||
|
|
||||||
(defmacro with-vc-properties (files form settings)
|
(defmacro with-vc-properties (files form settings)
|
||||||
"Execute FORM, then maybe set per-file properties for FILES.
|
"Execute FORM, then maybe set per-file properties for FILES.
|
||||||
|
@ -89,5 +89,15 @@
|
|||||||
(obarray-map collect-names table)
|
(obarray-map collect-names table)
|
||||||
(should (equal (sort syms #'string<) '("a" "b" "c")))))
|
(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)
|
(provide 'obarray-tests)
|
||||||
;;; obarray-tests.el ends here
|
;;; obarray-tests.el ends here
|
||||||
|
Loading…
Reference in New Issue
Block a user