dap-mode icon indicating copy to clipboard operation
dap-mode copied to clipboard

Display graphics and pretty printed formulae with `dap-ui-repl`.

Open hongyi-zhao opened this issue 2 years ago • 12 comments

Currently, I'm using the comint-mime package with the following configuration:

(use-package comint-mime
  :straight (:host github :repo "astoff/comint-mime"
             :files (:defaults "*.py" "*.sh"))
  :hook ((shell-mode inferior-python-mode) . comint-mime-setup))

With the help of the above package, Emacs can display graphics and pretty printed formulae as follows, just as I've discussed here:

image

But I want to know if we can get the similar feature in dap-ui-repl.

Regards, HZ

hongyi-zhao avatar Oct 07 '21 08:10 hongyi-zhao

ATM this is not possible using dap-ui-repl. Somebody has to investigate and implement it if possible.

yyoncho avatar Oct 07 '21 08:10 yyoncho

Is there a way to, at least, use ipython shell in dap-ui-repl ?

amirdib avatar Jan 15 '22 11:01 amirdib

@amirdib in general, you may run an external python process that supports graphics and connect using dap-mode.

yyoncho avatar Jan 15 '22 11:01 yyoncho

@yyoncho Does the comint-mime based example I showed above fall into the situation you said?

hongyi-zhao avatar Jan 15 '22 12:01 hongyi-zhao

@amirdib in general, you may run an external python process that supports graphics and connect using dap-mode.

Can you point to the relevant documentation entry ? I can't find what you're referring to. If so, that would solve the issue.

amirdib avatar Jan 15 '22 12:01 amirdib

reffer to that, and afaics there is attach template registered in dap-python: https://github.com/microsoft/debugpy#attaching-to-a-running-process-by-id

yyoncho avatar Jan 15 '22 12:01 yyoncho

Thank you for your linked documentation. But if I start a process, say ipython, the PID should be generated/assigned randomly completely. So, I still can't figure out how to use the example given there.

hongyi-zhao avatar Jan 15 '22 12:01 hongyi-zhao

reffer to that, and afaics there is attach template registered in dap-python: https://github.com/microsoft/debugpy#attaching-to-a-running-process-by-id

Thanks. Indeed, there is an attach option: https://code.visualstudio.com/docs/python/debugging

I think PID is not needed. Next step will be to try on a minimal example @hongyi-zhao

amirdib avatar Jan 15 '22 12:01 amirdib

@amirdib If you have figured out one, hope you can follow up and post here.

hongyi-zhao avatar Jan 15 '22 12:01 hongyi-zhao

Thank you for your linked documentation. But if I start a process, say ipython, the PID should be generated/assigned randomly completely. So, I still can't figure out how to use the example given there.

You can find the PID of a process by name with pgrep. So, python3 -m debugpy --listen localhost:5882 --pid $(pgrep -f main.py) will inject in debugger in main.py

amirdib avatar Jan 15 '22 22:01 amirdib

Still not so clear. Run this from within Emacs? Could you please describe the specific steps?

hongyi-zhao avatar Jan 16 '22 00:01 hongyi-zhao

Still not so clear. Run this from within Emacs? Could you please describe the specific steps?

I don't think that the solution proposed by @yyoncho correspond to what we intend to do. We want our debug shell to be a comint buffer that can display graphics. For that, would likely require to investigate and rewrite the dap-ui-repl function imo

amirdib avatar Jan 16 '22 16:01 amirdib