Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns toucher.core
- (:require [clojure.java.io :as io]
- [robert.hooke :as rh :only [append]]))
- (defn- touch-file
- "Called on defn invocation; updates the mod time on the reload trigger
- file so LiveReload will reload the web page."
- [file-to-touch]
- (let [f (java.io.File. file-to-touch)]
- (if (.exists f)
- (.setLastModified f (System/currentTimeMillis))
- (with-open [w (io/writer f)]))))
- (defn touch-file-on-defn
- "Starts touching the specified file every time a function is defined.
- In your startup code, call
- (toucher.core/touch-file-on-defn \"some-filename.trigger\")
- and configure LiveReload to watch for changes to .trigger files in your
- directory. (Use whatever extension you want; .trigger has no special
- meaning.) Now when you send a function definition to the REPL either
- directly from the REPL prompt or remotely from vim-fireplace or another
- tool, LiveReload will see the update of the trigger file and automatically
- reload the web page so you don't have to remove focus from your terminal
- window."
- [file-to-touch]
- (rh/append defn (touch-file file-to-touch)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement