reddit / emacs

What mystery package is setting semantic-create-imenu-index?

JDRiverRun · 2022-04-24 00:52
Sometimes, after days or weeks of using an Emacs session, I find that my `imenu-create-index-function` has been globally set to `semantic-create-imenu-index` which is something from CEDET. This messes up imenu, and in particular the lovely vertico grouping of consult-imenu. I don't use CEDET. Any ideas what could be loading this so long after init?
jimehgeek · 2022-04-24 08:31
I’m afraid I can’t help directly, but I’ve had similar issues in the past with other variables. These are the methods I’ve used to track down the culprits: - Simply do a full text search for the new unexpected value in my whole config folder, which in my case includes the source for all installed packages. - Use `M-X debug-on-variable-change` to launch a debugger when the variable is changed. Then just wait till it happens again.
JDRiverRun · 2022-04-24 16:45
Good idea; I'll set it the watch and wait.
lastnamebird · 2022-12-06 22:39
7 months later but I've found out why this happens to me too. The semantic file `el.el`sets the `imenu-create-index-function` with `defvar-mode-local` variable [here](https://github.com/emacs-mirror/emacs/blob/master/lisp/cedet/semantic/bovine/el.el#L923-L924) whenever it is initially loaded. It's from a commit from 2009 so probably should be removed. In my case `semantic-mode` is temporarily (or permanently if `lispy-no-permanent-semantic` is left at its default value) by `lispy-goto`. I don't really use `lispy-goto` so I suppose one could just override the function. However, I imagine something like the following should fix future issues as well. (with-eval-after-load 'semantic/bovine/el (defvar-mode-local emacs-lisp-mode imenu-create-index-function 'imenu-default-create-index-function))
JDRiverRun · 2022-12-06 23:23
Indeed! Thank you for this. lispy! Which is fantastic, but man does it load *everything —* ivy, semantic, org, hydra, avy, ... Somebody needs to make a *lispy-light*. I had suspected lispy. What threw me off the trail is that I have `lispy-no-permanent-semantic=t`, but that doesn't seem to prevent it. This is probably due to the temporary setting of that mode you mention in `lispy--goto` "breaking out" sometimes when there are errors. That would explain why it's so intermittent (just happened to me yesterday after a month or more). It should really be wrapped in an unwind-protect so you are never left in accidental unwanted semantic mode. I will probably just kill it with advice.
lastnamebird · 2022-12-07 04:00
> Somebody needs to make a lispy-light. That would be ideal. I’ve started to try out [puni](https://github.com/AmaiKinono/puni) today, it’s not bad but I do miss `lispy-flow`. I’m trying to see if I can replicate it. But yes, I think the goto function will load semantic no matter what. And since semantic does not set that variable with a hook, it’s set immediately and as a mode local variable. But glad it could help a bit.