Commit 6fc13c16b79a

Vincent Demeester <vincent@sbr.pm>
2026-06-29 11:40:53
feat(emacs): add project-scoped ghostel terminal
Added vde/project-ghostel bound to C-x p t and project switch menu. Reuses existing buffer per project root.
1 parent 18d7bab
Changed files (2)
dots
config
dots/config/emacs/site-lisp/project-func.el
@@ -16,6 +16,9 @@
 ;; Declare eat functions for byte-compiler
 (declare-function eat "eat")
 
+;; Declare ghostel functions for byte-compiler
+(declare-function ghostel "ghostel")
+
 ;; Declare magit functions for byte-compiler
 (declare-function magit-status "magit")
 
@@ -178,6 +181,23 @@ if one already exists."
 	(pop-to-buffer eat-buffer (bound-and-true-p display-comint-buffer-action))
       (eat shell))))
 
+;;;###autoload
+(defun vde/project-ghostel ()
+  "Run ghostel in the current project's root directory.
+If a ghostel buffer already exists for the project, switch to it.
+Otherwise, create a new ghostel buffer."
+  (interactive)
+  (defvar ghostel-buffer-name)
+  (let* ((default-directory (project-root (project-current t)))
+         (ghostel-buffer-name (project-prefixed-buffer-name "ghostel"))
+         (buf (seq-find (lambda (b)
+                          (string-match-p (regexp-quote ghostel-buffer-name)
+                                          (buffer-name b)))
+                        (buffer-list))))
+    (if (and buf (not current-prefix-arg))
+        (pop-to-buffer-same-window buf)
+      (ghostel))))
+
 ;;;###autoload
 (defun vde/project-magit-status ()
   "Run `magit-status' on project."
dots/config/emacs/init.el
@@ -903,7 +903,7 @@ minibuffer, even without explicitly focusing it."
   :bind (("C-x v B" . vde/vc-browse-remote)))
 
 (use-package project-func
-  :commands (vde/project-magit-status vde/project-eat vde/project-vterm vde/project-run-in-vterm vde/project-try-local vde/open-readme))
+  :commands (vde/project-magit-status vde/project-eat vde/project-vterm vde/project-run-in-vterm vde/project-ghostel vde/project-try-local vde/open-readme))
 
 (use-package project
   :commands (project-find-file project-find-regexp)
@@ -918,6 +918,7 @@ minibuffer, even without explicitly focusing it."
 			     (?e "Eshell" project-eshell)
 			     (?E "Eat" vde/project-eat)
 			     (?s "Vterm" vde/project-vterm)
+			     (?G "Ghostel" vde/project-ghostel)
 			     (?R "README" vde/open-readme)
 			     (?g "Checkout GitHub PR" checkout-github-pr)))
   (project-mode-line t)
@@ -928,6 +929,7 @@ minibuffer, even without explicitly focusing it."
   ("C-x p s" . vde/project-vterm)
   ("C-x p X" . vde/project-run-in-vterm)
   ("C-x p E" . vde/project-eat)
+  ("C-x p t" . vde/project-ghostel)
   ("C-x p G" . checkout-github-pr)
   ("C-x p F" . flymake-show-project-diagnostics)
   ("C-x p R" . vde/project-refresh-list)