on.el icon indicating copy to clipboard operation
on.el copied to clipboard

Feature request: `on-first-project-hook`?

Open jcs090218 opened this issue 3 years ago • 1 comments

Many packages requires a project to be defined, I think a on-first-project-hook could benefits many users? :)

jcs090218 avatar Sep 14 '22 05:09 jcs090218

Do you have a use case for this? It doesn't seem entirely necessary to me, because you could just use (eval-after-load 'project '(...)) instead. The :after keyword in use-package makes this even easier.

axgfn avatar Sep 14 '22 21:09 axgfn

Oh, not the project.el (loading package). What I mean is when a project root is defined. Many packages rely on the project root to be defined in order to work, like lsp-mode, etc.

jcs090218 avatar Sep 25 '22 13:09 jcs090218

@ajgrf Friendly ping. :)

jcs090218 avatar Oct 06 '22 08:10 jcs090218

@jcs090218 Is the idea to do something like add-variable-watcher to a project root variable? I'm not sure I understand the use case because you wouldn't normally wan to run lsp-mode just once.

noctuid avatar Oct 08 '22 14:10 noctuid

I'm not sure I understand the use case because you wouldn't normally wan to run lsp-mode just once.

Not enable lsp-mode but require the module the first time. lsp-mode may be a bad example, other example are diff-hl, git-gutter, or vc-msg, etc.

Maybe hooks on-first-project-hook (for diff-hl/git-gutter) and on-project-hook (for lsp-mode/eglot) can be a great addition?

Expectation:

(add-hook 'on-first-project-hook (lambda () (global-diff-hl-mode 1)))  ; don't load on every project's hook
(add-hook 'on-project-hook (lambda () (lsp-mode 1)))

jcs090218 avatar Oct 08 '22 16:10 jcs090218