1

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.

Bion Pohl
  • 11
  • 3

2 Answers2

0

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
        (replace-regexp-in-string
             "^\\*?\\(gud-\\)?\\(.+?\\)\\*?$" "\\1term-\\2" (buffer-name)
(message "Using %s as term buffer, script and pipe name." term-file-name)
Bion Pohl
  • 11
  • 3
0

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 ".
(replace-regexp-in-string
 (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.

g-gundam
  • 1,096
  • 1
  • 3
  • 13