clojure-emacs / clj-refactor.el

A CIDER extension that provides powerful commands for refactoring Clojure code.
GNU General Public License v3.0
771 stars 111 forks source link

`cljr-sort-project-dependencies` drop :dependencies section when using managed-dependencies #520

Open iomonad opened 2 years ago

iomonad commented 2 years ago

Expected behavior

When using :managed-dependencies in a leiningen project, the :dependencies section is dropped while using cljr-sort-project-dependencies instead of being sorted

Steps to reproduce the problem

Assuming this project.clj file:

(defproject superfun/happyslide "1.0.0-SNAPSHOT"
  :description "A Clojure project with managed dependencies"
  :min-lein-version  "2.7.0"
  :managed-dependencies [[clj-time "0.12.0"]
                         [me.raynes/fs "1.4.6"]
                         [ring/ring-codec "1.0.1"]]
  :dependencies [[clj-time]
                 [me.raynes/fs]])

After: M-x cljr-sort-project-dependencies

Buffer is updated as follow:

(defproject superfun/happyslide "1.0.0-SNAPSHOT"
  :description "A Clojure project with managed dependencies"
  :min-lein-version  "2.7.0"
  :managed-dependencies [[clj-time "0.12.0"]
                         [me.raynes/fs "1.4.6"]
                         [ring/ring-codec "1.0.1"]]
  :dependencies )

Environment & Version information

clj-refactor.el version information

clj-refactor 2.5.1 (package: 20210628.1154), refactor-nrepl 2.5.1

CIDER version information

;; CIDER 1.2.0snapshot (package: 20210812.654), nREPL 0.9.0-beta1
;; Clojure 1.8.0, Java 1.8.0_302

Leiningen or Boot version

Leiningen 2.9.5 on Java 1.8.0_302 OpenJDK 64-Bit Server VM GraalVM CE 20.3.3

Emacs version

GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6) of 2022-04-09

Operating system

Linux 5.15.25-gentoo x86_64

vemv commented 2 years ago

Hi! Thanks for the report.

Perhaps there's an easy fix but probably nobody will spontaneously look at it. If you could check out the .el code, that would be much appreciated.

btw there's https://github.com/kkinnear/zprint/blob/1.2.3/doc/reference.md#sort-dependencies

iomonad commented 2 years ago

Thanks, I'll try to find a way to correct this on free time :+1: