mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
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 " ".
This commit is contained in:
parent
c1f73569be
commit
4c68c53804
1 changed files with 17 additions and 5 deletions
|
@ -46,11 +46,23 @@ Return a list of strings with result values of evaluation."
|
|||
(defun guix-geiser-eval-read (str &optional repl)
|
||||
"Evaluate STR with guile expression using Geiser REPL.
|
||||
Return elisp expression of the first result value of evaluation."
|
||||
;; Parsing scheme code with elisp `read' is probably not the best idea.
|
||||
(read (replace-regexp-in-string
|
||||
"#f\\|#<unspecified>" "nil"
|
||||
(replace-regexp-in-string
|
||||
"#t" "t" (car (guix-geiser-eval str repl))))))
|
||||
;; The goal is to convert a string with scheme expression into elisp
|
||||
;; expression.
|
||||
(let ((result (car (guix-geiser-eval str repl))))
|
||||
(cond
|
||||
((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)
|
||||
"Send CMD input string to the current REPL buffer.
|
||||
|
|
Loading…
Reference in a new issue