If I start a new terminal with something like toggle-term-eat or toggle-term-vterm, and then kill the terminal by killing both the buffer and the associated process, running toggle-term again will open an empty buffer with no running terminal.
I have tracked this down to the terminal's presence in toggle-term--active-toggles. If I set that to nil prior to running toggle-term again, it pops open a new terminal.
My workaround locally is to run essentially this set of logic before calling toggle-term-eat or whatever:
(defun my/toggle-eat-project ()
(interactive)
(let*
;; override eat with eat-project so it opens in the project root
((eat #'eat-project)
(term-popup-name
(format "%s-eat-popup"
(or (when
(project-current)
(project-name (project-current)))
"global")))
(tt-last (toggle-term--get-last-used))
(tt-name (format " *%s*" term-popup-name))
(tt-is-last (and tt-last (string= tt-name (car tt-last))))
(tt-buffer (and tt-is-last (get-buffer tt-name))))
(when (and tt-is-last (not tt-buffer))
(setq toggle-term--active-toggles (cdr toggle-term--active-toggles)))
(funcall-interactively 'toggle-term-find term-popup-name "eat")))
If I start a new terminal with something like
toggle-term-eatortoggle-term-vterm, and then kill the terminal by killing both the buffer and the associated process, runningtoggle-termagain will open an empty buffer with no running terminal.I have tracked this down to the terminal's presence in
toggle-term--active-toggles. If I set that tonilprior to runningtoggle-termagain, it pops open a new terminal.My workaround locally is to run essentially this set of logic before calling
toggle-term-eator whatever: