Emacs Asked by Mittenchops on November 25, 2020
When I run realgud for python debugging, with:
M-x realgud:pdb
I see this prompt:
Run pdb (like this): python -m pdb /home/username/work/place/scratch.py
I’m using a conda environment installed in ./place/environments/default/
, so I’d like to use the python executable at ./place/environments/default/bin/python
This means I have to type out a correction to use a different python:`
Run pdb (like this): /home/username/work/place/environments/default/bin/python -m pdb /home/username/work/place/scratch.py
installed in that directory every time I invoke pdb, which is tedious.
I have multiple projects in
/home/username/work/
So I can’t just hard-code /one/, it needs to be configurable—but I’d like something like the following:
What options do I have to reduce the amount I have to type to change the python invoked?
Realgud:ipdb has a variable that indicate the command-name, is called realdu:pdb-command-name
by default is set to "python -m pdb", but it can easily be adapted to use with differents projects (I'm assuming that you are using projectile, if it's not the case, take a look at project.el)
We can assume that the location of the python executable has some similarities between projects (it's in the environment directory in the root project) if it's not the case, Directory-Variables may help you, as you can define this variable in every directory regardless of the project.
So, for the first case, we can use a python-mode-hook
and add some logic:
(add-hook 'python-mode-hook
(lambda ()
(let* ((conda-python (format "%/environments/default/bin/python -m pdb" (projectile-project-root))))
(setq-local realgud:pdb-command-name conda-python))
))
This hook will ensure that for every file in a project, it will set a different variable, making possible to work with differents projects at the same time, mostly because we are using a buffer-local variable.
When realgud:pdb is launch, it will put the correct projectile base root, and will concat the file name at the end, making the file selection automatic.
For the 2 and 4 request, it is not implemented, but it can be an interesting addition to the realgud project, I really suggest you to contribute it (or open an issue) to the realgud project.
Good luck!
Correct answer by f-sasa on November 25, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP