Fix split-window: restore syntax highlighting and font size in new panes

ober

0c533be9c865557b03b0b43c2c3883e7c68950fd

diff --git a/lib/jerboa-emacs/qt/highlight.sls b/lib/jerboa-emacs/qt/highlight.sls
index 03c4010..6617cdb 100644
--- a/lib/jerboa-emacs/qt/highlight.sls
+++ b/lib/jerboa-emacs/qt/highlight.sls
@@ -724,7 +724,7 @@
          (when lang
            (let ([lexer-name (and (not (memq
                                          lang
-                                         '(dired repl eshell shell)))
+                                         '(dired repl eshell)))
                                   (language->lexer-name lang))])
              (cond
                [(eq? lang 'org)
diff --git a/lib/jerboa-emacs/qt/window.sls b/lib/jerboa-emacs/qt/window.sls
index 243b0df..172e0ef 100644
--- a/lib/jerboa-emacs/qt/window.sls
+++ b/lib/jerboa-emacs/qt/window.sls
@@ -279,6 +279,31 @@
                          #f)])
          (qt-scintilla-setup-editor! new-ed)
          (qt-buffer-attach! new-ed buf)
+         (let loop ([i 0])
+           (when (<= i 127)
+             (sci-send/string
+               new-ed
+               SCI_STYLESETFONT
+               *default-font-family*
+               i)
+             (sci-send new-ed SCI_STYLESETSIZE i *default-font-size*)
+             (loop (+ i 1))))
+         (let ([ln-face (face-get 'line-number)])
+           (when (and ln-face (face-bg ln-face))
+             (let-values ([(r g b) (parse-hex-color (face-bg ln-face))])
+               (sci-send
+                 new-ed
+                 SCI_STYLESETBACK
+                 STYLE_LINENUMBER
+                 (rgb->sci r g b))
+               (sci-send new-ed 2260 0 (rgb->sci r g b))))
+           (when (and ln-face (face-fg ln-face))
+             (let-values ([(r g b) (parse-hex-color (face-fg ln-face))])
+               (sci-send
+                 new-ed
+                 SCI_STYLESETFORE
+                 STYLE_LINENUMBER
+                 (rgb->sci r g b)))))
          (qt-stacked-widget-add-widget! container new-ed)
          (qt-splitter-add-widget! container-parent container)
          (hash-put! *editor-window-map* new-ed new-win)
diff --git a/src/jerboa-emacs/qt/highlight.ss b/src/jerboa-emacs/qt/highlight.ss
index 49466de..bd38ba8 100644
--- a/src/jerboa-emacs/qt/highlight.ss
+++ b/src/jerboa-emacs/qt/highlight.ss
@@ -725,7 +725,7 @@
 (def (qt-reapply-highlighting! ed buf)
   (let ((lang (buffer-lexer-lang buf)))
     (when lang
-      (let ((lexer-name (and (not (memq lang '(dired repl eshell shell)))
+      (let ((lexer-name (and (not (memq lang '(dired repl eshell)))
                              (language->lexer-name lang))))
         (cond
           ((eq? lang 'org)
diff --git a/src/jerboa-emacs/qt/window.ss b/src/jerboa-emacs/qt/window.ss
index 0be6b54..5003ec4 100644
--- a/src/jerboa-emacs/qt/window.ss
+++ b/src/jerboa-emacs/qt/window.ss
@@ -303,6 +303,23 @@
          (new-win (make-qt-edit-window new-ed container buf lna #f #f)))
     (qt-scintilla-setup-editor! new-ed)
     (qt-buffer-attach! new-ed buf)
+    ;; Force font family+size on all styles (0-127).
+    ;; QsciLexer's setLexer() overrides style fonts, so we must re-apply
+    ;; after highlighting is set up by qt-buffer-attach!'s hook.
+    (let loop ((i 0))
+      (when (<= i 127)
+        (sci-send/string new-ed SCI_STYLESETFONT *default-font-family* i)
+        (sci-send new-ed SCI_STYLESETSIZE i *default-font-size*)
+        (loop (+ i 1))))
+    ;; Restore margin colors (font loop may corrupt line-number style)
+    (let ((ln-face (face-get 'line-number)))
+      (when (and ln-face (face-bg ln-face))
+        (let-values (((r g b) (parse-hex-color (face-bg ln-face))))
+          (sci-send new-ed SCI_STYLESETBACK STYLE_LINENUMBER (rgb->sci r g b))
+          (sci-send new-ed 2260 0 (rgb->sci r g b))))
+      (when (and ln-face (face-fg ln-face))
+        (let-values (((r g b) (parse-hex-color (face-fg ln-face))))
+          (sci-send new-ed SCI_STYLESETFORE STYLE_LINENUMBER (rgb->sci r g b)))))
     (qt-stacked-widget-add-widget! container new-ed)
     (qt-splitter-add-widget! container-parent container)
     (hash-put! *editor-window-map* new-ed new-win)