DiamondDemon669 · 2022-04-17 04:35
some of the events in my .emacs file take a while to load their buffers and emacs runs the next statements before they are done loading, messing up the buffer order. I found out that those events have hooks but I do not know how to use them since the demo had the hook run a function and I want to avoid putting the rest of .emacs in a function because of a few events.
7890yuiop · 2022-04-17 04:44
The question is impossibly vague without the specific details.
Emacs is a single-threaded program, so any asynchronous behaviour involves either separate processes or the cooperative threads functionality (but not many libraries use the latter feature).
If you provide a minimal example to demonstrate and explain the problem, people will be able to help.
DiamondDemon669 · 2022-04-17 04:47
well run-python is a function that takes a while to start and its hook is python-shell-first-prompt-hook. how do I wait for that hook to be run before running the next statements
7890yuiop · 2022-04-17 06:03
You'd put the statements that need to happen at the point that `python-shell-first-prompt-hook` runs into the function that you add to that hook. That's what hooks are for -- doing things at well-defined points.
Define a function with the necessary statements, and use `add-hook` to have it called at the correct time.
> I want to avoid putting the rest of .emacs in a function because of a few events.
You don't put "the rest of .emacs" into your hook function. You put the code which is relevant to that hook into your hook function. And you do likewise for each of the other hooks you're utilising.
DiamondDemon669 · 2022-04-17 07:59
thanks!