Last active
          January 1, 2019 18:39 
        
      - 
      
 - 
        
Save metametadata/c11044a5d490eac7158ae535c10ce45c to your computer and use it in GitHub Desktop.  
    Customized rebel-readline REPL
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (ns repl.rebel | |
| "Entry point for starting rebel-readline REPL. | |
| Inspired by rebel-readline.main. | |
| Usage: [LEIN_FAST_TRAMPOLINE=1] lein trampoline run -m repl.rebel [init-ns]" | |
| (:require [clojure.repl :as clj-repl] | |
| [rebel-readline.core :as rebel-core] | |
| [rebel-readline.clojure.main :as rebel-clj-main])) | |
| (defn -handle-sigint-form | |
| [] | |
| `(let [thread# (Thread/currentThread)] | |
| (clj-repl/set-break-handler! (fn [_signal#] (.stop thread#))))) | |
| (defn -main | |
| [& [init-ns]] | |
| (rebel-core/ensure-terminal | |
| (rebel-clj-main/repl* | |
| {:init (fn [] | |
| ; HACK: rebel-readline doesn't have a convenient way to change init ns (it's always `user`). | |
| ; See https://github.com/bhauman/rebel-readline/issues/157. | |
| (when (some? init-ns) | |
| (let [init-ns (symbol init-ns)] | |
| (require init-ns) | |
| (in-ns init-ns)))) | |
| :eval (fn [form] | |
| ; HACK: allows Ctrl+C to interrupt long running tasks. | |
| ; See https://github.com/bhauman/rebel-readline/issues/180#issuecomment-429057767. | |
| (eval `(do ~(-handle-sigint-form) ~form)))}))) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment