When running M-x pdb
from Emacs, the current directory seems to be set to that of the directory of the script you are running, so
pdb ~/path/to/project/__main__.py
Would set the working directory to ~/path/to/project/
. However, what if I need the working directory to be a different directory - say, one directory back? Is there a way to set the directory that pdb/gud uses as the "working directory"? At the first pdb
prompt I can change the directory with os.chdir()
, which works, but I would like to not have to do this every time. Thank you!
Update:
I have found that one potential solution would be to set gud-chdir-before-run
(mentioned by @Nsukami_ below) to nil
and then change to the desired directory with (cd "/path/to/directory")
before running pdb
. I tried doing this with the gud-mode-hook
but the directory is changed too late. I have also, tried to do this with by advising pdb
and gud-mode-hook
, but don't yet have the lisp skills for this apparently...Is there a good way to call cd
before gud-mode-hook
/ before the dubugger starts?