From 7f3e060b7c5f2de6addb0dd12114680e7cf69868 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 29 Jun 2015 03:09:06 -0700 Subject: [PATCH] imalison:flatten-imenu-index --- dotfiles/emacs.d/init.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 8ac084c5..564c2b2d 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -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)))