jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.38k stars 260 forks source link

Failed to add hooks like this: `(python-mode . (flycheck-mode company-mode))`. #954

Open hongyi-zhao opened 2 years ago

hongyi-zhao commented 2 years ago

I install and manage the python-mode package via use-package and have the following configuration in :hooks section:

:hook
  (python-mode . flycheck-mode)
  (python-mode . company-mode)
 [...]

If I combine the above two hook lines into this one: (python-mode . (flycheck-mode company-mode)), the following error will be triggered during Emacs startup:

Error in post-command-hook (global-company-mode-check-buffers): (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")

Why doesn't use-package support this type of hook combination?

Regards, HZ

doolio commented 1 year ago

Does it not make more sense to include these hooks to python-mode in the use-package forms for flycheck and company. That is:

(use-package company
  :hook (python-mode . company-mode))
(use-package flycheck
  :hook (python-mode . flycheck-mode))

However, I think you would be better served by hooking into prog-mode rather than python-mode.

(use-package company
  :hook (prog-mode . company-mode))
(use-package flycheck
  :hook (prog-mode . flycheck-mode))
jwiegley commented 1 year ago

@hongyi-zhao Your suggestion makes sense to me.