Public Vars

Back

spit (clj)

(source)

function

(spit f content & options)
Opposite of slurp. Opens f with writer, writes content, then closes f. Options passed to clojure.java.io/writer.

Examples

mikera/core.matrix
(ns clojure.core.matrix.impl.ndarray-object
  (:refer-clojure :exclude [vector?])
  (:require [clojure.walk :as w]
            [clojure.core.matrix.impl.defaults]
            [clojure.core.matrix.impl.ndarray-magic :as magic]
            [clojure.core.matrix.protocols :as mp]
            [clojure.core.matrix.implementations :as imp]
            [clojure.core.matrix.impl.mathsops :as mops]
            [clojure.core.matrix.macros :refer :all]
            [clojure.core.matrix.macros-clj :refer :all]
            [clojure.core.matrix.impl.ndarray-macro :refer :all]
            [clojure.core.matrix.impl.ndarray :refer :all]))

(magic/spit-code :object)
hraberg/deuce
(ns deuce.emacs.callproc
  (:use [deuce.emacs-lisp :only (defun defvar) :as el])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [clojure.java.io :as io]
            [clojure.java.shell :as sh]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.editfns :as editfns])
  (:import [java.io File])
  (:refer-clojure :exclude []))

  If BUFFER is 0, `call-process' returns immediately with value nil.
  Otherwise it waits for PROGRAM to terminate
  and returns a numeric exit status or a signal description string.
  If you quit, the process is killed with SIGINT, or SIGKILL if you quit again."
  (let [opts (if infile [:in (io/file infile)] [])
        no-wait? (= 0 buffer)
        buffer (or no-wait?
                   (and (data/consp buffer) (= :file (data/car buffer)) (data/cdr buffer))
                   (and (true? buffer) (buffer/current-buffer))
                   (el/check-type 'bufferp (or (when (data/consp buffer) (data/car buffer))
                                               buffer (buffer/current-buffer))))
        stderr (when (data/consp buffer) (data/cdr buffer))
        runner (if no-wait? #(do (future-call %) nil) #(%))]
    (runner #(let [{:keys [exit out err]}
                   (apply sh/sh (concat (cons program args) opts))]
               (when (data/bufferp buffer)
                 (binding [buffer/*current-buffer* buffer]
                   (editfns/insert out)
                   (when (true? stderr)
                     (editfns/insert err))))
               (when (string? buffer)
                 (spit (io/file buffer) out))
               (when (string? stderr)
                 (spit (io/file stderr) err))
               exit))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

;TODO
;cc/spit [java.io.Writer t/Any]
johnlawrenceaspden/hobby-code
(do (set! *warn-on-reflection* nil)
    (do nil 
        (try (clojure.core/require (quote clojure.tools.nrepl.server)) 
             (catch java.lang.Throwable t__6306__auto__ 
               (clojure.core/println "Error loading" (clojure.core/str (quote clojure.tools.nrepl.server) ":") 
                                     (clojure.core/or (.getMessage t__6306__auto__) (clojure.core/type t__6306__auto__)))))
        (try (clojure.core/require (quote complete.core))
             (catch java.lang.Throwable t__6306__auto__ (clojure.core/println "Error loading" (clojure.core/str (quote complete.core) ":") 
                                                                              (clojure.core/or (.getMessage t__6306__auto__) (clojure.core/type t__6306__auto__)))))
        [(println "hello from ~/.lein/profiles.clj")]
        ) 

    (clojure.core/let [server__6301__auto__ (clojure.tools.nrepl.server/start-server :bind "127.0.0.1" :port 4001 :ack-port 42615 :handler (clojure.tools.nrepl.server/default-handler))
                       port__6302__auto__ (clojure.core/-> server__6301__auto__ clojure.core/deref :ss .getLocalPort) 
                       repl-port-file__6303__auto__ (clojure.core/apply clojure.java.io/file ["/home/john/hobby-code" ".nrepl-port"])
                       legacy-repl-port__6304__auto__ (if 
                                                          (.exists (clojure.java.io/file "/home/john/hobby-code/target"))
                                                        (clojure.java.io/file "/home/john/hobby-code/target" "repl-port"))]
      (clojure.core/when false (clojure.core/println "nREPL server started on port" port__6302__auto__ "on host" "127.0.0.1"))
      (clojure.core/spit 
       (clojure.core/doto repl-port-file__6303__auto__ .deleteOnExit) 
       port__6302__auto__)
      (clojure.core/when legacy-repl-port__6304__auto__ 
        (clojure.core/spit (clojure.core/doto legacy-repl-port__6304__auto__ .deleteOnExit) port__6302__auto__))
      (clojure.core/deref (clojure.core/promise))))
tatut/re-html-template
(ns re-html-template.core-test
  (:require [re-html-template.core :refer [html-template html define-html-template]]
            [clojure.test :refer [deftest is testing]]
            [clojure.core.match :refer [match]]
            [clojure.string :as str]))

(deftest reload-test
  (spit "reload.html" "<html><body>INITIAL</body></html>")
  (let [tpl (binding [*ns* this-ns]
              (eval '(html-template
                      [x]
                      {:file "reload.html"
                       :selector "body"
                       :reload? true}
                      :body {:append-children x})))
        reloaded? (promise)]
    (add-watch re-html-template.core/reloads :reload-watcher
               (fn [& _]
                 (deliver reloaded? true)))
    (is (= [:body {} "INITIAL" 42]
           (tpl 42)))
    (spit "reload.html" "<html><body>RELOADED</body></html>")
    (is (deref reloaded? 5000 false)
        "reload didn't happen within 5 seconds")
    (is (= [:body {} "RELOADED" 666]
           (tpl 666)))))