-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emacs is stuck when opening file containing comment
when clojure-toplevel-inside-comment-form is t
#586
Comments
I've had that variable set to comment nor on many other files that contain comment forms. Perhaps it's a lsp-mode interaction after all? (I'm on Emacs 28.0.50, not using lsp) |
Do (require 'package)
(setq debug-on-error t
no-byte-compile t
package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/"))
package-user-dir (expand-file-name (make-temp-name "lsp-tmp-elpa")
user-emacs-directory)
custom-file (expand-file-name "custom.el" package-user-dir))
(toggle-debug-on-quit)
(setq clojure-toplevel-inside-comment-form t)
(let* ((pkg-list '(clojure-mode)))
(package-initialize)
(package-refresh-contents)
(mapc (lambda (pkg)
(unless (package-installed-p pkg)
(package-install pkg))
(require pkg))
pkg-list)) and foo.clj is
|
It reproduces on both emacs 27.2 and emacs 27.1 |
I Just got the same bug suddenly.
Trying #586 (comment) procedure and Emacs stuck with high CPU charge on Emacs 28.1 like for @yyoncho. |
In case it helps anyone, #624 (not directly related to this issue) has a nice example of how to unit-test for a given top-level form. If you can follow that pattern, adding |
I work-around this issue by disabling
See related discussion: |
It happens because of infinite loop in the function that collects starting points for forms in buffer that are later used for font locking. Particularly in this case, that function jumps back and forth, infinitely adding position of (defun clojure-sexp-starts-until-position (position)
"Return the starting points for forms before POSITION.
Positions are in descending order to aide in finding the first starting
position before the current position."
(save-excursion
(let (sexp-positions)
(condition-case nil
(while (< (point) position)
(clojure-forward-logical-sexp 1)
(clojure-backward-logical-sexp 1)
(if (eq (point) (car sexp-positions))
(goto-char position)
(push (point) sexp-positions)
(clojure-forward-logical-sexp 1)))
(scan-error nil))
sexp-positions))) diff --git a/clojure-mode.el b/clojure-mode.el
index a5f7531..22aaffd 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -2264,8 +2264,10 @@ position before the current position."
(while (< (point) position)
(clojure-forward-logical-sexp 1)
(clojure-backward-logical-sexp 1)
- (push (point) sexp-positions)
- (clojure-forward-logical-sexp 1))
+ (if (eq (point) (car sexp-positions))
+ (goto-char position)
+ (push (point) sexp-positions)
+ (clojure-forward-logical-sexp 1)))
(scan-error nil))
sexp-positions))) I'll send PR later today or tomorrow if my fix is good enough |
Expected behavior
Emacs working fine
Actual behavior
Emacs freeze
Steps to reproduce the problem
do
(setq clojure-toplevel-inside-comment-form t)
then open clj file containingcomment
.Originally reported at emacs-lsp/lsp-mode#2698
Environment & Version information
clojure-mode version
Latest from melpa:
;; Package-Version: 20210307.824
;; Package-Commit: b5c913a
Emacs version
Emacs 27.1
Operating system
Linux
The text was updated successfully, but these errors were encountered: