From da990cb7e5c75f692cc2ff58c0a1a725d40ec7af Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 5 Mar 2023 15:21:57 +0000 Subject: 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). --- elisp/geiser-eval.el | 17 +++++++++-------- 1 file 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." -- cgit v1.2.3