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
Closed

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

wants to merge 1 commit into from

Conversation

Yevgnen
Copy link
Contributor

@Yevgnen Yevgnen 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.

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
(functions (remove-if (lambda (x) (listp (cdr x))) items)))
(if functions
(append others `(("Function" ,@functions)))
items)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

abo-abo commented May 17, 2018

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants