将大量文本粘贴到在tmux中运行的clojure repl中会导致错误并混淆文本 [英] pasting a large amount of text into the clojure repl running in tmux results in errors and mixed up text

查看:96
本文介绍了将大量文本粘贴到在tmux中运行的clojure repl中会导致错误并混淆文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将多个函数定义粘贴到在tmux中运行的clojure repl中。 (一般情况是粘贴大量代码)

I'm having trouble pasting multiple function definitions into the clojure repl running in tmux. (the general case is pasting over a large amount of code)

当我手动将以下clojure定义(作为一个粘贴操作)粘贴到clojure repl不在tmux中运行

When I manually paste the following clojure definitions (as one paste operation) into the clojure repl not running in tmux it pastes over fine.

但是当从tslime或直接运行clojure repl的tmux时,一些最终的def会得到他们的文本乱码,只有一些定义完成正常。

But when pasting from tslime or directly into tmux running the clojure repl, some of the final defs get their text garbled and only some of the definitions get completed properly. (gets screwy around the make-exponentiation def)

任何人都有这种感觉,或对任何可能发生的事情有任何想法?

Anyone else experience this or have any ideas on what might be going on?



; Some expiriments and exercises for 
; Lecture 3B of SICP


(ns deriv)

(defn variable? 
  [x] 
  (symbol? x))

(defn same-variable?
  [v1 v2]
  (and (variable? v1) (variable? v2) (= v1 v2))) 

(defn sum? 
  [x] 
  (and (seq? x) (= (first x) '+)))

(defn make-sum
  [a1 a2] 
  (cond 
    (= a1 0) a2 
    (= a2 0) a1
    (and (number? a1) (number? a2)) (+ a1 a2)
    :else (list '+ a1 a2)))

(defn make-product
  [a1 a2] 
  (cond 
    (or (= a1 0) (= a2 0)) 0
    (= a1 1) a2 
    (= a2 1) a1
    (and (number? a1) (number? a2)) (* a1 a2)
    :else (list '* a1 a2)))

(defn product?
  [x] 
  (and (seq? x) (= (first x) '*)))

(defn addend 
  [[op addend & augend]]
    addend)

(defn augend
  [[op addend & augend]] 
  (if (next augend)
    (conj augend '+)
    (first augend)))

(defn multiplier 
  [[op multiplier & multiplicand]]
    multiplier)

(defn multiplicand
  [[op multiplier & multiplicand]]
  (if (next multiplicand)
    (conj multiplicand '*)
    (first multiplicand)))


(defn exponentiation? 
  [x]
  (and (seq? x) (= (first x) '**)))

(defn base 
  [[op base exponent]] 
  base)

(defn exponent
  [[op base exponent]] 
  exponent)

(defn make-exponentiation
  [base exponent]
  (cond 
    (= exponent 0) 1
    (= exponent 1) base
    :else (list '** base exponent)))



(defn deriv
  [exp var] 
  (cond 
    (number? exp) 0
    (variable? exp) (if
                      (same-variable? exp var)
                      1
                      0)
    (sum? exp) (make-sum
                 (deriv (addend exp) var)
                 (deriv (augend exp) var))
    (product? exp) (make-sum
                     (make-product (multiplier exp)
                                   (deriv (multiplicand exp) var))
                     (make-product (multiplicand exp)
                                   (deriv (multiplier exp) var)))
    (exponentiation? exp) (make-product 
                            (deriv (base exp) var)
                            (make-product 
                              (exponent exp) 
                              (make-exponentiation 
                                (base exp)
                                (- (exponent exp) 1))))
    :else
      (throw (Exception. (str "unknown expression type -- DERIV " exp)))))



推荐答案

我通常使用emacs + swank / slime,没有问题。 JLine似乎也避免了这个问题。我试过rlwrap,而且注意到类似的行为。这最肯定似乎是一个rlwrap的问题。如果你想保持相同的REPL你正在使用我建议给JLine一试。你只需要下载jar并把它放在你的路径中或声明为一个Leiningen依赖。然后可以使用JLine支持启动REPL:

I use tmux almost daily. I normally use emacs + swank/slime and don't have issues. JLine seems to avoid this issue as well. I tried rlwrap instead and noticed similar behavior. This most certainly seems to be an rlwrap issue. If you want to keep the same REPL you are using I suggest giving JLine a try. You just need to download the jar and put it in your path or declare it as a Leiningen dependency. You can then start a REPL up with JLine support like so:

java -cp "lib/*:lib/dev/*" jline.ConsoleRunner clojure.main

之后你应该很好。

这篇关于将大量文本粘贴到在tmux中运行的clojure repl中会导致错误并混淆文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