2009年12月5日土曜日

slime + swank-clojureが動かない

Clojure with Emacs and Slime/Swank on Ubuntuを参考にemacs + slime + swank-clojureでプログラミングしてるのだけれど、
最近のslimeとswank-clojureの組み合わせがこける。
SLIME REPL broken
を参考に、

"/home/hokari/opt/swank-clojure/src/main/clojure/swank/core/protocol.clj"


@@ -4,6 +4,20 @@

 ;; Read forms

+  (def #^{:private true}

+     *percent-re* #"%")

+


+(defn- fix-percent

+  "Replace double colons with a /."

+  ([text] (.replaceAll (re-matcher *percent-re* text) "?")))

+

+(def #^{:private true}

+     *double-colon-re* #"::")


+

+(defn- fix-double-colon
+  "Replace double colons with a /."

+  ([text] (.replaceAll (re-matcher *double-colon-re* text) "/")))

+

(def #^{:private true}

      *namespace-re* #"(^\(:emacs-rex \([a-zA-Z][a-zA-Z0-9]+):")


 (defn- fix-namespace

@@ -50,7 +64,7 @@

   ([#^java.io.Reader reader]

      (let [len  (Integer/parseInt (read-chars reader 6 read-fail-exception) 16)

            msg  (read-chars reader len read-fail-exception)


-           form (read-string (fix-namespace msg))]

+           form (read-string (fix-namespace (fix-double-colon (fix-percent msg))))]

        (if (seq? form)


          (deep-replace {'t true} form)

          form))))

のようなかんじにしたら動いた。
Common LispとClojureで"%"や"::"の意味とか許可/不許可が違うせい、
ということみたい。

4 件のコメント:

  1. このコメントは投稿者によって削除されました。

    返信削除
  2. ありがとうございます。
    参考にさせていただきました。
    上記の方法ですと、(format "%d" 100)が"?d"となってしまうようなので、以下のようにしてみました。
    とりあえず動いているようです。
    ご参考までに。

    --- a/src/swank/core/protocol.clj
    +++ b/src/swank/core/protocol.clj
    @@ -4,6 +4,12 @@

    ;; Read forms
    (def #^{:private true}
    + *fix-message-re* #"::%(.*?)%")
    +
    +(defn- fix-message [text]
    + (.replaceAll (re-matcher *fix-message-re* text) "/?$1?"))
    +
    +(def #^{:private true}
    *namespace-re* #"(^\(:emacs-rex \([a-zA-Z][a-zA-Z0-9]+):")

    (defn- fix-namespace
    @@ -50,7 +56,8 @@
    ([#^java.io.Reader reader]
    (let [len (Integer/parseInt (read-chars reader 6 read-fail-exception) 16)
    msg (read-chars reader len read-fail-exception)
    - form (read-string (fix-namespace msg))]
    +;; form (read-string (fix-namespace msg))]
    + form (read-string (fix-namespace (fix-message msg)))]
    (if (seq? form)
    (deep-replace {'t true} form)
    form))))

    返信削除
  3. Merkur 15c Safety Razor - Barber Pole - Deccasino
    Merkur 15C Safety Razor - Merkur 바카라 사이트 - 15C for Barber Pole is febcasino the https://deccasino.com/review/merit-casino/ perfect https://septcasino.com/review/merit-casino/ introduction to the Merkur wooricasinos.info Safety Razor.

    返信削除
  4. Remember that you just always danger shedding the cash you wager, so do not spend more than find a way to|you probably can} afford to lose. To see all of our articles on poker rules and advice, go to our primary article on How To Play Poker. Video poker first became commercially viable when 토토사이트 it became economical to combine a television-like monitor with a strong state central processing unit. The earliest models appeared the identical time as|concurrently|simultaneously} the primary private computers have been produced, within the mid-1970s, although they have been primitive by at present's standards.

    返信削除