emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/eev e2a1b5e460: Rewrote `eepitch-sly'.


From: ELPA Syncer
Subject: [elpa] externals/eev e2a1b5e460: Rewrote `eepitch-sly'.
Date: Fri, 30 Dec 2022 15:57:34 -0500 (EST)

branch: externals/eev
commit e2a1b5e460bd3027eb20c2cfd27876fb1b2fef60
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>

    Rewrote `eepitch-sly'.
---
 ChangeLog  |  9 +++++++
 VERSION    |  4 +--
 eepitch.el | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 89 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c9d099f47f..d435b49c70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-12-30  Eduardo Ochs  <eduardoochs@gmail.com>
+
+       * eepitch.el (ee-wait-status): new variable.
+       (ee-wait-repl-started, ee-wait, find-slyprocess-reuse)
+       (find-slyprocess-create00, find-slyprocess-create0)
+       (find-slyprocess-create, find-slyprocess, eepitch-sly): new
+       functions. Some of the `find-sly*' functions are complete rewrites
+       of older experimental functions with the same names.
+
 2022-12-29  Eduardo Ochs  <eduardoochs@gmail.com>
 
        * eev-videolinks.el (ee-1stclassvideos-info): added an indication
diff --git a/VERSION b/VERSION
index 09270fa9e4..6e45b83d22 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Thu Dec 29 08:27:15 GMT 2022
-Thu Dec 29 05:27:15 -03 2022
+Fri Dec 30 20:05:46 GMT 2022
+Fri Dec 30 17:05:46 -03 2022
diff --git a/eepitch.el b/eepitch.el
index b0f07e163f..b1df45e7f7 100644
--- a/eepitch.el
+++ b/eepitch.el
@@ -48,6 +48,8 @@
 ;; «.other-terms»              (to "other-terms")
 ;;   «.eepitch-ansiterm»       (to "eepitch-ansiterm")
 ;;   «.eepitch-vterm»          (to "eepitch-vterm")
+;; «.wait-for-hooks»           (to "wait-for-hooks")
+;;   «.ee-wait»                        (to "ee-wait")
 ;;   «.eepitch-sly»            (to "eepitch-sly")
 ;;
 ;; «.eepitch-langs»            (to "eepitch-langs")
@@ -901,25 +903,94 @@ The arguments are explained here:
   (prog1 (eepitch `(find-vtermprocess ,program ,name0))
     (setq eepitch-line 'eepitch-line-vterm)))
 
+
+
+;;; __        __    _ _      __              _                 _        
+;;; \ \      / /_ _(_) |_   / _| ___  _ __  | |__   ___   ___ | | _____ 
+;;;  \ \ /\ / / _` | | __| | |_ / _ \| '__| | '_ \ / _ \ / _ \| |/ / __|
+;;;   \ V  V / (_| | | |_  |  _| (_) | |    | | | | (_) | (_) |   <\__ \
+;;;    \_/\_/ \__,_|_|\__| |_|  \___/|_|    |_| |_|\___/ \___/|_|\_\___/
+;;;                                                                     
+;; «wait-for-hooks»  (to ".wait-for-hooks")
+;; Some eepitch targets, like `eepitch-sly' and `eepitch-geiser',
+;; are hard to write because things like this
+;;
+;;   (save-window-excursion (sly))
+;;
+;; don't work - the (sly) above returns too soon, but Sly keeps
+;; running and doing things in the background... including things that
+;; change the window configuration, and these things are done outside
+;; the `save-window-excursion'.
+;;
+;; In august and december/2022 I sent these "issues" to the Sly
+;; developers,
+;;
+;;   https://github.com/joaotavora/sly/issues/527
+;;   https://github.com/joaotavora/sly/issues/550
+;;
+;; and then in 2022dec30 I finally found a way to create a "shell-like
+;; function" that opens a Sly REPL in the current window, reusing an
+;; existing one if possible. The main idea is to replace the `(sly)'
+;; above by something that only returns wither when a certain hook -
+;; `sly-mrepl-hook' - is run, or when a timeout occurs.
+;;
+;; THE CODE BELOW IS EXPERIMENTAL & VERY IMMATURE.
+
+;; «ee-wait»  (to ".ee-wait")
+;; Test: (setq ee-wait-status nil)
+;;       (run-at-time 2 nil 'ee-wait-repl-started)
+;;       (ee-wait 10 0.5)
+;;       ee-wait-status
+;;
+(defvar ee-wait-status nil)
+(defun  ee-wait-repl-started ()
+  (setq ee-wait-status 'repl-started))
+
+(defun ee-wait (ntimes time)
+  "Run NTIMES (sit-for TIME); aborts in some conditions."
+  (catch 'stop
+    (dotimes (i ntimes)
+      (if (not (sit-for time))
+         (throw 'stop 'got-input))
+      (if ee-wait-status
+         (throw 'stop 'ee-wait-status-not-nil)))
+    'timeout))
+
 ;; «eepitch-sly»  (to ".eepitch-sly")
-;; This is a prototype. See:
-;; https://github.com/joaotavora/sly/issues/527
-;; https://github.com/joaotavora/sly/issues/550
+;; THIS IS A PROTOTYPE!!!
 ;;
 (defun find-slyprocess-reuse ()
   "Go to a Sly REPL buffer (when we want to reuse an old one).
 This is an internal function used by `find-slyprocess'."
   (find-ebuffer (sly-mrepl--find-buffer) :end))
 
-(defun find-slyprocess-create ()
+(defun find-slyprocess-create00 ()
   "Go to a Sly REPL buffer (when we want to create a new one).
-This is an internal function used by `find-slyprocess'."
+This is an internal function used by `find-slyprocess-create0'."
   (let ((sly-command-switch-to-existing-lisp 'never)
        (sly-auto-select-connection 'never)
        (sly-lisp-implementations '((sbcl ("sbcl"))))
        (sly-default-lisp 'sbcl))
-    (save-window-excursion (sly))      ; TODO: fix this
-    (find-slyprocess-reuse)))
+    (sly)))
+
+(defun find-slyprocess-create0 ()
+  "Like `find-slyprocess-create0', but only returns when the mrepl starts.
+If the mrepl doesn't start in 30 seconds this function yields an error."
+  (interactive)
+  (unwind-protect
+      (progn
+       (setq ee-wait-status nil)
+       (add-hook 'sly-mrepl-hook 'ee-wait-repl-started)
+       (find-slyprocess-create00)
+       (ee-wait 60 0.5))
+    (remove-hook 'sly-mrepl-hook 'ee-wait-repl-started))
+  (if (eq ee-wait-status 'repl-started)
+      "Repl started!"
+    (error "ee-sly: Sly timed out")))
+
+(defun find-slyprocess-create ()
+  (save-window-excursion (find-slyprocess-create0))
+  (find-slyprocess-reuse))
 
 (defun find-slyprocess ()
   "Go to a Sly REPL buffer, This function is used by `eepitch-sly'."



reply via email to

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