I've been adding some modifications to the perldb which goes through gud. When started it calls its perldb-mode-hook so that and .perldb is where I'm working.

From within the hook I can get the buffer name which is in the form *gud-script.pl* and thus in the context of the gud comint buffer where there is no file being visited. I could parse the file's name out of the buffer name, but it seems I should be able to get the path and name of the Perl file executed or the whole command line run.


2 Answers 2


No one else has answered my question so I just went ahead and did this:

;; Alt regex to remove file ext "^\\*?\\(gud-\\)?\\(.+?\\)\\(\\.pl\\)*\\*?$"
(setq term-file-name
             "^\\*?\\(gud-\\)?\\(.+?\\)\\*?$" "\\1term-\\2" (buffer-name)
(message "Using %s as term buffer, script and pipe name." term-file-name)

You can get the information you want by looking at the variable gud-perldb-history. Every time you run M-x perldb, the full command line used to run the Perl Debugger will be prepended to the front of that list.

;; Get the most recent command run under perldb.
(car gud-perldb-history)

;; Get just the command line without the "perl -d ".
 (concat "^" gud-perldb-command-name " ") ; debugger command
 ""                                       ; removed
 (car gud-perldb-history))                ; leaving the command line

;; Get the full path to the script.
(nth 2 (split-string-and-unquote (car gud-perldb-history)))

The last one is a bit fragile, because it assumes the presence of "perl -d" and skips over the first two strings to get at the script path. This should be a good starting point for whatever you're trying to do though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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