I have Emacs Lisp program that I want to work inside either a comint process buffer or an eshell buffer. The code I currently am using is:
https://github.com/rocky/emacs-dbgr/blob/master/realgud/common/track-mode.el#L141-L147
but this is a bit ugly and might be prone to breakage if either the comint or eshell changes.
Any suggestions?