diff options
| author | jao <jao@gnu.org> | 2026-04-25 13:45:39 +0100 |
|---|---|---|
| committer | jao <jao@gnu.org> | 2026-04-25 13:45:39 +0100 |
| commit | 7bb18cd896e736fb90a0b5c2f945331fcabf0fbb (patch) | |
| tree | 3d68af546e1a58e99650739e81321f620d122f1c | |
| parent | db9a62cdfc197f5905f142ffebd1d5bcb978944c (diff) | |
| download | geiser-7bb18cd896e736fb90a0b5c2f945331fcabf0fbb.tar.gz geiser-7bb18cd896e736fb90a0b5c2f945331fcabf0fbb.tar.bz2 | |
avoiding sending repl inputs while evaluating requests (#78)
| -rw-r--r-- | elisp/geiser-connection.el | 5 | ||||
| -rw-r--r-- | elisp/geiser-eval.el | 8 | ||||
| -rw-r--r-- | elisp/geiser-repl.el | 25 |
3 files changed, 24 insertions, 14 deletions
diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el index 2d32d50..5f1e782 100644 --- a/elisp/geiser-connection.el +++ b/elisp/geiser-connection.el @@ -111,6 +111,9 @@ (cons :count 0) (cons :completed (make-hash-table :weakness 'value)))) +(defsubst geiser-con--pending-requests-p (c) + (not (tq-queue-empty (geiser-con--connection-tq c)))) + (defsubst geiser-con--connection-process (c) (tq-process (cdr (assq :tq c)))) @@ -274,7 +277,7 @@ (interrupt-process proc)))) (defun geiser-con--wait (req timeout) - "Wait up to TIMEOUT msecs for request REQ to finish, returning its result." + "Wait up to TIMEOUT msecs for request REQ to finish." (let* ((con (or (geiser-con--request-connection req) (error "Geiser connection not active"))) (proc (geiser-con--connection-process con)) diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el index 8f58c25..069dfb9 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, 2023 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009-2013, 2015, 2021, 2023, 2026 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 @@ -150,7 +150,8 @@ module-exports, autodoc, callers, callees and generic-methods.") (geiser-con--send-string (geiser-eval--connection) (geiser-eval--code-str code) (lambda (s) - (setq geiser-eval--async-retort (geiser-eval--log s)) + (setq geiser-eval--async-retort + (geiser-eval--log s)) (funcall cont s)) buffer)) @@ -167,6 +168,9 @@ module-exports, autodoc, callers, callees and generic-methods.") buffer) sync-retort)) +(defun geiser-eval--pending-requests-p () + (geiser-con--pending-requests-p (geiser-eval--connection))) + (defun geiser-eval-interrupt () "Interrupt on-going evaluation, if any." (interactive) diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 54cf6d8..84ff8ce 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -1,6 +1,6 @@ ;;; geiser-repl.el --- Geiser's REPL -*- lexical-binding: t; -*- -;; Copyright (C) 2009-2013, 2015-2016, 2018-2023 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009-2013, 2015-2016, 2018-2023, 2026 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 @@ -490,8 +490,8 @@ Returns the classification based on the first line of output. Only used when `geiser-repl-classify-output-p' is non-nil." (save-excursion (goto-char start) - (let ((first-line (buffer-substring-no-properties - start + (let ((first-line (buffer-substring-no-properties + start (min end (line-end-position))))) (cond ((string-match-p "raise-exception" first-line) :error) @@ -743,20 +743,23 @@ to standard output face." (defun geiser-repl--prepare-send () (geiser-image--clean-cache) (geiser-autodoc--inhibit-autodoc) + (geiser-eval--wait ) (geiser-con--connection-deactivate geiser-repl--connection)) (defun geiser-repl--send (cmd &optional save-history) "Send CMD input string to the current REPL buffer. If SAVE-HISTORY is non-nil, save CMD in the REPL history." (when (and cmd (eq major-mode 'geiser-repl-mode)) - (geiser-repl--prepare-send) - (goto-char (point-max)) - (comint-kill-input) - (insert cmd) - (let ((comint-input-filter (if save-history - comint-input-filter - 'ignore))) - (comint-send-input nil t)))) + (if (geiser-eval--pending-requests-p) + (message "Waiting for scheme process...") + (geiser-repl--prepare-send) + (goto-char (point-max)) + (comint-kill-input) + (insert cmd) + (let ((comint-input-filter (if save-history + comint-input-filter + 'ignore))) + (comint-send-input nil t))))) (defun geiser-repl-interrupt () (interactive) |
