I'm running code in development using docker. I do that using the -v flag to docker run to mount my code in the container.

I've set directory-abbrev-alist and configured compilation-error-regexp-alist-alist appropriately, so I can click on links in stack traces and jump to the corresponding place in the source code (e.g. in bt output from M-x pdb).

However, that doesn't give me gud's debug arrow pointing to the current line of the active stack frame. For example, when I run the bt command in pdb, I don't see a window open visiting the appropriate file with the arrow in the fringe pointing at the line of the python stack frame I'm currently on.

In the past I've resorted to creating symlinks on the docker host (for example from /opt/someproject to /home/me/dev/someproject). That fixes the problem. But these may differ from one container to another. It's inconvenient to keep these up-to-date, not to mention a bit hacky.

How can I fix this using elisp configuration rather than via symlinks?


If you set the variable gud-find-file to a function, GUD will call it with any paths it gets from the debugger. My setup is something like this:

(setq gud-find-file (lambda (name) (let* ((name (replace-regexp-in-string "^/var/app" "." name)) (name (replace-regexp-in-string "^.*/lib/" ".ve/lib/" name))) (gud-file-name name))))

Just change those regexes to match your remote and local paths and it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.