clojure-emacs / clojure-ts-mode

The next generation Clojure major mode for Emacs, powered by TreeSitter
GNU General Public License v3.0
140 stars 13 forks source link

`M-x fill-paragraph` in comments regression vs `clojure-mode` #50

Closed stig closed 2 months ago

stig commented 2 months ago

Use the template below when reporting bugs. Please, make sure that you're running the latest stable clojure-ts-mode and that the problem you're reporting hasn't been reported (and potentially fixed) already.

Please, remove all of the placeholder text (the one in italics) in your final report!

Expected behavior

Clojure TS Mode should support comments being filled (using M-x fill-paragraph or similar) without disturbing surrounding code, like regular Clojure Mode.

Actual behavior

In Clojure TS Mode fill-paragraph will happily mangle surrounding code when attempting to do fill-paragraph on a comment.

Steps to reproduce the problem

This is extremely important! Providing us with a reliable way to reproduce a problem will expedite its solution.

Place cursor somewhere in the comment of this example, and invoke M-x fill-paragraph:

(defn hello []
  ;; hello world
  ;; bar
  (println "hello world"))

This produces the following token salad:

(defn hello [] ;; hello world ;; bar (println "hello world"))

Instead I would expect to see this instead (and regular Clojure Mode does this)

(defn hello []
  ;; hello world bar
  (println "hello world"))

Environment & Version information

clojure-ts-mode version

clojure-ts-mode 0.2.2 (package: 20240725.1139)

tree-sitter-clojure grammar version

v0.0.12

Emacs version

GNU Emacs 29.4 (build 1, aarch64-apple-darwin23.5.0, NS appkit-2487.60 Version 14.5 (Build 23F79))

Operating system

MacOS

dannyfreeman commented 2 months ago

Hello thanks for opening a ticket.

I am unable to reproduce this. Can you try to see if this bad fill-paragraph behavior still occurs when you use clojure-ts-mode when running Emacs with emacs -Q? When I run with emacs -Q on linux with emacs 29.4 I get the expected behavior.

stig commented 2 months ago

I did some binary searching, and found that this patch to my config fixes the issue:

@@ -385,7 +385,7 @@
 (add-hook 'message-mode-hook #'orgalist-mode)
 (add-hook 'git-commit-setup-hook #'orgalist-mode)
 (add-hook 'markdown-mode-hook #'orgalist-mode)
-(add-hook 'prog-mode-hook #'orgalist-mode)
+;; (add-hook 'prog-mode-hook #'orgalist-mode)

 (require 'subword)
 (add-hook 'prog-mode-hook #'subword-mode)

I can live with that :-)