clojure-mode icon indicating copy to clipboard operation
clojure-mode copied to clipboard

`clojure-sort-ns` does not handle forms like :gen-class

Open xiongtx opened this issue 6 years ago • 2 comments

Expected behavior

clojure-sort-ns should handle the whole ns form, including :gen-class.

Actual behavior

clojure-sort-ns chokes on forms like :gen-class.

Steps to reproduce the problem

Create a .clj file w/ the following ns form:

(ns foo
  (:gen-class
   :methods [[methodOne [] String]
             [methodTwo [] String]]
   :init init))

Run clojure-sort-ns and see that the form is mangled:

(ns foo
  (:gen-class
   :methods [[methodOne [] String]
             :init init
             [methodTwo [] String]]))

Environment & Version information

clojure-mode version information

20190105.1043

Emacs version

26.1

Operating system

Fedora 28

xiongtx avatar May 28 '19 02:05 xiongtx

I wonder if we would be able to persuade @yuhan0 to take a stab at this one. 😉

bbatsov avatar Mar 21 '20 08:03 bbatsov

I tried running clojure-sort-ns on the above form and it produced

(ns foo
  (:gen-class
   :init init
             :methods [[methodOne [] String]
   [methodTwo [] String]]))

which after manual indentation becomes

(ns foo
  (:gen-class
   :init init
   :methods [[methodOne [] String]
             [methodTwo [] String]]))

Maybe this already got fixed in the meantime?

yuhan0 avatar Mar 21 '20 10:03 yuhan0