Function: hash-prepend
hash-prepend is a byte-compiled function defined in hasht.el.
Signature
(hash-prepend VALUE KEY HASH-TABLE)
Documentation
Prepend VALUE onto the list value referenced by KEY, a string, in HASH-TABLE.
If KEY is not found in HASH-TABLE, it is added with a value of (list VALUE).
Trigger an error if an existing VALUE is not a list. Do nothing and return nil if KEY or HASH-TABLE are of the wrong type.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hasht.el
(defun hash-prepend (value key hash-table)
"Prepend VALUE onto the list value referenced by KEY, a string, in HASH-TABLE.
If KEY is not found in HASH-TABLE, it is added with a value of (list VALUE).
Trigger an error if an existing VALUE is not a list. Do nothing and return nil
if KEY or HASH-TABLE are of the wrong type."
(when (and (hash-table-p hash-table)
(stringp key))
(let* ((key-sym (intern key))
(key-val (gethash key-sym hash-table)))
(if key-sym
(if (listp key-val) ;; allowed to be nil
(puthash key-sym (cons value key-val) hash-table)
(error "(hash-prepend): `%s' key's value `%s' is not a list:" key key-val))
(error "(hash-prepend): Invalid hash-table key: %s" key)))))