<commit_before>(ns reply.initialization
  (:require [clojure.pprint]
            [clojure.repl]))

(defmacro repl-defn [sym & args]
  (let [no-meta-source (with-out-str (clojure.pprint/pprint `(defn ~sym ~@args)))
        meta-source `(clojure.core/defn ~(with-meta sym {:source no-meta-source}) ~@args)]
    meta-source))

(defmacro sourcery [name]
  `(if-let [s# (:source (meta (var ~name)))]
    (do (print s#) (flush))
    (clojure.repl/source ~name)))

(defn help
  "Prints a list of helpful commands."
  []
  (println "    Exit: Control+D or (exit) or (quit)")
  (println "Commands: (help)")
  (println "    Docs: (doc function-name-here)")
  (println "          (find-doc \"part-of-name-here\")")
  (println "  Source: (source function-name-here)")
  (println "          (sourcery function-name-here)")
  (println " Javadoc: (javadoc java-object-or-class-here)")
  (println "Examples from clojuredocs.org:")
  (println "          (clojuredocs name-here)")
  (println "          (clojuredocs \"ns-here\" \"name-here\")"))

(defn intern-with-meta [ns sym value-var]
  (intern ns
          (with-meta sym (meta value-var))
          @value-var))

(def resolve-class
  (fn [sym#]
    (try (let [val# (resolve sym#)]
      (when (class? val#) val#))
        (catch Exception e#
          (when (not= ClassNotFoundException
                      (class (clojure.main/repl-exception e#)))
            (throw e#))))))

(defn export-definition [s]
  (read-string (clojure.repl/source-fn s)))

(defn default-init-code
  "Assumes cd-client will be on the classpath when this is evaluated."
  []
  `(do
    (println "Welcome to REPL-y!")
    (println "Clojure" (clojure-version))

    (use '[clojure.repl :only ~'[source apropos dir]])
    ; doc and find-doc live in clojure.core in 1.2
    (when (ns-resolve '~'clojure.repl '~'pst)
      (refer 'clojure.repl :only '~'[pst doc find-doc]))

    (use '[clojure.java.javadoc :only ~'[javadoc]])
    (use '[clojure.pprint :only ~'[pp pprint]])

    ~(export-definition 'reply.initialization/help)
    ~(export-definition 'reply.main/exit)
    (def ~'quit ~'exit)

    (ns reply.exports)
    ~(export-definition 'reply.initialization/intern-with-meta)

    (~'intern-with-meta '~'user '~'quit #'user/exit)

    (binding [*err* (java.io.StringWriter.)]<commit_msg>No need for gensyms here anymore<commit_after>(ns reply.initialization
  (:require [clojure.pprint]
            [clojure.repl]))

(defmacro repl-defn [sym & args]
  (let [no-meta-source (with-out-str (clojure.pprint/pprint `(defn ~sym ~@args)))
        meta-source `(clojure.core/defn ~(with-meta sym {:source no-meta-source}) ~@args)]
    meta-source))

(defmacro sourcery [name]
  `(if-let [s# (:source (meta (var ~name)))]
    (do (print s#) (flush))
    (clojure.repl/source ~name)))

(defn help
  "Prints a list of helpful commands."
  []
  (println "    Exit: Control+D or (exit) or (quit)")
  (println "Commands: (help)")
  (println "    Docs: (doc function-name-here)")
  (println "          (find-doc \"part-of-name-here\")")
  (println "  Source: (source function-name-here)")
  (println "          (sourcery function-name-here)")
  (println " Javadoc: (javadoc java-object-or-class-here)")
  (println "Examples from clojuredocs.org:")
  (println "          (clojuredocs name-here)")
  (println "          (clojuredocs \"ns-here\" \"name-here\")"))

(defn intern-with-meta [ns sym value-var]
  (intern ns
          (with-meta sym (meta value-var))
          @value-var))

(def resolve-class
  (fn [sym]
    (try (let [val (resolve sym)]
      (when (class? val) val))
        (catch Exception e
          (when (not= ClassNotFoundException
                      (class (clojure.main/repl-exception e)))
            (throw e))))))

(defn export-definition [s]
  (read-string (clojure.repl/source-fn s)))

(defn default-init-code
  "Assumes cd-client will be on the classpath when this is evaluated."
  []
  `(do
    (println "Welcome to REPL-y!")
    (println "Clojure" (clojure-version))

    (use '[clojure.repl :only ~'[source apropos dir]])
    ; doc and find-doc live in clojure.core in 1.2
    (when (ns-resolve '~'clojure.repl '~'pst)
      (refer 'clojure.repl :only '~'[pst doc find-doc]))

    (use '[clojure.java.javadoc :only ~'[javadoc]])
    (use '[clojure.pprint :only ~'[pp pprint]])

    ~(export-definition 'reply.initialization/help)
    ~(export-definition 'reply.main/exit)
    (def ~'quit ~'exit)

    (ns reply.exports)
    ~(export-definition 'reply.initialization/intern-with-meta)

    (~'intern-with-meta '~'user '~'quit #'user/exit)

    (binding [*err* (java.io.StringWriter.)]
{'fraction_non_alphanumeric': 0.17579562675903876, 'fraction_numerical': 0.0008659883091578263, 'mean_word_length': 2.9622641509433962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5809887', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1687, 'n_words': 404}