Skip to content

[core] Hack load-history for items defined during package init functions#17235

Open
bcc32 wants to merge 1 commit intosyl20bnr:developfrom
janestreet:hack-toggle-load-history
Open

[core] Hack load-history for items defined during package init functions#17235
bcc32 wants to merge 1 commit intosyl20bnr:developfrom
janestreet:hack-toggle-load-history

Conversation

@bcc32
Copy link
Collaborator

@bcc32 bcc32 commented Feb 19, 2026

Items defined during my-layer/init-package, such as defuns, defvars,
or commands defined by spacemacs|add-toggle have their definition
file recorded as init.el (at the root of the Spacemacs repo) because
load-file-name is bound to that value at the time the function is
called and the definitions are executed. This is unlike the normal
way to define commands which is at the top-level of some file which is
loaded by load.

This PR wraps each init/pre-init/post-init funcall with
configuration-layer//funcall-recording-load-history, which let-binds
current-load-list and load-file-name to capture definitions under
the correct source file, so that symbol-file returns the file where
the definition is actually written, not the one that was being loaded
when the definition was executed.

spacemacs|add-toggle isn't recognized by find-function-regexp, so
find-function still goes to a slightly imprecise place, but at least
it goes to the right file now, which is a significant improvement.

Close #17234.

@bcc32
Copy link
Collaborator Author

bcc32 commented Feb 19, 2026

Sadly, this does not fix spacemacs|define-transient-state because that macro delays the definition again until emacs-startup-hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spacemacs|add-toggle forms produce commands with wrong load-history and source file

1 participant