Skip to content
Snippets Groups Projects
Commit 4c68c538 authored by Alex Kost's avatar Alex Kost
Browse files

emacs: Fix converting scheme into elisp expression.

* emacs/guix-geiser.el (guix-geiser-eval-read): Replace #f/#t with nil/t
  only when they follow "(" or " ".
parent c1f73569
No related branches found
No related tags found
No related merge requests found
...@@ -46,11 +46,23 @@ Return a list of strings with result values of evaluation." ...@@ -46,11 +46,23 @@ Return a list of strings with result values of evaluation."
(defun guix-geiser-eval-read (str &optional repl) (defun guix-geiser-eval-read (str &optional repl)
"Evaluate STR with guile expression using Geiser REPL. "Evaluate STR with guile expression using Geiser REPL.
Return elisp expression of the first result value of evaluation." Return elisp expression of the first result value of evaluation."
;; Parsing scheme code with elisp `read' is probably not the best idea. ;; The goal is to convert a string with scheme expression into elisp
(read (replace-regexp-in-string ;; expression.
"#f\\|#<unspecified>" "nil" (let ((result (car (guix-geiser-eval str repl))))
(replace-regexp-in-string (cond
"#t" "t" (car (guix-geiser-eval str repl)))))) ((or (string= result "#f")
(string= result "#<unspecified>"))
nil)
((string= result "#t")
t)
(t
(read (replace-regexp-in-string
"[ (]\\(#f\\)" "nil"
(replace-regexp-in-string
"[ (]\\(#t\\)" "t"
result
nil nil 1)
nil nil 1))))))
(defun guix-repl-send (cmd &optional save-history) (defun guix-repl-send (cmd &optional save-history)
"Send CMD input string to the current REPL buffer. "Send CMD input string to the current REPL buffer.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment