From 001af75c852f2f85f58a9bebb50cca28225d26e8 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 17 Aug 2016 17:55:24 -0700 Subject: [PATCH] Get markers from entries when flattening imenu --- dotfiles/emacs.d/README.org | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 1655cc68..3d6657ae 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -505,17 +505,15 @@ to get this behavior out of functions that provide a nested imenu index. #+BEGIN_SRC emacs-lisp (defvar imalison:imenu-separator ".") +(defvar imalison:imenu-get-markers-from-entry-strings t) (cl-defun imalison:flatten-index-entry (index-entry &optional (prefix "")) (cl-destructuring-bind (entry-name . rest) index-entry (message "%s" rest) (let ((new-entry-name (concat prefix entry-name)) - (original-properties (text-properties-at 0 entry-name))) - ;; Inherit any text-properties that were attached to the - ;; original entry. - (set-text-properties 0 (length new-entry-name) - original-properties - new-entry-name) + (entry-marker + (when imalison:imenu-get-markers-from-entry-strings + (imalison:get-marker-from-string entry-name)))) (if (listp rest) ;; Internal Node (let* ((new-prefix (concat new-entry-name imalison:imenu-separator)) @@ -523,14 +521,17 @@ index. (cl-mapcan (lambda (entry) (imalison:flatten-index-entry entry new-prefix)) rest))) - (if original-properties + (if entry-marker ;; When the entry had properties, we may want to keep ;; it around, because it might have a marker attached. - (cons (list new-entry-name) flattened-subentries) + (cons (cons new-entry-name entry-marker) flattened-subentries) flattened-subentries)) ;; Leaf Node (list (cons new-entry-name rest)))))) +(defun imalison:get-marker-from-string (string) + (--first (markerp it) (text-properties-at 0 string))) + (defun imalison:flatten-imenu-index (index) (cl-mapcan 'imalison:flatten-index-entry index))