summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2023-03-05 15:21:57 +0000
committerjao <jao@gnu.org>2023-03-05 15:21:57 +0000
commitda990cb7e5c75f692cc2ff58c0a1a725d40ec7af (patch)
treec6434d6c318b94c54a291b3269f2ac014781dff7
parentbd12f2dc6c5949e260f094fb60737498cd0ae9a5 (diff)
downloadgeiser-da990cb7e5c75f692cc2ff58c0a1a725d40ec7af.tar.gz
geiser-da990cb7e5c75f692cc2ff58c0a1a725d40ec7af.tar.bz2
Avoid global state in sychronous evaluations
Fixes #60, as diagnosed and solved by Fabian Brosda: if an implementation is fast enough, new evaluations can override the result of eval/wait before it is used (this seems to be the case during completion).
-rw-r--r--elisp/geiser-eval.el17
1 files changed, 9 insertions, 8 deletions
diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el
index 91265d7..5c721a8 100644
--- a/elisp/geiser-eval.el
+++ b/elisp/geiser-eval.el
@@ -1,6 +1,6 @@
;;; geiser-eval.el -- sending scheme code for evaluation -*- lexical-binding: t; -*-
-;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2021 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2021, 2023 Jose Antonio Ortega Ruiz
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the Modified BSD License. You should
@@ -160,13 +160,14 @@ module-exports, autodoc, callers, callees and generic-methods.")
(setq geiser-eval--sync-retort (geiser-eval--log s)))
(defun geiser-eval--send/wait (code &optional timeout buffer)
- (setq geiser-eval--sync-retort nil)
- (geiser-con--send-string/wait (geiser-eval--connection)
- (geiser-eval--code-str code)
- 'geiser-eval--set-sync-retort
- timeout
- buffer)
- geiser-eval--sync-retort)
+ (let ((sync-retort nil))
+ (geiser-con--send-string/wait (geiser-eval--connection)
+ (geiser-eval--code-str code)
+ (lambda (s)
+ (setq sync-retort (geiser-eval--log s)))
+ timeout
+ buffer)
+ sync-retort))
(defun geiser-eval-interrupt ()
"Interrupt on-going evaluation, if any."