swiper icon indicating copy to clipboard operation
swiper copied to clipboard

counsel-imenu doesn't see leaf org-mode entries with which-func and pdf-tools

Open whatacold opened this issue 3 years ago • 7 comments

Hi,

Say I have an org file like this:

* 1
** 1.1
* 2
** 2.1
*** 2.1.1
** 2.2

I would like jump to every headings possibly by M-x counsel-imenu, instead of only leaf heading as below:

1: 1.1
2.2.1: 2.1.1
2: 2.2

How to do that? thanks.

whatacold avatar Jul 30 '21 14:07 whatacold

How to do that?

That's what happens by default:

  1. emacs -Q

  2. M-x package-initialize RET

  3. C-x C-f /tmp/foo.org RET

  4. * 1
    ** 1.1
    * 2
    ** 2.1
    *** 2.1.1
    ** 2.2
    
  5. C-x C-s

  6. M-x counsel-imenu RET

    2021-07-30-174155_574x405_scrot

What do you see on your end? What steps lead you to that? Can you reproduce the issue starting from emacs -Q? Could it be some part of your configuration or an installed package that is interfering? What are your M-x emacs-version and Counsel version? Thanks.

basil-conto avatar Jul 30 '21 16:07 basil-conto

Oops, counsel-imenu does work as what I want if I start a clean Emacs env by emacs -Q, sorry about that.

My counsel version is 0.13.4 and M-x emacs-version is GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.29, cairo version 1.16.0) of 2021-06-14.

Still investigating on what causes this problem in my config, thanks for your detailed response!

whatacold avatar Jul 31 '21 01:07 whatacold

The culprit is which-func with below snippets:

(require 'which-func)
(which-function-mode 1)

I don't know why, but if I comment them out, counsel-imenu works as expected.

And I also found that (pdf-tools-install) also causes this problem.

whatacold avatar Jul 31 '21 04:07 whatacold

But the problems also happen with vanilla imenu, right? So I don't think it's a problem with counsel-imenu per se.

basil-conto avatar Jul 31 '21 11:07 basil-conto

Haven't used M-x imenu directly before, but it seems it works :(

I made a gif to demonstrate this: t

whatacold avatar Jul 31 '21 15:07 whatacold

Haven't used M-x imenu directly before, but it seems it works

Ah, sorry, I didn't realise it performs completion in steps. So I'm guessing the problem with counsel-imenu is that it fails to follow all of the same completion steps as imenu. Hopefully someone more familiar with imenu and counsel-imenu than I will figure out how to do that.

basil-conto avatar Jul 31 '21 15:07 basil-conto

No worries, at least I can work-around it, so it's not a big problem :)

whatacold avatar Jul 31 '21 15:07 whatacold