Function: registry-delete

registry-delete is a byte-compiled function defined in registry.el.gz.

Signature

(registry-delete ARG &rest ARGS)

Implementations

((db registry-db) keys assert &rest spec) in `registry.el'.

Delete KEYS from the registry-db DB. If KEYS is nil, use SPEC to do a search. Updates the secondary ('tracked') indices as well. With assert non-nil, errors out if the key does not exist already.

Source Code

;; Defined in /usr/src/emacs/lisp/registry.el.gz
(cl-defmethod registry-delete ((db registry-db) keys assert &rest spec)
  "Delete KEYS from the registry-db DB.
If KEYS is nil, use SPEC to do a search.
Updates the secondary ('tracked') indices as well.
With assert non-nil, errors out if the key does not exist already."
  (let* ((data (oref db data))
	 (keys (or keys
		   (apply #'registry-search db spec)))
	 (tracked (oref db tracked)))

    (dolist (key keys)
      (let ((entry (gethash key data)))
	(when assert
	  (cl-assert entry nil "Key %s does not exist in database" key))
	;; clean entry from the secondary indices
	(dolist (tr tracked)
	  ;; is this tracked symbol indexed?
	  (when (registry-lookup-secondary db tr)
	    ;; for every value in the entry under that key...
	    (dolist (val (cdr-safe (assq tr entry)))
	      (let* ((value-keys (registry-lookup-secondary-value
				  db tr val)))
		(when (member key value-keys)
		  ;; override the previous value
		  (registry-lookup-secondary-value
		   db tr val
		   ;; with the indexed keys MINUS the current key
		   ;; (we pass t when the list is empty)
		   (or (delete key value-keys) t)))))))
	(remhash key data)))
    keys))