0

To jump around in my init.el I used to do

(setq imenu-generic-expression '((nil ";; \\[ \\(.*\\)" 1)))

and then put markers in the file like so

;; [ my marker here

To call imenu i have a handy shortcut

(local-set-key (kbd "C-*") 'imenu)

This worked nice but does not anymore... Now i only get

user-error: No items suitable for an index found in this buffer

toggle-debug-on-error and removing user-error from ignored-debug-errors and calling imenu again gives me

Debugger entered--Lisp error: (user-error "No items suitable for an index found in this buffer")
  signal(user-error ("No items suitable for an index found in this buffer"))
  user-error("No items suitable for an index found in this buffer")
  imenu--make-index-alist()
  imenu-choose-buffer-index()
  byte-code("\300 C\207" [imenu-choose-buffer-index] 1)
  call-interactively(imenu nil nil)

My emacs version is 24.3.1. What am i doing wrong? How can i get the intended imenu behavior working the way i have had it?

  • This works for me with Emacs 25. Are you aware of the extra closing paren in the line with setq? – Marco Wahl Nov 1 '15 at 13:39
  • 1
    "This worked nice but does not anymore" implies that you changed something in your init, but have not said what. Try it with emacs -Q, and bisect your init file until you find the culprit. – Dan Nov 1 '15 at 15:31
  • I found that imenu-create-index-function's value is semantic-create-imenu-index and that it is local in buffer init.el. The global value is imenu-default-create-index-function. I dont know where this is change is coming from. And will research in this direction... (thanks for the -Q hint. wil try this too) – Matthias Nov 2 '15 at 5:36
1

Load the source file imenu.el, then use M-x debug-on-entry RET imenu-choose-buffer-index. Open file imenu.el in a separate frame (C-x 5 f), and move to the definition of imenu-choose-buffer-index, so you can see what it does.

Then, when you try to invoke imenu the debugger will open. You can walk through the debugger using d (or c to skip through an uninteresting step).

You are especially interested in the invocation of imenu--make-index-alist. (You could use debug-on-entry for that, instead, but it might be instructive to see what goes on before it is invoked.

The reason for showing imenu.el in another frame is so you can follow the code along with what the debugger is doing.

Following the execution in the debugger will tell you what goes wrong, and possibly why. If you have a question about what it shows you in this regard, update your question accordingly.

1

It turned out that I have installed a package called lispy and that this package seems to change imenu-create-index-functions value. Answering my own question gives me the impression that doing "emacs -Q" should have been my pre-post action... Since I had not time to get used to lispy I just removed the package and now i can imenu through my init.el again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.