Function: aget

aget is a byte-compiled function defined in assoc.el.gz.

Signature

(aget ALIST KEY &optional KEYNIL-P)

Documentation

Return the value in ALIST that is associated with KEY.

Optional KEYNIL-P describes what to do if the value associated with KEY is nil. If KEYNIL-P is not supplied or is nil, and the value is nil, then KEY is returned. If KEYNIL-P is non-nil, then nil would be returned.

If no key-value pair matching KEY could be found in ALIST, or ALIST is nil then nil is returned. ALIST is not altered.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/assoc.el.gz
(defun aget (alist key &optional keynil-p)
  "Return the value in ALIST that is associated with KEY.
Optional KEYNIL-P describes what to do if the value associated with
KEY is nil.  If KEYNIL-P is not supplied or is nil, and the value is
nil, then KEY is returned.  If KEYNIL-P is non-nil, then nil would be
returned.

If no key-value pair matching KEY could be found in ALIST, or ALIST is
nil then nil is returned.  ALIST is not altered."
  (defvar assoc--copy)
  (let ((assoc--copy (copy-alist alist)))
    (cond ((null alist) nil)
	  ((progn (asort 'assoc--copy key) ; dynamic binding
		  (anot-head-p assoc--copy key)) nil)
	  ((cdr (car assoc--copy)))
	  (keynil-p nil)
	  ((car (car assoc--copy)))
	  (t nil))))