abo-abo / swiper

Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
https://oremacs.com/swiper/
2.31k stars 338 forks source link

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

Open whatacold opened 3 years ago

whatacold commented 3 years ago

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.

basil-conto commented 3 years ago

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.

whatacold commented 3 years ago

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 commented 3 years ago

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.

basil-conto commented 3 years ago

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

whatacold commented 3 years ago

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

I made a gif to demonstrate this: t

basil-conto commented 3 years ago

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.

whatacold commented 3 years ago

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