clojure-emacs/clojure-mode

Emacs hangs when `clojure-toplevel-inside-comment-form` is `t`, and `comment` is used as a var

Ramblurr opened this issue · 5 comments

Expected behavior

I can edit code with comment shadowed from clojure.core without the editor hanging. (Whether or not I should do this in the first place is a lesson I should probably learn but the editor shouldn't hang in any case)

Actual behavior

When clojure-toplevel-inside-comment-form is t and comment is used in a buffer as a clojure var, emacs hangs indefinitely until C-ged.

See discussion here: https://clojurians.slack.com/archives/C099W16KZ/p1667918713039869

Here is a stacktrace when C-ged:

scrn-2022-11-08-17-09-25

Steps to reproduce the problem

(ns bug
  (:refer-clojure :exclude [comment]))


(def comment {:comment/body "I probably shouldn't be using comment"})

Load up that code, ensureclojure-toplevel-inside-comment-form is t, and then navigate edit inside and round the comment var or in the map.

Environment & Version information

clojure-mode version

I'm using doom which uses clojure-mode from git. The git hash of clojure-mode I'm using is 414157c3e523e80cc44dca8f86f1853122ee5f6b

Emacs version

GNU Emacs 28.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-07-15 [2 times]

Operating system

Fedora Silverblue 36

vemv commented

It would be interesting to see if this can be reproduced in our CI; that is to discard the possibility that this issue cannot be reproduced without the other libs also seen in the stacktrace (related to markdown and lsp).

Should be easy enough.

Tried to reproduce on my machine (Prelude), but did not notice any hanging

I experience what seems to be very similar issue with a (comment ) form hanging when I have both clojure-toplevel-inside-comment-form t and Clojure LSP and Lsp-mode enabled.

I navigate the cursor to the opening paren, ( and the cursor stops and cpu is 100%

Some editing within the (comment ) form can also cause the issue, although this is intermittent.

C-g pressed several times will kill what ever process is causing 100% CPU.

Shutting down the LSP server resolves the issue.
Restarting Emacs with clojure-toplevel-inside-comment-form nil also resolves the issue

I have experience the issue on both Spacemacs and Doom Emacs setups

Yes same experience here and found this related issue #586.

I have set lsp-eldoc-enable-hover to nil in my Emacs LSP (lsp-mode / lsp-ui) config and no longer have the issue with using clojure-toplevel-inside-comment-form

If I understand the slack discussion correctly, LSP is asking clojure-mode to font-lock doc-strings and causing a process to eat up the cpu.

lsp-eldoc-enable-hover is responsible for triggering the documentation pop-ups when moving the cursor or mouse over function names and seems to be running even if you have otherwise disabled those popups. Setting lsp-eldoc-enable-hover as nil ensures lsp doesnt call clojure-mode for this each time and therefore the problem is not tiggered.

(setq lsp-eldoc-enable-hover nil)

Obviously if the LSP hover functionality is desirable, then this is not a valid approach.