When I issue the Emacs command M-x pdb
it invokes Python’s pdb
as python -m pdb foo.py
. I want to instead invoke python3 -m pdb foo.py
-- how do I set this up?
1 Answer
At least in emacs 27, this is controlled by the customization gud_pdb_command_name
.
The easy way to set it is to invoke pdb
once, to get past any autoload issues, then M-x customize_option
gud_pdb_command_name
then fill in the command desired and choose Apply
to try it out or Apply and Save
to have it stored for future use.
-
Does "Apply and Save" store it in
.emacs
? I assume there is some magic incantation I can put in.emacs
.– wcochranAug 22, 2020 at 15:13 -
I have no
pdb
program which emacs complains about, but I can dopython3 -m pdb foo.py
from the command line.– wcochranAug 22, 2020 at 15:30 -
1So you have a couple of choices, write a
pdb
shell script, something like#!/bin/sh\nexec python3 -m pdb "$@"\n
would do it, or else customize the variable to bepython3 -m pdb
. Yes "Apply and Save" does store it in your emacs startup files, which might be ~/.emacs, ~/.emacs.d/init.el, ~/.config/emacs/init.el or somewhere else.– icarusAug 22, 2020 at 18:14 -
Thanks for your help. I just threw
(setq gud-pdb-command-name "python3 -m pdb")
in my.emacs
file and all is good.– wcochranAug 22, 2020 at 18:25 -
@wcochran, as you suggested, I was able to run the python3 -m pdb with my script in emacs. But it will not give me 2 separate windows, 1st is the command window, and the 2nd is source code window where I can see the pointer on current execution line. The default pdb does that. Any comments ? Dec 17, 2021 at 20:32