Fix split-window on terminal buffers; remove broken make binary target

ober

93b4b6c05e524228f42dea18617806349185e444

diff --git a/.gitignore b/.gitignore
index 66dcd2d..f64a1c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,5 @@ qt_chez_shim.so
 
 # Vendored repos (cloned, not submodules)
 vendor/jerboa-shell/
+vendor/**/*.so
+vendor/**/*.wpo
diff --git a/Makefile b/Makefile
index 3e44919..3277736 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ endif
 .PHONY: all build rebuild run test-tier0 test-tier2 test-tier3 test-tier4 test-tier5 test-org test-extra test clean clean-generated \
         test-org-duration test-org-element test-org-fold test-org-footnote \
         test-org-lint test-org-num test-org-property test-org-src test-org-tempo \
-        test-vtscreen test-debug-repl test-qt test-qt-e2e build-qt binary binary-qt \
+        test-vtscreen test-debug-repl test-qt test-qt-e2e build-qt binary-qt \
         test-pty test-emacs test-functional test-term-hang \
         docker-deps static-qt clean-docker check-root build-jemacs-qt-static macos \
         stress-run stress-run-static stress-test stress-burn stress-burn-static \
@@ -362,9 +362,6 @@ test-pty:
 test-term-hang:
 	$(SCHEME) $(LIBDIRS) --program tests/test-term-hang.ss
 
-binary: build
-	$(SCHEME) $(LIBDIRS) --script build-binary.ss
-
 binary-qt: build
 	$(SCHEME) $(LIBDIRS) --script build-binary-qt.ss
 
