From bae17023d6a8b9bfed74502777ced1c7b35ab98d Mon Sep 17 00:00:00 2001 From: Ajai Khatri Nelson Date: Sun, 4 Jan 2026 22:39:08 -0500 Subject: [PATCH] fix(vterm): buffer read-only error after compiling If libvterm hasn't been compiled yet when vterm first loads, it'll offer to compile it for you. If you say yes, then vterm will switch to the compilation buffer. If vterm was autoloaded from a vterm-mode call, this is a problem: by the time the vterm-mode function runs, the current buffer will be the compilation buffer. The vterm-mode call will fail because the compilation buffer is read-only. Instead, we can explicitly require vterm before with-current-buffer so it's already loaded before we call vterm-mode. --- modules/term/vterm/autoload.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/term/vterm/autoload.el b/modules/term/vterm/autoload.el index 7fac10433..1f99a213c 100644 --- a/modules/term/vterm/autoload.el +++ b/modules/term/vterm/autoload.el @@ -34,6 +34,9 @@ Returns the vterm buffer." buffer-name) return buf) (get-buffer-create buffer-name)))) + ;; Explicitly require vterm before `with-current-buffer', since + ;; loading vterm can change the current buffer + (require 'vterm) (with-current-buffer buffer (unless (eq major-mode 'vterm-mode) (vterm-mode))