[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master adfad96 007/272: support imenu
From: |
Oleh Krehel |
Subject: |
[elpa] master adfad96 007/272: support imenu |
Date: |
Mon, 25 Apr 2016 10:13:13 +0000 |
branch: master
commit adfad9605ade2f8faabf09cec16408b26e32d422
Author: Chen Bin <address@hidden>
Commit: Chen Bin <address@hidden>
support imenu
---
counsel.el | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/counsel.el b/counsel.el
index 9c86ec0..44fac93 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1296,6 +1296,32 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(insert (substring-no-properties s))
(setq counsel-completion-end (point))))
+(defun counsel-imenu-get-candidates-from (alist &optional prefix)
+ "Create a list of (key . value) from ALIST.
+PREFIX is used to create the key."
+ (cl-loop for elm in alist
+ nconc (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)))
+ (concat prefix (if prefix ".") (car elm)))
+ (and (cdr elm) ; bug in imenu, should not be needed.
+ (setcdr elm (copy-marker (cdr elm))) ; Same as [1].
+ (list (cons (concat prefix (if prefix ".") (car elm))
+ (copy-marker (cdr elm))))))))
+
+;;;###autoload
+(defun counsel-imenu ()
+ "Jump to a buffer position indexed by imenu."
+ (interactive)
+ (let ((imenu-auto-rescan t) items)
+ (unless (featurep 'imenu)
+ (require 'imenu nil t))
+ (setq items (imenu--make-index-alist t))
+ (ivy-read "imenu items:"
+ (counsel-imenu-get-candidates-from (delete (assoc "*Rescan*"
items) items))
+ :action (lambda (pos) (goto-char pos)))))
+
(provide 'counsel)
;;; counsel.el ends here
- [elpa] master 83f89d8 003/272: Improve swiper for multiple occurrences on one line, (continued)
- [elpa] master 83f89d8 003/272: Improve swiper for multiple occurrences on one line, Oleh Krehel, 2016/04/25
- [elpa] master db283d3 005/272: Fix recursive minibuffer exit with "C-g", Oleh Krehel, 2016/04/25
- [elpa] master cabab4b 012/272: swiper.el (swiper-font-lock-ensure): Add bongo-library-mode, Oleh Krehel, 2016/04/25
- [elpa] master 2c50031 004/272: Fix ivy-reverse-i-search broken by recursive update, Oleh Krehel, 2016/04/25
- [elpa] master 6951eba 001/272: Make ivy--regex-plus recognize ! at the beginning of the str, Oleh Krehel, 2016/04/25
- [elpa] master d74fab4 010/272: counsel.el (counsel-M-x): Let-bind this-command, Oleh Krehel, 2016/04/25
- [elpa] master fd27465 014/272: counsel.el (counsel-git): Fix window selection, Oleh Krehel, 2016/04/25
- [elpa] master 6bf72fd 008/272: counsel.el (counsel-imenu): Work when given positions are overlays, Oleh Krehel, 2016/04/25
- [elpa] master 63be079 009/272: ivy.el (ivy-re-builders-alist): Allow this-command to be a key, Oleh Krehel, 2016/04/25
- [elpa] master 09848ca 013/272: Add cousel-ag-base-command var, Oleh Krehel, 2016/04/25
- [elpa] master adfad96 007/272: support imenu,
Oleh Krehel <=
- [elpa] master d09a16b 011/272: swiper.el (swiper-font-lock-ensure): Add bongo-playlist-mode, Oleh Krehel, 2016/04/25
- [elpa] master a0f1e25 021/272: ivy.el (ivy-completion-in-region): Fix log 0 issue, Oleh Krehel, 2016/04/25
- [elpa] master df1dc78 019/272: counsel.el (counsel-find-file): Add initial-input, Oleh Krehel, 2016/04/25
- [elpa] master 2ea56ec 027/272: ivy.el (ivy-occur): Fix when ivy--old-re isn't a string, Oleh Krehel, 2016/04/25
- [elpa] master db3e7ff 015/272: Ensure the return result of `ivy-read', Oleh Krehel, 2016/04/25
- [elpa] master e070f4c 022/272: ivy.el (ivy-add-face-text-property): New defun, Oleh Krehel, 2016/04/25
- [elpa] master 89ed4d6 024/272: Improve flx highlighting, Oleh Krehel, 2016/04/25
- [elpa] master 09cb5c9 025/272: ivy: fix ivy--resize-minibuffer-to-fit for small delta, Oleh Krehel, 2016/04/25
- [elpa] master 6051225 020/272: Call ivy-set-actions with t to affect all commands, Oleh Krehel, 2016/04/25
- [elpa] master 12523d0 023/272: Use flx for highlighting fuzzy matches, Oleh Krehel, 2016/04/25