gud-mode
retrieves the list of possible completitions by calling gdb's complete
command. In your example, the returned list would contain the following (assuming that there's only one directory in your file system that starts with "/mn"):
(run /mnt)
The first part of each entry in the returned list is cut off, so that the remaining complete-list is
(/mnt)
As you can see, this entry returned by gdb's complete
command already lacks the trailing slash. Your only hope to fix this would be to either patch gdb's complete
command, or to patch Emacs' gud-mode
, by somehow detecting that the completed word is a directory and then appending a slash (and suppressing the auto-insertion of the space character).
But of course, you could simply bind the TAB key to a different completion function, potentially one that falls back on the default gud-gdb-complete-command
, but perhaps does a different kind of completion when called for.
For this, try putting the following in your .emacs file:
(defun my-gud-gdb-setup ()
(define-key (current-local-map) "\t" 'my-gud-gdb-complete-command))
(defun my-gud-gdb-complete-command (&optional COMMAND PREDICATE FLAGS)
(interactive)
(unless (comint-dynamic-complete-filename)
(gud-gdb-complete-command COMMAND PREDICATE FLAGS)))
(add-hook 'gdb-mode-hook 'my-gud-gdb-setup)
This code binds a new function to the TAB key which first tries to expand the current word as a file, and only if that fails calls the default gud-gdb-complete-command
.