diff options
author | muahah <gnieheh@gmail.com> | 2016-12-22 02:55:56 +0100 |
---|---|---|
committer | muahah <gnieheh@gmail.com> | 2016-12-22 21:52:36 +0100 |
commit | 12aeb84489cf74976ee2b5347931df49e35c190f (patch) | |
tree | 2e32183d0944233f130037e81b81f67f19396504 /helm-imenu.el | |
parent | 21181649a6bcbdb59d792b16e263b549632f7d7a (diff) |
Make helm-imenu support complex format for imenu lists
see `imenu--index-alist` for the different possible
formats for imenu lists.
Simple format (INDEX-NAME . POSITION) and nested format (INDEX-NAME .
SUB-ALIST) was already supported by helm-imenu, but complex format
(INDEX-NAME POSITION FUNCTION ARGUMENTS...) was not.
Diffstat (limited to 'helm-imenu.el')
-rw-r--r-- | helm-imenu.el | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/helm-imenu.el b/helm-imenu.el index 55649599..c8db63db 100644 --- a/helm-imenu.el +++ b/helm-imenu.el @@ -124,7 +124,7 @@ only '((foo . bar)) is needed." :fuzzy-match helm-imenu-fuzzy-match)))) (defun helm-imenu--maybe-switch-to-buffer (candidate) - (helm-aif (marker-buffer (cdr candidate)) + (helm-aif (and (markerp (cdr candidate)) (marker-buffer (cdr candidate))) (switch-to-buffer it))) (defun helm-imenu--execute-action-at-once-p () @@ -191,19 +191,23 @@ only '((foo . bar)) is needed." (defun helm-imenu--candidates-1 (alist) (cl-loop for elm in alist - nconc (if (imenu--subalist-p elm) - (helm-imenu--candidates-1 - (cl-loop for (e . v) in (cdr elm) collect - (cons (propertize - e 'helm-imenu-type (car elm)) - ;; If value is an integer, convert it - ;; to a marker, otherwise it is a cons cell - ;; and it will be converted on next recursions. - ;; (Issue #1060) [1]. - (if (integerp v) (copy-marker v) v)))) - (and (cdr elm) ; bug in imenu, should not be needed. - (setcdr elm (copy-marker (cdr elm))) ; Same as [1]. - (list elm))))) + nconc (cond + ((imenu--subalist-p elm) + (helm-imenu--candidates-1 + (cl-loop for (e . v) in (cdr elm) collect + (cons (propertize + e 'helm-imenu-type (car elm)) + ;; If value is an integer, convert it + ;; to a marker, otherwise it is a cons cell + ;; and it will be converted on next recursions. + ;; (Issue #1060) [1]. + (if (integerp v) (copy-marker v) v))))) + ((listp (cdr elm)) + (and elm (list elm))) + (t + (and (cdr elm) ; bug in imenu, should not be needed. + (setcdr elm (copy-marker (cdr elm))) ; Same as [1]. + (list elm)))))) (defun helm-imenu--get-prop (item) ;; property value of ITEM can have itself @@ -222,7 +226,7 @@ only '((foo . bar)) is needed." (cl-loop for (k . v) in candidates for types = (or (helm-imenu--get-prop k) (list "Function" k)) - for bufname = (buffer-name (marker-buffer v)) + for bufname = (and (markerp v) (buffer-name (marker-buffer v))) for disp1 = (mapconcat (lambda (x) (propertize |