Created
May 27, 2026 14:33
-
-
Save aaronjensen/0ec335a4802b40d16dc02a17259f6848 to your computer and use it in GitHub Desktop.
Ghostel deprioritization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defvar c/ghostel-taskpolicy-command | |
| (when-let ((taskpolicy (and (eq system-type 'darwin) | |
| (executable-find "taskpolicy")))) | |
| (list taskpolicy "-c" "utility")) | |
| "Command prefix used to start Ghostel shells with lower macOS priority.") | |
| (defun c/ghostel--make-process-with-taskpolicy (make-process &rest args) | |
| "Apply `c/ghostel-taskpolicy-command' to Ghostel's spawned shell." | |
| (let ((command (plist-get args :command))) | |
| (when (and c/ghostel-taskpolicy-command | |
| (equal (plist-get args :name) "ghostel") | |
| (listp command) | |
| (not (equal (car command) (car c/ghostel-taskpolicy-command)))) | |
| (setq args (plist-put args :command | |
| (append c/ghostel-taskpolicy-command command)))) | |
| (apply make-process args))) | |
| (defun c/ghostel--spawn-pty-with-taskpolicy (spawn-pty &rest args) | |
| "Start Ghostel processes under macOS background scheduling policy." | |
| (let ((real-make-process (symbol-function 'make-process))) | |
| (cl-letf (((symbol-function 'make-process) | |
| (lambda (&rest plist) | |
| (apply #'c/ghostel--make-process-with-taskpolicy | |
| real-make-process plist)))) | |
| (apply spawn-pty args)))) | |
| ;; Reduces priority of ghostel so that the rest of Emacs is responsive, even | |
| ;; when running tests in several projects - Aaron, Wed May 27 2026 | |
| (advice-add #'ghostel--spawn-pty :around #'c/ghostel--spawn-pty-with-taskpolicy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment