commit 8f28c1dee82a931b4c92ef41ae933c1cf7b091e3 parent 9e17022c9a8b73da18908cba4fca2f1dd340431e Author: Vincent Demeester <vincent@sbr.pm> Date: Fri, 24 Sep 2021 10:21:58 +0200 tools/emacs: slowly switching to project.el Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | tools/emacs/config/config-projects.el | | | 29 | +++++++++++++++++++++++++++++ |
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/tools/emacs/config/config-projects.el b/tools/emacs/config/config-projects.el @@ -5,6 +5,35 @@ ;;; Note: this file is autogenerated from an org-mode file. ;;; Code: + +(use-package project + :bind (("C-x p v" . vde-project-magit-status) + ("C-x p s" . vde-project-vterm)) + :init + (defun vde-project-magit-status () + "Run `magit-status' on project." + (interactive) + (let* ((pr (project-current t)) + (dir (cdr pr))) + (magit-status dir))) + + (defun vde-project-vterm () + "Run `vterm' on project. +If a buffer already exists for running a vterm shell in the project's root, +switch to it. Otherwise, create a new vterm shell." + (interactive) + (let* ((default-directory (project-root (project-current t))) + (default-project-vterm-name (project-prefixed-buffer-name "vterm")) + (vterm-buffer (get-buffer default-project-vterm-name))) + (if (and vterm-buffer (not current-prefix-arg)) + (pop-to-buffer-same-window vterm-buffer) + (let* ((cd-cmd (concat " cd " (shell-quote-argument default-directory)))) + (vterm vterm-buffer) + (with-current-buffer vterm-buffer + (vterm-send-string cd-cmd) + (vterm-send-return)))))) + ) + (use-package projectile :unless noninteractive :commands