I have some elisp that runs an external 'npm' command.
(defun npm-mode-npm-run ()
"Run the 'npm run' command on a project script."
(interactive)
(let ((command
(completing-read
"Run command: " (npm-mode--get-project-scripts))))
(message "Running npm script: %s" command)
(switch-to-buffer npm-mode--buffer-name command)
(erase-buffer)
(ansi-term (getenv "SHELL") "npm-mode-npm-run")
(comint-send-string "*npm-mode-npm-run*" (format "npm run-script %s\n" command))))
While it does the job, when execution completes the user is left in a buffer that must be killed, and that requires additional confirmation to kill the process.
What I would like is once the program exits, I could press the 'q' key to do all of that, leaving the user in their original buffer.
Is their a good example of how to do this best for modern emacs that I could refer to, or any other specific docs that may be helpful?
Many thanks in advance!