syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.69k stars 4.9k forks source link

How disable `semantic-idle-summary-mode` in `emacs-lisp-mode` #16179

Closed sfavazza closed 10 months ago

sfavazza commented 1 year ago

Cotext

Recently I enabled the semantic layer. Working on lisp files I realized that Eldoc does not show documentation in the echo area anymore.

Root cause

I could trace the issue to the semantic-idle-summary-mode . When manually disabled, Eldoc works again.

Possible solution

I dig into the emacs-lisp layer and tried the following code:


(defun emacs-lisp/post-init-semantic ()
  (add-hook 'emacs-lisp-mode-hook 'semantic-mode)
  ;; (with-eval-after-load 'semantic
  ;;   (semantic-default-elisp-setup))
  )

Though I don't know what is the consequence of removing (semantic-default-elisp-setup). Any thoughts about the consequences?

I also tried, w/o success:

(with-eval-after-load 'semantic
    (semantic-default-elisp-setup)
    (semantic-idle-summary-mode -1))

System Info :computer:

Sergey-Makarov commented 11 months ago

Hey! Just my 5 cents after some digging into the code.

When enabling semantic-idle-summary-mode, the following line of code is executed.

(add-hook 'eldoc-documentation-functions #'semantic--eldoc-info nil t)

The semantic--eldoc-info function essentially makes eldoc-mode useless (at least inside elisp buffers) by returning t instead of nil and thus not allowing the consecutive functions inside eldoc-documentation-functions to provide an actual result. Not sure what is the reasoning behind that.

Anyways, this dirty code fixes the problem for me:

(eval-after-load 'semantic/idle
  (advice-add #'semantic--eldoc-info
              :filter-return (lambda (res)
                               (if (eq res t)
                                   nil
                                 res))))

This issue seems to be related to Emacs itself rather than Spacemacs distro though, but I currently don't have time to figure out where and how to open that issue (have never done that before :) )

sfavazza commented 11 months ago

Hi, thanks for your reply. To be honest I already turned the layer off, its periodic function frequently clog the echo area with not so meaningful error messages about buffers I'm not even working on.

That said, as it seems not related to spacemacs, this issue might be closed.

What's your opinion @smile13241324?

emacs18 commented 10 months ago

I'm wondering if the following could actually be a bug fix:

diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el
index 58f162e67f7..746c714ca88 100644
--- a/lisp/cedet/semantic/idle.el
+++ b/lisp/cedet/semantic/idle.el
@@ -736,15 +736,16 @@ specific to a major mode.  For example, in jde mode:
   "Return the eldoc info for the current symbol.
 Call `semantic-idle-summary-current-symbol-info' for getting the
 current tag to display information."
-  (or (eq major-mode 'emacs-lisp-mode)
-      (not (semantic-idle-summary-useful-context-p))
-      (let* ((found (save-excursion
-                      (semantic-idle-summary-current-symbol-info)))
-             (str (cond ((stringp found) found)
-                        ((semantic-tag-p found)
-                         (funcall semantic-idle-summary-function
-                                  found nil t)))))
-        str)))
+  (if (eq major-mode 'emacs-lisp-mode)
+      nil ;; returning t breaks eldoc.  See https://github.com/syl20bnr/spacemacs/issues/16179 
+    (or (not (semantic-idle-summary-useful-context-p))
+        (let* ((found (save-excursion
+                        (semantic-idle-summary-current-symbol-info)))
+               (str (cond ((stringp found) found)
+                          ((semantic-tag-p found)
+                           (funcall semantic-idle-summary-function
+                                    found nil t)))))
+          str))))

 (define-minor-mode semantic-idle-summary-mode
   "Toggle Semantic Idle Summary mode.

The key change is to return nil in emacs-lisp-mode rather than returning t. If folks agree that this could be a bug fix, I can submit this patch to emacs-devel email list.

smile13241324 commented 10 months ago

I think this would be a bug fix @emacs18

smile13241324 commented 10 months ago

As this is no Spacemacs bug I am closing it for now.