Patchwork [v2,07/24] Remove "show" command completers, "set" command completers for string commands

login
register
mail settings
Submitter Pedro Alves
Date May 30, 2019, 7:53 p.m.
Message ID <20190530195333.20448-8-palves@redhat.com>
Download mbox | patch
Permalink /patch/32932/
State New
Headers show

Comments

Pedro Alves - May 30, 2019, 7:53 p.m.
The default command completer is symbol_completer, but it makes no
sense for a "show" command to complete on symbols, or anything else,
really.

I wonder whether we should instead make the default be no completer.
That seems like a much larger/complicated audit/change, so I'd like to
move forward with this version, as it'll be covered by tests.  I
noticed this because a following patch will add a new
gdb.base/settings.exp testcase that exercises all sorts of details of
settings commands, including completing the show commands, using new
representative "maint test-settings <type or settings command>"
commands.

Also remove the completer for var_string and var_string_noescape
commands.  No point in completing symbols when GDB is expecting a
string.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* cli/cli-decode.c (add_setshow_cmd_full): Remove "show"
	completer.
	(add_setshow_string_cmd, add_setshow_string_noescape_cmd): Remove
	"set" completers.
---
 gdb/cli/cli-decode.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
Tom Tromey - June 3, 2019, 6:55 p.m.
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I wonder whether we should instead make the default be no completer.

I think so.  The current default seems wrong in many situations, and
expensive to invoke besides.

One thing bash does is bind certain keys to specific completers, so for
example M-! will complete on command names, no matter the context.
Perhaps gdb could provide something like this as well, for the odd case
where you really want to complete on a symbol- or file-name in an
unusual context.

I'm ok with this patch in the interim.

Tom
Pedro Alves - June 4, 2019, 9:54 p.m.
On 6/3/19 7:55 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> I wonder whether we should instead make the default be no completer.
> 
> I think so.  The current default seems wrong in many situations, and
> expensive to invoke besides.
> 
> One thing bash does is bind certain keys to specific completers, so for
> example M-! will complete on command names, no matter the context.
> Perhaps gdb could provide something like this as well, for the odd case
> where you really want to complete on a symbol- or file-name in an
> unusual context.

That's an interesting idea.

> 
> I'm ok with this patch in the interim.
> 
> Tom
> 

Thanks,
Pedro Alves

Patch

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 72e2a970097..80158593b38 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -508,6 +508,9 @@  add_setshow_cmd_full (const char *name,
 			      full_show_doc, show_list);
   show->doc_allocated = 1;
   show->show_value_func = show_func;
+  /* Disable the default symbol completer.  Doesn't make much sense
+     for the "show" command to complete on anything.  */
+  set_cmd_completer (show, nullptr);
 
   if (set_result != NULL)
     *set_result = set;
@@ -632,11 +635,16 @@  add_setshow_string_cmd (const char *name, enum command_class theclass,
 			struct cmd_list_element **set_list,
 			struct cmd_list_element **show_list)
 {
+  cmd_list_element *set_cmd;
+
   add_setshow_cmd_full (name, theclass, var_string, var,
 			set_doc, show_doc, help_doc,
 			set_func, show_func,
 			set_list, show_list,
-			NULL, NULL);
+			&set_cmd, NULL);
+
+  /* Disable the default symbol completer.  */
+  set_cmd_completer (set_cmd, nullptr);
 }
 
 /* Add element named NAME to both the set and show command LISTs (the
@@ -658,6 +666,10 @@  add_setshow_string_noescape_cmd (const char *name, enum command_class theclass,
 			set_func, show_func,
 			set_list, show_list,
 			&set_cmd, NULL);
+
+  /* Disable the default symbol completer.  */
+  set_cmd_completer (set_cmd, nullptr);
+
   return set_cmd;
 }