Skip to content
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

cljr-promote-function issues #505

Open
yuhan0 opened this issue Nov 16, 2021 · 1 comment
Open

cljr-promote-function issues #505

yuhan0 opened this issue Nov 16, 2021 · 1 comment

Comments

@yuhan0
Copy link
Contributor

yuhan0 commented Nov 16, 2021

Expected/Actual behavior

There appear to be several issues with the implementation of cljr--promote-function-literal (the #() -> fn case of cljr-promote-function)

  • Throws a "unbalanced parantheses" error when the #() form is at top level
#(foo %)
  • Does not support certain combinations of nested forms and multiple % args
(comment
  #(foo % (bar %2))
  )

;; => 

(comment
  (fn [a] (foo a (bar a2)))
  )
  • Enters a loop when a string contains "%"
(comment
  #(str "%%" %)
  )

I've proposed an alternative implementation of this feature in clojure-emacs/clojure-mode#601.

The cljr-promote-function command could delegate to it in the #()->fn case, replacing the current implementation while keeping the fn->defn logic.

Environment & Version information

clj-refactor.el version information

3.0.0alpha13

CIDER version information

;; CIDER 1.2.0snapshot, nREPL 0.8.3
;; Clojure 1.10.3, Java 13.0.2

Leiningen or Boot version

Emacs version

28.1

Operating system

macOS

@bbatsov
Copy link
Member

bbatsov commented Jan 2, 2022

The cljr-promote-function command could delegate to it in the #()->fn case, replacing the current implementation while keeping the fn->defn logic.

Fine by me. PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants