Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make counsel-imenu show functions as "Function: func". #775

Closed
wants to merge 1 commit into from

Conversation

@Yevgnen
Copy link
Contributor

commented Nov 14, 2016

Add the missing category of functions for counsel-imenu.
The global function is display in
Function: func.
All the other contents will retain unchanged, e.g.

Package: pack
Variables: var
Import: pack

Tested in emacs-lisp-mode, c++mode and python-mode.

@Yevgnen Yevgnen force-pushed the Yevgnen:imenu-functions branch Dec 2, 2016

Make counsel-imenu show functions as "Function: func".
Add the missing category of functions for counsel-imenu.
The global function is display in "Function: func".
All the other contents will retain unchanged, e.g.
    Package: pack
    Variables: var
    Import: pack

@Yevgnen Yevgnen force-pushed the Yevgnen:imenu-functions branch to d17c9e9 Dec 5, 2016

(functions (remove-if (lambda (x) (listp (cdr x))) items)))
(if functions
(append others `(("Function" ,@functions)))
items)))

This comment has been minimized.

Copy link
@basil-conto

basil-conto May 17, 2018

Collaborator

The Swiper project uses cl-lib, not cl, so you should use the cl- namespace. You can also simplify this code a bit:

(defun counsel-imenu-categorize-functions (items)
  "Categorize all the functions of imenu."
  (let ((fns (cl-remove-if #'listp items :key #'cdr))
        (others (cl-remove-if #'nlistp items :key #'cdr)))
    (if fns
        (nconc others `(("Function" ,@fns)))
      items)))

or even

(defun counsel-imenu-categorize-functions (items)
  "Categorize all the functions of imenu."
  (let ((fns (cl-remove-if #'listp items :key #'cdr)))
    (if fns
        (nconc (cl-remove-if #'nlistp items :key #'cdr)
               `(("Function" ,@fns)))
      items)))

@abo-abo abo-abo closed this in b6fc894 May 17, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented May 17, 2018

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.