diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/config-utilities.el | 28 | ||||
| -rw-r--r-- | modules/dashboard-config.el | 10 | ||||
| -rw-r--r-- | modules/dirvish-config.el | 10 | ||||
| -rw-r--r-- | modules/eat-config.el | 10 | ||||
| -rw-r--r-- | modules/elfeed-config.el | 5 | ||||
| -rw-r--r-- | modules/org-capture-config.el | 8 | ||||
| -rw-r--r-- | modules/org-reveal-config.el | 148 | ||||
| -rw-r--r-- | modules/prog-general.el | 8 | ||||
| -rw-r--r-- | modules/telega-config.el | 235 | ||||
| -rw-r--r-- | modules/test-runner.el | 26 | ||||
| -rw-r--r-- | modules/transcription-config.el | 26 | ||||
| -rw-r--r-- | modules/video-audio-recording.el | 41 |
12 files changed, 229 insertions, 326 deletions
diff --git a/modules/config-utilities.el b/modules/config-utilities.el index 4332f407..62fc29d0 100644 --- a/modules/config-utilities.el +++ b/modules/config-utilities.el @@ -196,27 +196,27 @@ Returns the count of files deleted." count user-emacs-directory))) (keymap-set cj/debug-config-keymap "c d" 'cj/delete-emacs-home-compiled-files) -(defun cj/compile-this-elisp-buffer () - "Compile the current .el: prefer native (.eln), else .elc. Message if neither." - (interactive) - (unless (and buffer-file-name (string-match-p "\\.el\\'" buffer-file-name)) - (user-error "Not visiting a .el file")) - (save-buffer) - (let ((file buffer-file-name)) +(defun cj/--compile-elisp-file (file &optional available-p) + "Compile FILE: prefer async native, then sync native, then byte-compile. +AVAILABLE-P decides which compilers exist; it defaults to `fboundp'. It is +a parameter so tests can force each branch without redefining `fboundp': +an `fset' on that subr pulls in comp-run and bytecomp, whose own `defun' +of `byte-compile-file' then lands on top of any test double." + (let ((available-p (or available-p #'fboundp))) (cond ;; Native compilation (async preferred) - ((fboundp 'native-compile-async) + ((funcall available-p 'native-compile-async) (native-compile-async file) (message "Queued native compilation for %s" file)) ;; Native compilation (sync, if async not available) - ((fboundp 'native-compile) + ((funcall available-p 'native-compile) (condition-case err (progn (native-compile file) (message "Native-compiled %s" file)) (error (message "Native compile failed: %s" (error-message-string err))))) ;; Byte-compile fallback - ((fboundp 'byte-compile-file) + ((funcall available-p 'byte-compile-file) (let ((out (byte-compile-file file))) (if out (message "Byte-compiled -> %s" out) @@ -224,6 +224,14 @@ Returns the count of files deleted." ;; Neither facility available (t (message "No compilation available (no native-compile, no byte-compile)"))))) + +(defun cj/compile-this-elisp-buffer () + "Compile the current .el: prefer native (.eln), else .elc. Message if neither." + (interactive) + (unless (and buffer-file-name (string-match-p "\\.el\\'" buffer-file-name)) + (user-error "Not visiting a .el file")) + (save-buffer) + (cj/--compile-elisp-file buffer-file-name)) (keymap-set cj/debug-config-keymap "c ." 'cj/compile-this-elisp-buffer) ;; --------------------------- Information Reporting --------------------------- diff --git a/modules/dashboard-config.el b/modules/dashboard-config.el index c7ff39dc..14e7bd71 100644 --- a/modules/dashboard-config.el +++ b/modules/dashboard-config.el @@ -66,7 +66,6 @@ (declare-function cj/music-playlist-toggle "music-config") (declare-function cj/music-playlist-load "music-config") (declare-function cj/erc-switch-to-buffer-with-completion "erc-config") -(declare-function cj/telega "telega-config") (declare-function cj/slack-start "slack-config") (declare-function cj/kill-all-other-buffers-and-windows "undead-buffers") @@ -156,17 +155,17 @@ Adjust this if the title doesn't appear centered under the banner image.") (list "m" #'nerd-icons-mdicon "nf-md-music" "Music" "EMMS Music Player" (lambda () (cj/music-playlist-toggle) (cj/music-playlist-load))) (list "e" #'nerd-icons-faicon "nf-fa-envelope" "Email" "Mu4e Email Client" (lambda () (mu4e))) (list "i" #'nerd-icons-faicon "nf-fa-comments" "IRC" "Emacs Relay Chat" (lambda () (cj/erc-switch-to-buffer-with-completion))) - (list "G" #'nerd-icons-faicon "nf-fa-telegram" "Telegram" "Telega Telegram Client" (lambda () (cj/telega))) (list "s" #'nerd-icons-faicon "nf-fa-slack" "Slack" "Slack Client" (lambda () (cj/slack-start))) (list "l" #'nerd-icons-octicon "nf-oct-issue_tracks" "Linear" "Linear Issue Tracker" (lambda () (pearl-list-issues)))) "Dashboard launcher table: (KEY ICON-FN ICON-NAME LABEL TOOLTIP ACTION). Drives both `dashboard-navigator-buttons' and the dashboard-mode-map keys.") -(defconst cj/dashboard--row-sizes '(5 4 3 2) +(defconst cj/dashboard--row-sizes '(5 4 2 2) "Navigator row lengths. Must sum to the number of `cj/dashboard--launchers'. The top row carries Weather alongside the core tools; the last row pairs Slack and Linear. (Signal left the table when the signel client was -retired to archive/ -- agents drive Signal via signal-cli.)") +retired to archive/ -- agents drive Signal via signal-cli. Telegram left +it when the telega client was retired the same way.)") (defun cj/dashboard--navigator-button (l) "Build a `dashboard-navigator-buttons' entry from launcher L." @@ -310,8 +309,7 @@ system-defaults) are preserved rather than overwritten." ;; Disable 'q' to quit dashboard (define-key dashboard-mode-map (kbd "q") nil) - ;; 'g' refreshes the dashboard (the dired/magit convention). Telegram moved to - ;; 'G' in the launcher table to free it. + ;; 'g' refreshes the dashboard (the dired/magit convention). (define-key dashboard-mode-map (kbd "g") #'dashboard-refresh-buffer) ;; Launcher keys, derived from `cj/dashboard--launchers' (same source as the diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el index 6c849198..e9b9fde6 100644 --- a/modules/dirvish-config.el +++ b/modules/dirvish-config.el @@ -29,7 +29,7 @@ ;; - S: Study — start an org-drill session on the .org file at point ;; - M-D (Meta-Shift-d): DWIM shell commands menu ;; - TAB: Toggle subtree expansion -;; - F11: Toggle sidebar view +;; - F9: Toggle sidebar view ;;; Code: @@ -653,7 +653,13 @@ no popup frame is live." (("C-x d" . dirvish) ("C-x C-d" . dirvish) ("C-x D" . dirvish) - ("<f11>" . dirvish-side) + ;; F9, not F11: F11 is stock Emacs's toggle-frame-fullscreen, the same key + ;; every other application uses, and the sidebar sat on it for years by + ;; shadowing that. F9 is the free bare F-key: ai-term left it for M-SPC + ;; in June 2026 and the recording chord came off it on 2026-09-22. F2 is + ;; the preview key (markdown-mode binds it) and F5 is reserved for the + ;; debug backend, so neither was a candidate. + ("<f9>" . dirvish-side) :map dirvish-mode-map ("bg" . cj/set-wallpaper) ("/" . dirvish-narrow) diff --git a/modules/eat-config.el b/modules/eat-config.el index f764848e..72f27bda 100644 --- a/modules/eat-config.el +++ b/modules/eat-config.el @@ -414,9 +414,9 @@ terminal. ai-term's agent buffers are managed separately via M-SPC." ;; ------------------- terminal copy mode + tmux history ----------------------- ;; Carried over from the ghostel era for the EAT agent terminals (ai-term). ;; Agents run EAT over tmux, so copy-mode is tmux's own copy-mode -- the same UX -;; ghostel-over-tmux had. C-<up> enters it and scrolls up in one stroke; C-; x c -;; enters it via the menu, C-; x h grabs the whole pane history into a buffer, -;; and C-; x d detaches the tmux client without going through its prefix. +;; ghostel-over-tmux had. C-<up> enters it and scrolls up in one stroke; C-; t c +;; enters it via the menu, C-; t h grabs the whole pane history into a buffer, +;; and C-; t d detaches the tmux client without going through its prefix. (declare-function cj/register-prefix-map "keybindings") (declare-function eat-emacs-mode "eat") @@ -628,13 +628,13 @@ pty; without tmux, moves point up in EAT's emacs-mode buffer." (cj/term-copy-mode-dwim)) (forward-line -1))))) -;; The C-; x terminal prefix (copy-mode, tmux detach, tmux history, the F12 +;; The C-; t terminal prefix (copy-mode, tmux detach, tmux history, the F12 ;; toggle). C-<up> ;; enters copy-mode + scrolls in one stroke; bound in EAT's semi-char map so it ;; reaches Emacs from inside an agent terminal. (defvar-keymap cj/term-map :doc "Personal terminal command map.") -(cj/register-prefix-map "x" cj/term-map) +(cj/register-prefix-map "t" cj/term-map "terminal menu") (keymap-set cj/term-map "c" #'cj/term-copy-mode-dwim) (keymap-set cj/term-map "d" #'cj/term-tmux-detach) (keymap-set cj/term-map "h" #'cj/term-tmux-history) diff --git a/modules/elfeed-config.el b/modules/elfeed-config.el index f4feef3a..34e90eb1 100644 --- a/modules/elfeed-config.el +++ b/modules/elfeed-config.el @@ -28,6 +28,11 @@ (require 'user-constants) (require 'system-lib) (require 'media-utils) +;; elfeed.el ends with a bare `(unless byte-compile-root-dir ...)'. That +;; variable lives in bytecomp, so loading elfeed (source or .elc) in a +;; session that hasn't loaded bytecomp signals void-variable. I load it here, ahead of +;; any elfeed load, rather than rely on something else having pulled it in. +(require 'bytecomp) (declare-function elfeed "elfeed") (declare-function elfeed-update "elfeed") diff --git a/modules/org-capture-config.el b/modules/org-capture-config.el index b7250f1e..8f5903fe 100644 --- a/modules/org-capture-config.el +++ b/modules/org-capture-config.el @@ -145,12 +145,16 @@ re-scanning large target files after the first successful lookup." :around #'cj/org-capture--set-target-location-advice)) ;; --------------------------- Capture F-Key Guard ----------------------------- -;; The global popup keys (F1 dashboard sweep, F10 music, F11 dirvish-side, +;; The global popup keys (F1 dashboard sweep, F9 dirvish-side, F10 music, ;; F12 terminal, M-SPC agent swap) fire even while a capture is in progress ;; and pop their UI over the capture popup. org-capture-mode is a minor ;; mode active exactly for the capture's duration and its keymap shadows ;; the global map, so blocking the keys there scopes the guard precisely: ;; the moment the capture finalizes or aborts, the keys work again. +;; +;; The list follows the command, not the key. F11 was on it while it held +;; dirvish-side; now that F11 is the frame fullscreen toggle it pops nothing +;; over a capture and stays usable. (defun cj/--org-capture-blocked-key () "Refuse a global popup key while a capture is in progress." @@ -160,7 +164,7 @@ re-scanning large target files after the first successful lookup." (defvar org-capture-mode-map) (with-eval-after-load 'org-capture - (dolist (key '("<f1>" "<f10>" "<f11>" "<f12>" "M-SPC")) + (dolist (key '("<f1>" "<f9>" "<f10>" "<f12>" "M-SPC")) (keymap-set org-capture-mode-map key #'cj/--org-capture-blocked-key))) ;; ----------------------- Project-Aware Capture Target ------------------------ diff --git a/modules/org-reveal-config.el b/modules/org-reveal-config.el index f842680b..ddb0803d 100644 --- a/modules/org-reveal-config.el +++ b/modules/org-reveal-config.el @@ -18,6 +18,10 @@ ;; Fully offline workflow using a local reveal.js clone (managed by ;; scripts/setup-reveal.sh) and self-contained HTML export. ;; +;; Slides use a 16:9 canvas with a smaller base font than the stock theme, +;; and a script in the export shrinks any slide whose content would +;; otherwise be clipped (see "Slide Sizing" below). +;; ;; Keybindings (C-; p prefix): ;; - C-; p SPC : Ensure headers, export, and open in browser ;; - C-; p e : Export to self-contained HTML and open in browser @@ -37,6 +41,8 @@ (defvar org-reveal-plugins) (defvar org-reveal-highlight-css) (defvar org-reveal-init-options) +(defvar org-reveal-head-preamble) +(defvar org-reveal-extra-script) (declare-function org-reveal-export-to-html "ox-reveal") ;; --------------------------------- Constants --------------------------------- @@ -51,6 +57,135 @@ (defconst cj/reveal-default-transition "none" "Default reveal.js slide transition for new presentations.") +;; ------------------------------- Slide Sizing -------------------------------- +;; +;; reveal.js lays every slide out on a fixed canvas and scales that canvas +;; to the window; content taller than the canvas is clipped, not scrolled. +;; Three things keep a dense slide readable instead of cut off: +;; +;; - a 16:9 canvas (the shape of every screen the slides land on), so lines +;; wrap later than on the stock 960x700 frame; +;; - a smaller base font and heading scale, set through the theme's CSS +;; variables in the head preamble so any reveal.js 4+ theme picks them up; +;; - a script, spliced in after Reveal.initialize, that shrinks any slide +;; whose content still overflows. It floors at half size: a slide that +;; overflows even there needs splitting, not shrinking. +;; +;; The script rides ox-reveal's extra-script slot, so a file that sets its +;; own #+REVEAL_EXTRA_SCRIPT replaces it. Print view (?print-pdf) paginates +;; instead of clipping, so the fit is skipped there and a printed deck can +;; differ from the presented one. + +(defconst cj/reveal-canvas-width 1280 + "Width of the reveal.js slide canvas in CSS pixels.") + +(defconst cj/reveal-canvas-height 720 + "Height of the reveal.js slide canvas in CSS pixels.") + +(defconst cj/reveal-base-font-size "30px" + "Base font size for slide text, as a px value. +The stock themes use 42px, which fits about six short lines on a slide. +Keep it in px: ox-reveal runs the head preamble through `format-spec', +so a % unit would break the export.") + +(defun cj/--reveal-init-options () + "Return the Reveal.initialize options shared by default and template. +One line with no trailing comma, so ox-reveal can splice it into the +Reveal.initialize call." + (format "slideNumber:true, hash:true, transition:'%s', width:%d, height:%d" + cj/reveal-default-transition + cj/reveal-canvas-width + cj/reveal-canvas-height)) + +(defun cj/--reveal-head-preamble () + "Return the <style> element for the document head. +Sets the house font sizes through the theme variables, stops the theme +from upper-casing headings, and left-aligns slide text (reveal centers +everything by default); the title slide and standalone images keep the +centering." + (format "<style> +:root { + --r-main-font-size: %s; + --r-heading1-size: 2.2em; + --r-heading2-size: 1.5em; + --r-heading3-size: 1.2em; + --r-heading4-size: 1em; +} +.reveal h1, .reveal h2, .reveal h3, .reveal p { text-transform: none; } +.reveal .slides section { text-align: left; } +.reveal .slides #sec-title-slide { text-align: center; } +.reveal .slides section .figure { text-align: center; } +</style>" + cj/reveal-base-font-size)) + +(defun cj/--reveal-fit-script () + "Return the JavaScript that shrinks overflowing slides to the canvas. +ox-reveal emits it inside the <script> element right after +Reveal.initialize, so Reveal already exists: every slide is fitted once +reveal is ready and the current one refitted on each slide change. +Hidden slides are shown for the measurement only, so the display state +reveal manages is restored before anything paints." + "// Shrink any slide whose content overflows the canvas height so it scales +// down instead of being clipped. Floors at half size: a slide that still +// overflows there needs splitting, not shrinking. +(function () { + var FLOOR = 0.5; // never below half size: split the slide instead + var MARGIN = 0.05; // breathing room above the bottom edge of the canvas + var PASSES = 8; // fixed-height content converges slowly; cap the loop + var busy = false; // layout() re-enters through slidechanged in scroll view + // Overview boxes every slide at the canvas height and print view paginates, + // so a measurement there is meaningless. + function skip() { + return (Reveal.isPrintView && Reveal.isPrintView()) + || (Reveal.isOverview && Reveal.isOverview()); + } + // Shrink SLIDE until it fits; return true when its font size changed. + function fit(slide) { + if (!slide || skip()) { return false; } + var limit = Reveal.getConfig().height * (1 - MARGIN); + var before = slide.style.fontSize; + var scale = 1; + slide.style.fontSize = ''; + for (var pass = 0; pass < PASSES && scale > FLOOR && slide.scrollHeight > limit; pass++) { + scale = Math.max(FLOOR, scale * limit / slide.scrollHeight); + slide.style.fontSize = (scale * 100).toFixed(1) + '%'; + } + if (scale === FLOOR && slide.scrollHeight > limit) { + console.warn('reveal fit: slide still overflows at half size, split it: ' + + (slide.id || '(no id)')); + } + return slide.style.fontSize !== before; + } + function shown(el, fn) { + var saved = el.style.display; + el.style.display = 'block'; + try { fn(); } finally { el.style.display = saved; } + } + function fitAll() { + busy = true; + try { + Reveal.getSlides().forEach(function (slide) { + var parent = slide.parentNode; + var run = function () { shown(slide, function () { fit(slide); }); }; + if (parent && parent.classList && parent.classList.contains('stack')) { + shown(parent, run); + } else { + run(); + } + }); + Reveal.layout(); + } finally { busy = false; } + } + function refit(slide) { + if (busy) { return; } + busy = true; + try { if (fit(slide)) { Reveal.layout(); } } finally { busy = false; } + } + if (Reveal.isReady()) { fitAll(); } else { Reveal.on('ready', fitAll); } + Reveal.on('slidechanged', function (event) { refit(event.currentSlide); }); + Reveal.on('overviewhidden', function () { refit(Reveal.getCurrentSlide()); }); +})();") + ;; --------------------------------- ox-reveal --------------------------------- (use-package ox-reveal @@ -60,10 +195,9 @@ (setq org-reveal-single-file t) (setq org-reveal-plugins '(highlight notes search zoom)) (setq org-reveal-highlight-css "%r/plugin/highlight/monokai.css") - (setq org-reveal-init-options (format "slideNumber:true, hash:true, transition:'%s'" - cj/reveal-default-transition)) - (setq org-reveal-head-preamble - "<style>.reveal h1,.reveal h2,.reveal h3,.reveal p{text-transform:none;}</style>")) + (setq org-reveal-init-options (cj/--reveal-init-options)) + (setq org-reveal-head-preamble (cj/--reveal-head-preamble)) + (setq org-reveal-extra-script (cj/--reveal-fit-script))) ;; ----------------------------- Private Helpers ------------------------------- @@ -76,15 +210,15 @@ #+DATE: %s #+REVEAL_ROOT: %s #+REVEAL_THEME: %s -#+REVEAL_INIT_OPTIONS: slideNumber:true, hash:true, transition:'%s' +#+REVEAL_INIT_OPTIONS: %s #+REVEAL_PLUGINS: (highlight notes search zoom) #+REVEAL_HIGHLIGHT_CSS: %%r/plugin/highlight/monokai.css -#+OPTIONS: toc:nil num:nil date:nil timestamp:nil author:t +#+OPTIONS: toc:nil num:nil date:nil timestamp:nil author:t ^:nil " title (user-full-name) (format-time-string "%Y-%m-%d") (concat "file://" cj/reveal-root) cj/reveal-default-theme - cj/reveal-default-transition)) + (cj/--reveal-init-options))) (defun cj/--reveal-title-to-filename (title) "Convert TITLE to a slug-based .org filename. diff --git a/modules/prog-general.el b/modules/prog-general.el index 77ff88a5..e9586a97 100644 --- a/modules/prog-general.el +++ b/modules/prog-general.el @@ -119,9 +119,11 @@ REGEXP must be a string or an rx form." ;; Manages tree-sitter grammars. Install is 'prompt, never t: with t, ;; merely opening a file could trigger a network download and a compiler -;; build mid-edit. Batch/test runs never load treesit-auto (no package -;; init), so they can never install. Fresh-machine bootstrap is the -;; explicit `cj/install-treesit-grammars' command below. +;; build mid-edit. `make test' runs with no package init and so never +;; loads treesit-auto, but a test file that calls `package-initialize' +;; itself does load it, and a tree-sitter mode then prompts for a missing +;; grammar; such tests must skip on `treesit-ready-p'. Fresh-machine +;; bootstrap is the explicit `cj/install-treesit-grammars' command below. (defun cj/treesit-auto-pin-go-revision (recipes) "Pin the Go grammar revision in treesit-auto RECIPES. Return the updated Go recipe, or nil when RECIPES has no Go entry. diff --git a/modules/telega-config.el b/modules/telega-config.el deleted file mode 100644 index b9b80481..00000000 --- a/modules/telega-config.el +++ /dev/null @@ -1,235 +0,0 @@ -;;; telega-config.el --- Telega Telegram client config -*- lexical-binding: t; coding: utf-8; -*- -;; author: Craig Jennings <c@cjennings.net> - -;;; Commentary: -;; -;; Layer: 4 (Optional). -;; Category: O/D/P. -;; Load shape: eager. -;; Eager reason: none; optional Telegram client that registers a keymap, a -;; command-loaded deferral candidate. -;; Top-level side effects: registers a telega keymap under cj/custom-keymap, -;; package config. -;; Runtime requires: keybindings. -;; Direct test load: yes (requires keybindings explicitly). -;; -;; Configures telega.el (https://github.com/zevlg/telega.el) as an -;; in-Emacs Telegram client. -;; -;; TDLib (Telegram Database Library) runs in a docker container via -;; `telega-use-docker' so a fresh-clone install does not need a -;; system-level TDLib build. The image is built locally from -;; =docker/telega-server/Dockerfile= with =make telega-image= (see the -;; pin section below for why it is not pulled from the registry); -;; =scripts/setup-telega.sh= covers the rest of a fresh clone. -;; -;; First-run auth (phone number + Telegram verification code) is -;; interactive and happens inside `M-x telega'. This module does not -;; script it. -;; -;; Install: -;; -;; M-x package-refresh-contents -;; M-x package-install RET telega -;; -;; The refresh is important. MELPA rotates dated snapshot tarballs out -;; from under the cached archive index periodically, so if the local -;; archive-contents file points at a snapshot that no longer exists on -;; the server the install fails with a 404. Refreshing pulls a current -;; index. This module deliberately sets `:ensure nil' so a stale -;; archive doesn't take Emacs init down at startup; if the package -;; isn't installed yet, `C-; T' surfaces a clear "install telega" error -;; until the install runs once. -;; -;; Launcher: =C-; T= (mnemonic: Telegram). Previously `C-; G' because -;; `T' was contested between org-table and transcription menus -- both -;; have been moved (org-table flattened under `C-; O', transcription -;; cleared to M-x), so `T' is now telega's outright. - -;;; Code: - -(require 'keybindings) -(require 'system-lib) ; cj/log-silently, used by the death alert - -(use-package telega - :defer t - :ensure nil - :commands (telega) - :custom - (telega-use-docker t) - :config - ;; Without this, incoming Telegram messages are invisible unless their - ;; buffer is on screen -- telega ships desktop notifications but leaves - ;; the mode off by default. Runs at telega load (M-x telega), respects - ;; telega's own per-chat mute settings. From the 2026-06 config audit; - ;; routing through a shared messenger notifier is the unification task. - (telega-notifications-mode 1)) - -;; --------------------------- telega Docker Image Pin ------------------------- -;; telega picks its container image in `telega-docker--image-name', which only -;; pins to a version tag when `telega-tdlib-min-version' equals -;; `telega-tdlib-max-version' and the version ends in ".0". Here min is -;; "1.8.66" and max is nil, so that test never passes and the image is always -;; "zevlg/telega-server:latest" -- a floating tag. The elpa package is fixed -;; at whatever version was installed, so the server can be replaced underneath -;; a static elisp without anything announcing it. -;; -;; The pin used to be a registry digest. It became a local tag on 2026-08-25: -;; the telega package raised its tdlib floor to 1.8.66, and upstream's only -;; image at that version fails to start (libglycin missing, -;; zevlg/telega.el#596). docker/telega-server/Dockerfile derives a working -;; image from that upstream digest plus the one missing package, and -;; `make telega-image' builds it under the tag below. The digest guarantee -;; now lives in the Dockerfile's FROM line; the Makefile owns the tag and a -;; test holds this default equal to it. Set to nil to hand the choice back -;; to telega. - -(defcustom cj/telega-docker-image - "cj/telega-server:1.8.66-glycin" - "Container image reference for `telega-server', or nil for telega's default. -The default names the image `make telega-image' builds locally from -docker/telega-server/Dockerfile, whose base is pinned by upstream digest. -It must match TELEGA_IMAGE in the Makefile; `cj/telega' refuses to launch -when the image is not present, since docker would otherwise try to pull a -local-only tag from the registry and fail confusingly." - :type '(choice (const :tag "Let telega infer the image" nil) - (string :tag "Image reference")) - :group 'telega-docker) - -(defun cj/--telega-docker-pinned-image () - "Return the configured image pin, or nil when none is usable. -A blank or non-string setting yields nil rather than reaching the docker -command line, where it would fail in a way that looks unrelated to this." - (when (stringp cj/telega-docker-image) - (let ((pin (string-trim cj/telega-docker-image))) - (unless (string-empty-p pin) pin)))) - -(defun cj/--telega-docker-image-name (orig-fun &rest args) - "Return the pinned telega-server image, else call ORIG-FUN with ARGS. -`:around' advice on `telega-docker--image-name', so clearing the pin -restores telega's own inference instead of breaking the image name." - (or (cj/--telega-docker-pinned-image) - (apply orig-fun args))) - -(with-eval-after-load 'telega-util - (advice-add 'telega-docker--image-name :around #'cj/--telega-docker-image-name)) - -;; ------------------------- telega-server Death Alert ------------------------- -;; telega's own sentinel reports an abnormal server exit with `message', which -;; scrolls out of the echo area unseen. That is how a dead server reads as a -;; quiet Telegram: the scan stops partway and the unscanned chats look like -;; chats with nothing in them. It has happened twice (2026-07-10, 2026-07-27), -;; caught both times only because something downstream noticed. A desktop -;; notification makes the death itself visible. - -(declare-function notifications-notify "notifications") - -(defun cj/--telega-server-death-p (status) - "Return non-nil when exit STATUS means the server died abnormally. -Any non-zero integer counts, which covers both a non-zero exit code and a -fatal signal number (`process-exit-status' reports SIGSEGV as 11). A -non-integer STATUS returns nil rather than signalling: this runs inside -telega's sentinel, where an error would abort telega's own cleanup." - (and (integerp status) - (not (zerop status)))) - -(defun cj/--telega-server-exit-status (proc) - "Return PROC's exit status, or nil when it can't be determined. -Guarded because the sentinel hands over whatever process object it has, -and a bad one must not break telega's status handling." - (condition-case nil - (and (processp proc) (process-exit-status proc)) - (error nil))) - -(defun cj/--telega-server-death-body (status event) - "Build the notification body for a server death with STATUS and EVENT. -EVENT is the sentinel's event string, which carries a trailing newline that -would render as dead space in a desktop notification." - (let ((detail (string-trim (or event "")))) - (concat (format "telega-server died (status %s). " status) - (unless (string-empty-p detail) (concat detail ". ")) - "Telegram coverage is down until it restarts."))) - -(defun cj/--telega-server-send-notification (title body) - "Deliver a desktop notification with TITLE and BODY. -Prefers the external notify script (persistent, so it waits rather than -auto-dismissing while away), falling back to `notifications-notify'. -Mirrors `cj/slack--send-notification'." - (let ((script (executable-find "notify"))) - (if script - (start-process "telega-death-notify" nil script "fail" title body "--persist") - (unless (fboundp 'notifications-notify) - (require 'notifications)) - (notifications-notify :title title :body body)))) - -(defun cj/--telega-server-notify-death (proc event) - "Notify when the telega-server PROC dies abnormally. EVENT is its event string. -Installed as `:after' advice on `telega-server--sentinel'. Silent on a -clean exit, so quitting telega deliberately never pages. - -The whole body is guarded: a notifier failure here would otherwise escape -into telega's sentinel and abort its status handling and relogin path." - (condition-case err - (let ((status (cj/--telega-server-exit-status proc))) - (when (cj/--telega-server-death-p status) - (cj/--telega-server-send-notification - "Telegram: telega-server died" - (cj/--telega-server-death-body status event)))) - (error - (cj/log-silently - (format "telega death notify failed: %s" (error-message-string err)))))) - -;; Named, never a lambda: anonymous advice can't be `advice-remove'd by -;; reference, so a live daemon keeps running it after the source stops -;; installing it. -(with-eval-after-load 'telega-server - (advice-add 'telega-server--sentinel :after #'cj/--telega-server-notify-death)) - -(defun cj/--telega-docker-image-present-p (image) - "Return non-nil when IMAGE exists in the local docker image store. -Uses `docker image inspect' rather than `docker images': the listing hides -digest-pulled and untagged images, and this check exists because that -listing lied once. Any failure (docker absent, daemon down) reads as -not-present, which routes the user to the same make target." - (condition-case nil - (zerop (call-process "docker" nil nil nil "image" "inspect" image)) - (error nil))) - -(defun cj/--telega-missing-image-message (image) - "Return the user-facing message for a pinned IMAGE that is not built yet." - (format "telega-server image %s is not built -- run `make telega-image' in %s" - image (abbreviate-file-name user-emacs-directory))) - -(defun cj/telega () - "Launch telega.el with a helpful message when it isn't installed yet. - -The =telega= Emacs package uses =:ensure nil= in this config so a -stale MELPA archive index can't take startup down with a 404. The -trade-off: a fresh clone needs a one-time install before this -launcher works. Without this wrapper, the autoload stub fails with -the cryptic =Cannot open load file: telega=; with it, the user gets -pointed at =scripts/setup-telega.sh= and the manual fallback. - -When `cj/telega-docker-image' is set, the image must already be built: -it is a local tag, so a missing one would send docker to the registry -for something that was never there. The check is skipped with no pin, -where telega infers and pulls its own image." - (interactive) - (unless (or (featurep 'telega) - (locate-library "telega")) - (user-error - (concat "telega not installed -- run scripts/setup-telega.sh, " - "or `M-x package-install RET telega'"))) - (let ((image (cj/--telega-docker-pinned-image))) - (when (and image (not (cj/--telega-docker-image-present-p image))) - (user-error "%s" (cj/--telega-missing-image-message image)))) - (telega)) - -(cj/register-command "T" #'cj/telega) - -(with-eval-after-load 'which-key - (which-key-add-key-based-replacements - "C-; T" "telegram (telega)")) - -(provide 'telega-config) -;;; telega-config.el ends here diff --git a/modules/test-runner.el b/modules/test-runner.el index 6cb35275..54d56974 100644 --- a/modules/test-runner.el +++ b/modules/test-runner.el @@ -6,7 +6,7 @@ ;; Layer: 2 (Core UX). ;; Category: C/L. ;; Load shape: eager. -;; Eager reason: registers the C-; t test runner entry point and state. +;; Eager reason: registers the C-; T test runner entry point and state. ;; Top-level side effects: defines and registers cj/test-map. ;; Runtime requires: ert, cl-lib, keybindings, system-lib. ;; Direct test load: yes. @@ -15,7 +15,7 @@ ;; Test roots come from Projectile projects, falling back to the config's tests ;; directory, and test files are discovered by the test-*.el convention. ;; -;; Commands under C-; t load tests, run all/focused tests, run the test at point, +;; Commands under C-; T load tests, run all/focused tests, run the test at point, ;; and manage the per-project focus list. ;;; Code: @@ -490,21 +490,21 @@ Returns the number of tests deleted." "v" #'cj/test-view-focused "t" #'cj/test-toggle-mode) -(cj/register-prefix-map "t" cj/testrunner-map) +(cj/register-prefix-map "T" cj/testrunner-map) ;; which-key integration (with-eval-after-load 'which-key (which-key-add-key-based-replacements - "C-; t" "test runner menu" - "C-; t L" "load all tests" - "C-; t R" "run all tests" - "C-; t r" "run smart" - "C-; t ." "run test at point" - "C-; t a" "add to focus" - "C-; t b" "add buffer to focus" - "C-; t c" "clear focus" - "C-; t v" "view focused" - "C-; t t" "toggle mode")) + "C-; T" "test runner menu" + "C-; T L" "load all tests" + "C-; T R" "run all tests" + "C-; T r" "run smart" + "C-; T ." "run test at point" + "C-; T a" "add to focus" + "C-; T b" "add buffer to focus" + "C-; T c" "clear focus" + "C-; T v" "view focused" + "C-; T t" "toggle mode")) (provide 'test-runner) ;;; test-runner.el ends here diff --git a/modules/transcription-config.el b/modules/transcription-config.el index 944063b8..f7813eaf 100644 --- a/modules/transcription-config.el +++ b/modules/transcription-config.el @@ -33,6 +33,11 @@ ;; - 'assemblyai: Cloud transcription with speaker diarization ;; API key retrieved from authinfo.gpg (machine api.assemblyai.com) ;; - 'local-whisper: Local transcription (requires whisper installed) +;; - 'ratio: Self-hosted whisper plus speaker diarization on my transcription +;; host, via scripts/ratio-transcribe (ssh queue; falls back to a local +;; worker when the host is unreachable). No API key. SPEAKERS=N in the +;; environment pins the diarizer's speaker count; 1 is right for a +;; recording that holds only one side of a call. ;; ;; NOTIFICATIONS: ;; - "Transcription started on <file>" @@ -56,7 +61,8 @@ "Transcription backend to use. - `openai-api': Fast cloud transcription via OpenAI API - `assemblyai': Cloud transcription with speaker diarization via AssemblyAI -- `local-whisper': Local transcription using installed Whisper") +- `local-whisper': Local transcription using installed Whisper +- `ratio': Self-hosted whisper plus diarization on my transcription host") (defvar cj/transcription-keep-log-when-done nil "Whether to keep log files after successful transcription. @@ -74,9 +80,11 @@ Status: running, complete, error") (defconst cj/--transcription-backends '((openai-api :script "oai-transcribe" :auth-host "api.openai.com" :env-var "OPENAI_API_KEY") (assemblyai :script "assemblyai-transcribe" :auth-host "api.assemblyai.com" :env-var "ASSEMBLYAI_API_KEY") - (local-whisper :script "local-whisper" :auth-host nil :env-var nil)) + (local-whisper :script "local-whisper" :auth-host nil :env-var nil) + (ratio :script "ratio-transcribe" :auth-host nil :env-var nil)) "Per-backend descriptors. Each entry: (SYMBOL :script S :auth-host H :env-var V). -`:auth-host' and `:env-var' are nil for local backends that need no API key.") +`:auth-host' and `:env-var' are nil for backends that need no API key: the +local whisper install, and the self-hosted ratio queue reached over ssh.") (defun cj/--backend-plist (backend) "Return the descriptor plist for BACKEND, or signal if unknown." @@ -470,9 +478,11 @@ duration is computed from START-TIME." "Switch transcription backend. Prompts with completing-read to select from available backends." (interactive) - (let* ((backends '(("assemblyai" . assemblyai) - ("openai-api" . openai-api) - ("local-whisper" . local-whisper))) + ;; Offer exactly the descriptor set. This used to carry its own list, so + ;; a backend added to the descriptors was reachable only by setq. + (let* ((backends (mapcar (lambda (entry) + (cons (symbol-name (car entry)) (car entry))) + cj/--transcription-backends)) (current (symbol-name cj/transcribe-backend)) (prompt (format "Transcription backend (current: %s): " current)) (choice (completing-read prompt backends nil t)) @@ -490,9 +500,7 @@ Prompts with completing-read to select from available backends." (define-key dirvish-mode-map (kbd "T") #'cj/transcribe-media-at-point)) ;; Reach the transcription commands via M-x. The previous `C-; T' -;; menu was retired so the top-level slot could go to telega (which -;; finally has a clean mnemonic at `C-; T' once nothing else is -;; fighting over the same key). +;; menu was retired to free that top-level slot. (provide 'transcription-config) ;;; transcription-config.el ends here diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el index 65a8612f..8fd3d23b 100644 --- a/modules/video-audio-recording.el +++ b/modules/video-audio-recording.el @@ -300,40 +300,13 @@ Changes take effect on the next recording (not the current one)." (cj/register-prefix-map "r" cj/record-map) -;; Fast chords for the two toggles, alongside C-; r v and C-; r a. F9 is free: -;; ai-term vacated the F9 family when its swap moved to M-SPC, and -;; `test-ai-term-f9-family-removed-globally' keeps it vacated. Both commands -;; still take a prefix argument, so C-u F9 prompts for the recording location. -(keymap-global-set "<f9>" #'cj/video-recording-toggle) -(keymap-global-set "S-<f9>" #'cj/audio-recording-toggle) - -(defvar eat-mode-map) -(defvar eat-semi-char-mode-map) -(defvar eat-char-mode-map) -(defvar eat-eshell-char-mode-map) - -;; EAT builds each input mode's keymap from key categories, and which categories -;; a mode claims is what decides whether a chord reaches Emacs at all. -;; -;; Semi-char mode -- the default, and where every agent buffer sits -- is built -;; from :ascii, :arrow and :navigation. It never claims function keys, so F9 -;; already fell through to the global map. The semi-char entry below is -;; belt-and-braces rather than the fix, which is why it reads as redundant. -;; -;; Char mode is the one that swallows F9. It adds :function, binding f1 through -;; f63 to eat-self-input, and it is a minor mode, so its map outranks -;; eat-mode-map. Without an entry here the pair splits in the worst possible -;; way: :function claims only the unmodified keys, so S-F9 would toggle audio in -;; a char-mode buffer while F9 went to the program under the cursor. That is a -;; recording you believe you started and didn't. -;; -;; Claiming both costs a char-mode program the use of F9. I would rather pay -;; that than ship a toggle that works for audio and silently fails for video. -(with-eval-after-load 'eat - (dolist (map (list eat-semi-char-mode-map eat-mode-map - eat-char-mode-map eat-eshell-char-mode-map)) - (keymap-set map "<f9>" #'cj/video-recording-toggle) - (keymap-set map "S-<f9>" #'cj/audio-recording-toggle))) +;; The toggles live only under C-; r. They had a fast chord (F9 video, S-F9 +;; audio, claimed in every EAT map too) until 2026-09-22: with Fn Lock on the +;; Framework 13 the F-key row sends plain function keys, and a bare F9 press +;; started a screen recording. Both chords went together, because a lone S-F9 +;; on a live F-key row is one fat-finger from an unwanted audio recording. +;; Both commands still take a prefix argument, so C-u C-; r v prompts for the +;; recording location. (with-eval-after-load 'which-key (which-key-add-key-based-replacements |
