>From f127fc2ac741334340b650736b98ed15879a3be1 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sun, 24 Jan 2016 11:16:44 +0300 Subject: [PATCH] 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 " ". --- emacs/guix-geiser.el | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/emacs/guix-geiser.el b/emacs/guix-geiser.el index 0e6cc03..833f5bb 100644 --- a/emacs/guix-geiser.el +++ b/emacs/guix-geiser.el @@ -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\\|#" "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 "#")) + 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. -- 2.6.3