Skip to content

Commit

Permalink
Fix clean-ns sometimes deleting metadata
Browse files Browse the repository at this point in the history
If the file started with a comment, clean-ns, would fail to retrieve the
metadata.

Fixes clojure-emacs/clj-refactor.el#223
  • Loading branch information
expez committed Sep 5, 2015
1 parent 646ea62 commit 02e6c91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/refactor_nrepl/ns/pprint.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(:require [clojure
[pprint :refer [pprint]]
[string :as str]]
[refactor-nrepl.ns.helpers :refer [prefix-form?]]
[refactor-nrepl.util :as util]))
[refactor-nrepl.ns.helpers :as helpers :refer [prefix-form?]]))

(defn- libspec-vectors-last [libspecs]
(vec (concat (remove sequential? libspecs)
Expand Down Expand Up @@ -85,8 +84,8 @@
avoid duplication we have to remove some of the keys in the metadata
map before printing."
[path]
(let [meta? (-> path slurp util/get-next-sexp (.replaceFirst "\\^\\{" "\\{")
read-string second)]
(let [meta? (-> path slurp (.replaceFirst "\\^\\{" "\\{")
helpers/ns-form-from-string second)]
(when (map? meta?)
meta?)))

Expand Down
7 changes: 7 additions & 0 deletions test/resources/ns2_meta.clj
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
;; ===========================================================================
;;
;; Copyright (c) Example Inc. All rights reserved.
;;
;; https://github.com/clojure-emacs/clj-refactor.el/issues/223
;;
;; ===========================================================================
(ns ^{:author "Trurl and Klapaucius"
:doc "test ns with meta"}
resources.ns2-meta
Expand Down

0 comments on commit 02e6c91

Please sign in to comment.