imalison:flatten-imenu-index

This commit is contained in:
Ivan Malison 2015-06-29 03:09:06 -07:00
parent 43f132fa21
commit 7f3e060b7c

View File

@ -189,6 +189,18 @@
`(setq ,name ,value)
`(defvar ,name ,value)))
(defun imalison:imenu-prefix-flattened (index)
(let ((flattened (imalison:flatten-imenu-index (cdr index))))
(cl-loop for sub-item in flattened
collect
`(,(concat (car index) "." (car sub-item)) . ,(cdr sub-item)))))
(defun imalison:flatten-imenu-index (index)
(let ((cdr-is-index (listp (cdr index))))
(cond ((not (stringp (car index))) (cl-mapcan #'imalison:flatten-imenu-index index))
(cdr-is-index (imalison:imenu-prefix-flattened index))
(t (list index)))))
(defmacro defvar-if-non-existant (name value)
(unless (boundp name)
`(defvar ,name ,value)))