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 clean ns" should keep namespace meta information #223

Closed
huahaiy opened this issue Sep 3, 2015 · 4 comments
Closed

"cljr clean ns" should keep namespace meta information #223

huahaiy opened this issue Sep 3, 2015 · 4 comments
Assignees
Labels

Comments

@huahaiy
Copy link

huahaiy commented Sep 3, 2015

Such as :doc and :author, etc, instead of removing them.

@expez
Copy link
Member

expez commented Sep 4, 2015

I can't reproduce, but I know this was a problem in the past. What's the output of M-x cljr-version (in emacs)?

If it's anything other than

clj-refactor 1.2.0-SNAPSHOT (package: 20150902.625), refactor-nrepl 1.2.0-SNAPSHOT

I'd appreciate if you upgraded, tried again, and posted a minimal example exhibiting the problem if it still persists.

@huahaiy
Copy link
Author

huahaiy commented Sep 4, 2015

Yes, I have the latest versions as shown above. The bug can be reproduced when there is a comment before the name space declaration. A minimal example follows:

;; ===========================================================================
;;
;; Copyright (c) Example Inc. All rights reserved.
;;
;; ===========================================================================

(ns ^{:doc "Important documentation"}
  example.core
  (:import java.io.ByteArrayInputStream)
  (:require [clj-time.core :as t]
            [clojure.string :as s]
            [clojure.java.io :as io]
            [taoensso.timbre :as timbre]))

(timbre/refer-timbre)

(defn foo
  "I don't do a whole lot."
  [x]
  (let [t (t/now)
        ss (ByteArrayInputStream. (io/file "afile.txt"))]
    (println (s/trim x) "Hello, World!")))

The presence of the copyright notice will trigger the bug. Removing it removes the bug, but it is common for copyright notice to appear at that position.

@expez expez self-assigned this Sep 4, 2015
@expez expez added the bug label Sep 4, 2015
expez added a commit to clojure-emacs/refactor-nrepl that referenced this issue Sep 5, 2015
If the file started with a comment, clean-ns, would fail to retrieve the
metadata.

Fixes clojure-emacs/clj-refactor.el#223
expez added a commit to clojure-emacs/refactor-nrepl that referenced this issue Sep 5, 2015
If the file started with a comment, clean-ns, would fail to retrieve the
metadata.

Fixes clojure-emacs/clj-refactor.el#223
@expez
Copy link
Member

expez commented Sep 5, 2015

I've deployed a new snapshot containing this fix. Thanks for the bug report @huahaiy!

@huahaiy
Copy link
Author

huahaiy commented Sep 5, 2015

Thanks for the quick fix.

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

No branches or pull requests

2 participants