I'm using the lsp layer on Spacemacs with javascript-backend 'lsp and it activates two modes I don't like: lsp-ui-mode and eldoc.

I found lsp-ui-mode inside lsp-mode-hook and added (remove-hook 'lsp-mode-hook 'lsp-ui-mode) to my init.el, which fixed that.

But I can't find where eldoc-mode is being called. How do I search for it within (all?) hooks?

up vote 2 down vote accepted

Use M-x debug-on-entry RET eldoc-mode RET

(and M-x cancel-debug-on-entry RET to undo that.)

This will show you what called eldoc-mode, each time it is invoked.

To learn about the debugger, see C-hig (elisp)Debugger and especially (elisp)Debugger Commands (so you know how to use it).


In this case, the cause is almost certainly global-eldoc-mode which is a globalized minor mode. Globalized modes act in after-change-major-mode-hook, which happens after the major mode hook has run (and so you can't use the major mode hook to disable the associated buffer-local eldoc-mode).

If you don't want eldoc at all, just add (global-eldoc-mode -1) to your init file.

  • 1
    Thank you, debug-on-entry did it. I added (global-eldoc-mode -1) to my init file but it wasn't enough. Then through the debugger I found out I had to also set lsp-enable-eldoc nil. Also found lsp-ui-doc-enable and lsp-ui-sideline-enable and turned them off to stop annoying overlays on hover. – hsribei Sep 7 at 0:57

You can use command apropos-value to find all variables whose values match some pattern: M-x apropos-value eldoc-mode. Then search the results buffer for just the variables whose names end in -hook.

  • Thank you! This does exactly what I asked for, but it was less helpful as there were too many results and I couldn't sift through them to find the culprit. Using debug-on-entry I also found out that eldoc-mode wasn't getting called in a hook at all, but rather in a piece of code that checked for the lsp-enable-eldoc condition and then called eldoc-mode directly. – hsribei Sep 7 at 1:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.