Function: lookup-nested-alist
lookup-nested-alist is an autoloaded and byte-compiled function
defined in mule-util.el.gz.
Signature
(lookup-nested-alist KEYSEQ ALIST &optional LEN START NIL-FOR-TOO-LONG)
Documentation
Look up key sequence KEYSEQ in nested alist ALIST. Return the definition.
Optional 3rd argument LEN specifies the length of KEYSEQ.
Optional 4th argument START specifies index of the starting key.
The returned value is normally a nested alist of which
car part is the entry for KEYSEQ.
If ALIST is not deep enough for KEYSEQ, return number which is
how many key elements at the front of KEYSEQ it takes
to reach a leaf in ALIST.
Optional 5th argument NIL-FOR-TOO-LONG non-nil means return nil
even if ALIST is not deep enough.
Source Code
;; Defined in /usr/src/emacs/lisp/international/mule-util.el.gz
;;;###autoload
(defun lookup-nested-alist (keyseq alist &optional len start nil-for-too-long)
"Look up key sequence KEYSEQ in nested alist ALIST. Return the definition.
Optional 3rd argument LEN specifies the length of KEYSEQ.
Optional 4th argument START specifies index of the starting key.
The returned value is normally a nested alist of which
car part is the entry for KEYSEQ.
If ALIST is not deep enough for KEYSEQ, return number which is
how many key elements at the front of KEYSEQ it takes
to reach a leaf in ALIST.
Optional 5th argument NIL-FOR-TOO-LONG non-nil means return nil
even if ALIST is not deep enough."
(or (nested-alist-p alist)
(error "Invalid argument %s" alist))
(or len
(setq len (length keyseq)))
(let ((i (or start 0)))
(if (catch 'lookup-nested-alist-tag
(cond ((stringp keyseq) ; We can use `assq' for characters.
(while (< i len)
(if (setq alist (cdr (assq (aref keyseq i) (cdr alist))))
(setq i (1+ i))
(throw 'lookup-nested-alist-tag t))))
((arrayp keyseq)
(while (< i len)
(if (setq alist (cdr (assoc (aref keyseq i) (cdr alist))))
(setq i (1+ i))
(throw 'lookup-nested-alist-tag t))))
((listp keyseq)
(setq keyseq (nthcdr i keyseq))
(while (< i len)
(if (setq alist (cdr (assoc (pop keyseq) (cdr alist))))
(setq i (1+ i))
(throw 'lookup-nested-alist-tag t))))
(t (signal 'wrong-type-argument (list keyseq)))))
;; KEYSEQ is too long.
(if nil-for-too-long nil i)
alist)))