From 6d5d96ecea46b6daeccfd7814ea3565e05068bdb Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 25 Aug 2023 18:29:50 +0300 Subject: [PATCH] fix(emacs-pkgs/term-switcher): apply tramp workaround to first vterm Change-Id: Idc01001856cb01104c20b62dc4221c0ad2ab7a3f Reviewed-on: https://cl.tvl.fyi/c/depot/+/9153 Tested-by: BuildkiteCI Autosubmit: tazjin Reviewed-by: tazjin --- tools/emacs-pkgs/term-switcher/term-switcher.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/emacs-pkgs/term-switcher/term-switcher.el b/tools/emacs-pkgs/term-switcher/term-switcher.el index 76c756f73..c141a5e9c 100644 --- a/tools/emacs-pkgs/term-switcher/term-switcher.el +++ b/tools/emacs-pkgs/term-switcher/term-switcher.el @@ -27,15 +27,18 @@ :type '(string) :group 'term-switcher) +(defun ts/create-vterm () + "Launch vterm, but don't open semi-broken vterms over TRAMP." + (if (file-remote-p default-directory) + (let ((default-directory "~")) + (vterm)) + (vterm))) + (defun ts/open-or-create-vterm (buffer) "Switch to the terminal in BUFFER, or create a new one if buffer is nil." (if buffer (switch-to-buffer buffer) - ;; Don't open semi-broken vterms over tramp. - (if (file-remote-p default-directory) - (let ((default-directory "~")) - (vterm)) - (vterm)))) + (ts/create-vterm))) (defun ts/is-vterm-buffer (buffer) "Determine whether BUFFER runs a vterm." @@ -55,6 +58,6 @@ :require-match t :action (lambda (match) (ts/open-or-create-vterm (cdr (assoc match terms))))) - (vterm)))) + (ts/create-vterm)))) (provide 'term-switcher)