use-package icon indicating copy to clipboard operation
use-package copied to clipboard

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

Open hongyi-zhao opened this issue 2 years ago • 2 comments

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

hongyi-zhao avatar Sep 26 '21 14:09 hongyi-zhao

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))

doolio avatar Nov 14 '22 18:11 doolio

@hongyi-zhao Your suggestion makes sense to me.

jwiegley avatar Apr 14 '23 05:04 jwiegley