aboutsummaryrefslogtreecommitdiff
path: root/modules/term-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/term-config.el')
-rw-r--r--modules/term-config.el74
1 files changed, 59 insertions, 15 deletions
diff --git a/modules/term-config.el b/modules/term-config.el
index f9c126357..c1c28911d 100644
--- a/modules/term-config.el
+++ b/modules/term-config.el
@@ -226,6 +226,15 @@ run its own project-named tmux session instead of a bare, auto-named one.
(ghostel-send-string "tmux\n"))))
(use-package ghostel
+ ;; PINNED at module 0.33.0 (ghostel-20260604.2049, the last pre-rework June-4
+ ;; build), installed directly into elpa/ rather than from MELPA. The 0.35.0-0.35.2
+ ;; native-PTY rework (worker threads + mutex-outside-read-loop) hard-crashes the
+ ;; whole Emacs process when a ghostel buffer is displayed: on Linux/glibc a
+ ;; SIGSETXID handler calls malloc while the main thread holds the arena lock
+ ;; (ghostel upstream #422); on macOS a recursive os_unfair_lock via
+ ;; run_window_change_functions (#423). `:ensure t' is satisfied by the present
+ ;; 0.33.0 dir and will NOT upgrade it -- do NOT `package-upgrade' ghostel until
+ ;; #422/#423 are fixed upstream, or it returns to the crashing 0.35.x.
:ensure t
:commands (ghostel)
:init
@@ -237,12 +246,13 @@ run its own project-named tmux session instead of a bare, auto-named one.
;; rebuild is what actually lets the key through to `ghostel-mode-map' / the
;; global map. C-; and F12 are the prefix + toggle; the modified arrows are
;; windmove (S-arrows, focus) and buffer-move (C-M-arrows, swap), which the
- ;; ai-term workflow expects to work from inside an agent buffer. F8, F10 and
- ;; C-F10 are global bindings (org agenda, music-playlist toggle, server
- ;; shutdown) that reach Emacs by falling through to the global map once the
- ;; semi-char map stops forwarding them.
+ ;; ai-term workflow expects to work from inside an agent buffer. F8 and F10
+ ;; are global bindings (org agenda, music-playlist toggle) that reach Emacs by
+ ;; falling through to the global map once the semi-char map stops forwarding
+ ;; them. (Server shutdown moved off C-F10 to C-x C, which is deliberately
+ ;; left forwarding to the terminal program inside an agent buffer.)
(with-eval-after-load 'ghostel
- (dolist (key '("C-;" "<f8>" "<f12>" "<f10>" "C-<f10>"
+ (dolist (key '("C-;" "<f8>" "<f12>" "<f10>"
"S-<up>" "S-<down>" "S-<left>" "S-<right>"
"C-M-<up>" "C-M-<down>" "C-M-<left>" "C-M-<right>"))
(add-to-list 'ghostel-keymap-exceptions key))
@@ -252,6 +262,12 @@ run its own project-named tmux session instead of a bare, auto-named one.
(ghostel-mode . cj/term-launch-tmux))
:custom
(ghostel-kill-buffer-on-exit t)
+ ;; Auto-download the prebuilt native module on first launch instead of the
+ ;; default `ask' prompt -- it fetches the platform release asset from GitHub
+ ;; (for the pinned 0.33.0 source this resolves to the matching v0.33.0 module).
+ ;; The compile-from-source fallback also works here: zig 0.15.2 is installed at
+ ;; /usr/local/bin/zig (see M-x ghostel-module-compile).
+ (ghostel-module-auto-install 'download)
;; Byte analog of the prior 100000-line vterm setting (~100 bytes/line) -- D7.
(ghostel-max-scrollback (* 10 1024 1024)))
@@ -264,18 +280,43 @@ run its own project-named tmux session instead of a bare, auto-named one.
;; which ai-term.el owns via F9.
(defcustom cj/term-toggle-window-height 0.7
- "Default fraction of frame height for the F12 terminal window."
+ "Default fraction of frame height for the F12 terminal window.
+Used as the size fallback when F12 docks the terminal as a bottom split."
:type 'number
:group 'term)
+(defcustom cj/term-toggle-window-width 0.5
+ "Default fraction of frame width for the F12 terminal window.
+Used as the size fallback when F12 docks the terminal as a right-side
+column (see `cj/--term-toggle-default-direction')."
+ :type 'number
+ :group 'term)
+
+(defun cj/--term-toggle-default-direction ()
+ "Return the default dock direction for the F12 terminal: `right' or `below'.
+Docks as a right-side column only when a side-by-side split would leave
+both panes at least `cj/window-dock-min-columns' wide (the terminal's
+share is `cj/term-toggle-window-width'); otherwise stacks below. See
+`cj/preferred-dock-direction'."
+ (cj/preferred-dock-direction (frame-width) cj/term-toggle-window-width))
+
+(defun cj/--term-toggle-default-size (direction)
+ "Return the default size fraction paired with DIRECTION for the F12 terminal.
+`cj/term-toggle-window-width' for `right', `cj/term-toggle-window-height'
+otherwise."
+ (if (eq direction 'right)
+ cj/term-toggle-window-width
+ cj/term-toggle-window-height))
+
(defvar cj/--term-toggle-last-direction nil
"Last user-chosen direction for the F12 terminal display.
Symbol: right, left, or below. `above' is never stored. nil means use the
default `below' for F12's traditional bottom split.")
(defvar cj/--term-toggle-last-size nil
- "Last user-chosen body size for the F12 terminal display.
-Positive integer: body-cols (right/left) or body-lines (below/above).
+ "Last user-chosen size for the F12 terminal display.
+Positive integer: body-cols (right/left) or total-lines (below/above) -- see
+`cj/window-replay-size' for why the vertical axis uses total, not body.
nil means fall back to `cj/term-toggle-window-height' as a fraction.")
(defun cj/--term-toggle-buffer-p (buffer)
@@ -306,9 +347,10 @@ FRAME defaults to the selected frame. Minibuffer is excluded."
(defun cj/--term-toggle-capture-state (window)
"Capture WINDOW's direction + body size into module-level state.
-Default direction is `below' to match F12's traditional bottom split."
+The default direction (used when WINDOW fills its frame) is the
+column-rule choice from `cj/--term-toggle-default-direction'."
(cj/window-toggle-capture-state
- window 'below
+ window (cj/--term-toggle-default-direction)
'cj/--term-toggle-last-direction
'cj/--term-toggle-last-size
'(right below left)))
@@ -316,11 +358,13 @@ Default direction is `below' to match F12's traditional bottom split."
(defun cj/--term-toggle-display-saved (buffer alist)
"Display-buffer action: split per saved direction and body size.
Delegates to `cj/window-toggle-display-saved' against the F12 state vars,
-falling back to `below' and `cj/term-toggle-window-height'."
- (cj/window-toggle-display-saved
- buffer alist
- 'cj/--term-toggle-last-direction 'below
- 'cj/--term-toggle-last-size cj/term-toggle-window-height))
+falling back to the column-rule default direction
+\(`cj/--term-toggle-default-direction') and its paired size."
+ (let ((dir (cj/--term-toggle-default-direction)))
+ (cj/window-toggle-display-saved
+ buffer alist
+ 'cj/--term-toggle-last-direction dir
+ 'cj/--term-toggle-last-size (cj/--term-toggle-default-size dir))))
(defun cj/--term-toggle-display-rule-list ()
"Return the `display-buffer-alist' entry list installed by F12.