Emacs gdb tab - ends a directory with a space instead of /

When I run gdb in emacs (with Mx gdb ) and I try to fill in the directory names, it ends with a space instead of a slash. So for example:

(gdb) run/mn

tab-terminates before

(gdb) run /mnt

when should he execute the tab

(gdb) run /mnt/

If I run gdb outside of emacs, tab execution will work as expected.

I am running gdb 7.4.1-debian and emacs 23.4.1 to test debian.

Any help you could give me would be greatly appreciated; it's really annoying!

+4
source share
1 answer

gud-mode retrieves a list of possible terminations by calling the gdb complete command. In your example, the returned list will contain the following (assuming that there is only one directory on your file system that starts with "/ mn"):

 (run /mnt) 

The first part of each entry in the returned list is disabled, so the remaining complete list

 (/mnt) 

As you can see, this entry returned by the gdb complete command no longer has a trailing slash. Your only hope of fixing this would be to either gdb complete patches or to fix Emacs gud-mode , as it detects that the filled word is a directory and then adds a slash (and suppresses the automatic insertion of a space).

But, of course, you can simply bind the TAB key to another completion function, potentially one that returns to the default gud-gdb-complete-command by default, but may perform a different kind of termination when called.

To do this, try placing the following in the .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 associates the new function with the TAB key, which first tries to expand the current word as a file, and only if this fails, gud-gdb-complete-command is called by default.

+3
source

Source: https://habr.com/ru/post/1433494/


All Articles