From 8f354329dd23c48a1b018dae1150f3e6b8193a59 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 12 Oct 2023 16:56:14 -0700 Subject: [PATCH] Some work on vterm stuff --- init.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/init.el b/init.el index 5a33f73..9d72740 100644 --- a/init.el +++ b/init.el @@ -457,16 +457,17 @@ visual states." ;; project.el (use-package project - :bind (:map project-prefix-map + :bind (("C-x C-a" . my/project-vterm-or-default) + :map project-prefix-map ("s" . my/project-vterm) ("u" . my/project-run)) :init (defvar my/project-vterm-hash-table (make-hash-table :test 'equal) "Hash table that maps project root dirs to vterm buffers.") - (defun my/project-vterm () + (defun my/project-vterm (prompt) "Switch to or create a vterm buffer in the current projects root." - (interactive) - (if-let ((proj (project-current t)) + (interactive (list t)) + (if-let ((proj (project-current prompt)) (default-directory (project-root proj))) (if-let ((vterm-buff (gethash default-directory my/project-vterm-hash-table)) @@ -475,6 +476,14 @@ visual states." (puthash default-directory (vterm (concat "*vterm for project " default-directory "*")) my/project-vterm-hash-table)))) + (defun my/project-vterm-or-default () + "Open a vterm for the current project, otherwise, open a normal vterm." + (interactive) + (unless (my/project-vterm nil) + (if-let ((vterm-buff (gethash nil my/project-vterm-hash-table)) + ((buffer-live-p vterm-buff))) + (switch-to-buffer vterm-buff) + (puthash nil (vterm vterm-buffer-name) my/project-vterm-hash-table)))) (defvar my/project-run-command nil "Command to run with `my/project-run'.") (put 'my/project-run-command 'safe-local-variable (lambda (val) @@ -551,8 +560,7 @@ COMMAND and COMINT are like `compile'." ;; vterm (use-package vterm - :hook (vterm-mode . with-editor-export-editor) - :bind ("C-x C-a" . vterm)) + :hook (vterm-mode . with-editor-export-editor)) ;; proced (use-package proced