emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 9ef344d 062/272: use imenu API to jump to position. requir


From: Oleh Krehel
Subject: [elpa] master 9ef344d 062/272: use imenu API to jump to position. required by org-mode
Date: Mon, 25 Apr 2016 10:13:16 +0000

branch: master
commit 9ef344d61148132199624b73f969d1719aa77b0d
Author: Chen Bin <address@hidden>
Commit: Oleh Krehel <address@hidden>

    use imenu API to jump to position. required by org-mode
    
    Fixes #364
---
 counsel.el |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/counsel.el b/counsel.el
index 75ee2c6..682e238 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1405,13 +1405,15 @@ PREFIX is used to create the key."
                (if (imenu--subalist-p elm)
                    (counsel-imenu-get-candidates-from
                     (cl-loop for (e . v) in (cdr elm) collect
-                         (cons e (if (integerp v) (copy-marker v) v)))
+                             (cons e (if (integerp v) (copy-marker v) v)))
+                    ;; pass the prefix to next recursive call
                     (concat prefix (if prefix ".") (car elm)))
-                 (list
-                  (cons (concat prefix (if prefix ".") (car elm))
-                        (if (overlayp (cdr elm))
-                            (overlay-start (cdr elm))
-                          (cdr elm))))))
+                 (let ((key (concat prefix (if prefix ".") (car elm))))
+                   (list (cons key
+                               ;; create a imenu candidate here
+                               (cons key (if (overlayp (cdr elm))
+                                             (overlay-start (cdr elm))
+                                           (cdr elm))))))))
              alist))
 
 ;;;###autoload
@@ -1424,9 +1426,11 @@ PREFIX is used to create the key."
          (items (imenu--make-index-alist t))
          (items (delete (assoc "*Rescan*" items) items)))
     (ivy-read "imenu items:" (counsel-imenu-get-candidates-from items)
-              :action (lambda (pos)
+              :action (lambda (candidate)
                         (with-ivy-window
-                          (goto-char pos))))))
+                          ;; In org-mode, (imenu candidate) will expand child 
node
+                          ;; after jump to the candidate position
+                          (imenu candidate))))))
 
 (defun counsel--descbinds-cands ()
   (let ((buffer (current-buffer))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]