Compile command can "send" commands to shells

With a |v or a |s, I can send the compile commands to a shell for
execution instead of showing it in a compilation buffer.
This commit is contained in:
Howard Abrams 2022-11-24 23:13:09 -08:00
parent 6a74607b85
commit 023b8d3063

View file

@ -428,7 +428,7 @@ What compile commands should I have on offer? Along with the values in =compile-
compile-command-list)))) compile-command-list))))
#+end_src #+end_src
My replacement to [[help:compile][compile]] just uses my new =completing-read= function: My replacement to [[help:compile][compile]] uses my new =completing-read= function:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun ha-project-compile (command) (defun ha-project-compile (command)
"Run `compile' from a list of directory-specific commands." "Run `compile' from a list of directory-specific commands."
@ -436,9 +436,30 @@ My replacement to [[help:compile][compile]] just uses my new =completing-read= f
(ha--compile-command-list) (ha--compile-command-list)
nil nil "" 'compile-history))) nil nil "" 'compile-history)))
(let ((default-directory (projectile-project-root))) (let ((default-directory (projectile-project-root)))
(compile command))) (cond
((string-match rx-compile-to-vterm command) (ha-compile-vterm command))
((string-match rx-compile-to-eshell command) (ha-compile-eshell command))
(t (compile command)))))
#+end_src #+end_src
If I end a command with a =|v=, it sends the compile command to a vterm session for the project, allowing me to continue the commands:
#+begin_src emacs-lisp
(defvar rx-compile-to-vterm (rx "|" (0+ space) "v" (0+ space) line-end))
(defun ha-compile-vterm (full-command &optional project-dir)
(unless project-dir
(setq project-dir (projectile-project-name)))
;; (add-to-list 'compile-history full-command)
(let ((command (replace-regexp-in-string rx-compile-to-vterm "" full-command)))
(ha-shell-send command project-dir)))
#+end_src
And what about sending stuff to Eshell as well?
#+begin_src emacs-lisp
(defvar rx-compile-to-eshell (rx "|" (0+ space) "s" (0+ space) line-end))
#+end_src
And lets add it to the Project leader: And lets add it to the Project leader:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(ha-leader "p C" 'ha-project-compile) (ha-leader "p C" 'ha-project-compile)