guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/07: emacs: Fix 'guix-devel-setup-repl'.


From: Alex Kost
Subject: 04/07: emacs: Fix 'guix-devel-setup-repl'.
Date: Fri, 09 Oct 2015 13:53:25 +0000

alezost pushed a commit to branch master
in repository guix.

commit 5a60d56975a67facbea41cb97fb4903453bf0752
Author: Alex Kost <address@hidden>
Date:   Tue Oct 6 20:30:16 2015 +0300

    emacs: Fix 'guix-devel-setup-repl'.
    
    Setting up guix ports needs to be done in Geiser REPL synchronously,
    otherwise this operation may not be finished before the further
    evaluating of guile code.
    
    * emacs/guix-guile.el (guix-guile-prompt?): New function.
    * emacs/guix-geiser.el (guix-geiser-eval-in-repl-synchronously): New
      function.
    * emacs/guix-devel.el (guix-devel-setup-repl): Use it.
---
 emacs/guix-devel.el  |    2 +-
 emacs/guix-geiser.el |   17 +++++++++++++++++
 emacs/guix-guile.el  |    5 +++++
 3 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index 1f760b6..b51fcee 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -79,7 +79,7 @@ Interactively, use the module defined by the current scheme 
file."
                           "(guix store)")
   ;; Without this workaround, the build output disappears.  See
   ;; <https://github.com/jaor/geiser/issues/83> for details.
-  (guix-geiser-eval-in-repl
+  (guix-geiser-eval-in-repl-synchronously
    "(current-build-output-port (current-error-port))"
    repl 'no-history 'no-display))
 
diff --git a/emacs/guix-geiser.el b/emacs/guix-geiser.el
index eb449bc..0e6cc03 100644
--- a/emacs/guix-geiser.el
+++ b/emacs/guix-geiser.el
@@ -80,6 +80,23 @@ If NO-DISPLAY is non-nil, do not switch to the REPL buffer."
     (unless no-display
       (geiser-repl--switch-to-buffer repl))))
 
+(defun guix-geiser-eval-in-repl-synchronously (str &optional repl
+                                                   no-history no-display)
+  "Evaluate STR in Geiser REPL synchronously, i.e. wait until the
+REPL operation will be finished.
+See `guix-geiser-eval-in-repl' for the meaning of arguments."
+  (let* ((repl (if repl (get-buffer repl) (guix-geiser-repl)))
+         (running? nil)
+         (filter (lambda (output)
+                   (setq running?
+                         (and (get-buffer-process repl)
+                              (not (guix-guile-prompt? output))))))
+         (comint-output-filter-functions
+          (cons filter comint-output-filter-functions)))
+    (guix-geiser-eval-in-repl str repl no-history no-display)
+    (while running?
+      (sleep-for 0.1))))
+
 (defun guix-geiser-call (proc &rest args)
   "Call (PROC ARGS ...) synchronously using the current Geiser REPL.
 PROC and ARGS should be strings."
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index 63322d7..cd6c54d 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -88,6 +88,11 @@ PROC and ARGS should be strings."
            args
            " ")))
 
+(defun guix-guile-prompt? (string)
+  "Return non-nil, if STRING contains a Guile prompt."
+  (or (string-match-p geiser-guile--prompt-regexp string)
+      (string-match-p geiser-guile--debugger-prompt-regexp string)))
+
 (provide 'guix-guile)
 
 ;;; guix-guile.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]