diff --git a/lib/jerboa-emacs/async.sls b/lib/jerboa-emacs/async.sls
index 15ba057..ba77478 100644
--- a/lib/jerboa-emacs/async.sls
+++ b/lib/jerboa-emacs/async.sls
@@ -552,8 +552,8 @@
        (let ([v (hashtable-ref
                   cache
                   key
-                  '#{miss n10hyshhs5dvwyk4xet3dh5q9-1})])
-         (if (eq? v '#{miss n10hyshhs5dvwyk4xet3dh5q9-2})
+                  '#{miss bcb63ld7l34ufb8flafhv2xj7-1})])
+         (if (eq? v '#{miss bcb63ld7l34ufb8flafhv2xj7-2})
              (if (null? default) #f (car default))
              v)))
   (def (weak-cache-set! cache key value)
diff --git a/lib/jerboa-emacs/qt/window.sls b/lib/jerboa-emacs/qt/window.sls
index 2f9b73d..8b04afc 100644
--- a/lib/jerboa-emacs/qt/window.sls
+++ b/lib/jerboa-emacs/qt/window.sls
@@ -338,6 +338,16 @@
               [cur-leaf (split-tree-find-leaf (qt-frame-root fr) cur-win)]
               [parent (split-tree-find-parent (qt-frame-root fr) cur-win)]
               [cur-buf (qt-edit-window-buffer cur-win)]
+              [new-buf (if (eq? (buffer-lexer-lang cur-buf) 'terminal)
+                           (or (find
+                                 (lambda (b)
+                                   (string=?
+                                     (buffer-name b)
+                                     buffer-scratch-name))
+                                 (map qt-edit-window-buffer
+                                      (qt-frame-windows fr)))
+                               cur-buf)
+                           cur-buf)]
               [main-win (qt-frame-main-win fr)]
               [saved-w (and main-win (qt-widget-width main-win))]
               [saved-h (and main-win (qt-widget-height main-win))])
@@ -349,7 +359,7 @@
                           (let* ([parent-spl (split-node-splitter parent)]
                                  [new-win (qt-make-new-window!
                                             parent-spl
-                                            cur-buf)]
+                                            new-buf)]
                                  [new-leaf (make-split-leaf new-win)])
                             (split-node-children-set!
                               parent
@@ -395,7 +405,7 @@
                             orientation)
                           (let* ([new-win (qt-make-new-window!
                                             root-spl
-                                            cur-buf)]
+                                            new-buf)]
                                  [new-leaf (make-split-leaf new-win)]
                                  [new-node (make-split-node
                                              orientation
@@ -441,7 +451,7 @@
                                       cur-container)]
                                  [new-win (qt-make-new-window!
                                             new-spl
-                                            cur-buf)]
+                                            new-buf)]
                                  [new-leaf (make-split-leaf new-win)]
                                  [new-node (make-split-node
                                              orientation
diff --git a/src/jerboa-emacs/qt/window.ss b/src/jerboa-emacs/qt/window.ss
index fecdf84..5afca93 100644
--- a/src/jerboa-emacs/qt/window.ss
+++ b/src/jerboa-emacs/qt/window.ss
@@ -388,6 +388,13 @@
          (cur-leaf  (split-tree-find-leaf (qt-frame-root fr) cur-win))
          (parent    (split-tree-find-parent (qt-frame-root fr) cur-win))
          (cur-buf   (qt-edit-window-buffer cur-win))
+         ;; Terminal buffers use a QTerminalWidget that can only live in one pane.
+         ;; Use scratch buffer for the new pane instead of the terminal buffer.
+         (new-buf   (if (eq? (buffer-lexer-lang cur-buf) 'terminal)
+                      (or (find (lambda (b) (string=? (buffer-name b) buffer-scratch-name))
+                                (map qt-edit-window-buffer (qt-frame-windows fr)))
+                          cur-buf)
+                      cur-buf))
          ;; Save main window geometry — adding widgets to a QSplitter can cause
          ;; Qt to resize the QMainWindow via sizeHint propagation.
          (main-win  (qt-frame-main-win fr))
@@ -402,7 +409,7 @@
         ;; ── Case A: parent has same orientation — add sibling ─────────────────
         ((and parent (= (split-node-orientation parent) orientation))
          (let* ((parent-spl (split-node-splitter parent))
-                (new-win    (qt-make-new-window! parent-spl cur-buf))
+                (new-win    (qt-make-new-window! parent-spl new-buf))
                 (new-leaf   (make-split-leaf new-win)))
            ;; Insert new-leaf after cur-leaf in parent's children
            (set! (split-node-children parent)
@@ -432,7 +439,7 @@
         ;; ── Case B: root is a leaf (very first split) ─────────────────────────
         ((split-leaf? (qt-frame-root fr))
          (qt-splitter-set-orientation! root-spl orientation)
-         (let* ((new-win  (qt-make-new-window! root-spl cur-buf))
+         (let* ((new-win  (qt-make-new-window! root-spl new-buf))
                 (new-leaf (make-split-leaf new-win))
                 (new-node (make-split-node orientation root-spl (list cur-leaf new-leaf))))
            (set! (qt-frame-root fr) new-node)
@@ -462,7 +469,7 @@
                 ;; Reparent cur-win's container into the new splitter
                 (_ (qt-splitter-add-widget! new-spl cur-container))
                 ;; Create new window in the new splitter
-                (new-win      (qt-make-new-window! new-spl cur-buf))
+                (new-win      (qt-make-new-window! new-spl new-buf))
                 (new-leaf     (make-split-leaf new-win))
                 (new-node     (make-split-node orientation new-spl
                                                (list cur-leaf new-leaf))))
diff --git a/todo.md b/todo.md
new file mode 100644
index 0000000..3bcff23
--- /dev/null
+++ b/todo.md
@@ -0,0 +1,15 @@
+# TODO
+
+## Static TUI binary
+
+Add a `make static-tui` target that produces a fully static `jemacs` TUI binary,
+analogous to `make static-qt` / `jemacs-qt`.
+
+- Write `build-binary.ss` (analogous to `build-binary-qt.ss` but for TUI/ncurses)
+- Add `make binary` target that runs `build-binary.ss` once the file exists
+- Add `make static-tui` using the same Docker-based Alpine musl build as `static-qt`
+- Output: `./jemacs` statically linked, no runtime `.so` dependencies
+- Should work the same as `make run` but as a portable single binary
+
+Note: `build-binary.ss` does not exist yet — `make binary` has been removed from
+the Makefile until it is implemented.