TL;DR: How can I force evaluation of a
setq statement at start-up so that
imenu updates appropriately? (You can skip down to the second code-block below, if you want.)
I love the concept of
imenu (esp. when integrated with
helm) and I think it has great potential to improve my workflow...assuming I learn how to correctly set definitions for
As a simplified example, let's say that I'd like to add a few definitions to my
imenu which would be useful when making updates - namely, the list of imported packages.
Let's consider the following three lines as the code we want to parse (purely illustrative; my
init file doesn't actually have an explicit line for importing
(defconst dc/default-directory "/path/to/directory") (use-package dired) (use-package electric)
In order to extract the constants and package names in
imenu, I've included the code below in my
init.el file. This code works BUT only after I manually
eval the second line, (i.e., the second
setq statement below).
(setq dc-additions '(("Imported packages" ".*(use-package \\(.*\\))*" 1) ("Defined constants" ".*(defconst \\(.*\\))*" 1))) (setq imenu-generic-expression (copy-sequence `(,@dc-additions ,@imenu-generic-expression))) (add-hook 'emacs-lisp-mode 'imenu-generic-expression)
If I don't manually evaluate the second step, the
imenu list shows only the default definitions. However, after I
eval the second statement above, the
imenu list correctly include includes items based on my definition.
How can I force evaluation of the second statement? In other words, what can I do to to ensure that
imenu will automatically consider items based on my definition?
imenu after start-up but before I manually
eval the second
imenu after I manually
eval the statement: