public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] GDB: Add `NUMBER' completion to `set' integer commands
@ 2022-06-30 18:58 Maciej W. Rozycki
  0 siblings, 0 replies; only message in thread
From: Maciej W. Rozycki @ 2022-06-30 18:58 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=89555e4ec2195b7b10203befa23ff5e62fba406d

commit 89555e4ec2195b7b10203befa23ff5e62fba406d
Author: Maciej W. Rozycki <macro@embecosm.com>
Date:   Thu Jun 30 19:57:34 2022 +0100

    GDB: Add `NUMBER' completion to `set' integer commands
    
    Fix a completion consistency issue with `set' commands accepting integer
    values and the special `unlimited' keyword:
    
    (gdb) complete print -elements
    print -elements NUMBER
    print -elements unlimited
    (gdb)
    
    vs:
    
    (gdb) complete set print elements
    set print elements unlimited
    (gdb)
    
    (there is a space entered at the end of both commands, not shown here)
    which also means if you strike <Tab> with `set print elements ' input,
    it will, annoyingly, complete to `set print elements unlimited' right
    away rather than showing a choice between `NUMBER' and `unlimited'.
    
    Add `NUMBER' then as an available completion for such `set' commands:
    
    (gdb) complete set print elements
    set print elements NUMBER
    set print elements unlimited
    (gdb)
    
    Adjust the testsuite accordingly.  Also document the feature in the
    Completion section of the manual in addition to the Command Options
    section already there.

Diff:
---
 gdb/NEWS                            | 12 ++++++++++++
 gdb/cli/cli-decode.c                |  2 ++
 gdb/doc/gdb.texinfo                 | 15 +++++++++++++++
 gdb/testsuite/gdb.base/settings.exp |  8 +++++++-
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 5576c355b7a..c4f4a02a7c0 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -27,6 +27,18 @@
   emit to indicate where a breakpoint should be placed to break in a function
   past its prologue.
 
+* Completion now also offers "NUMBER" for "set" commands that accept
+  a numeric argument and the "unlimited" keyword.  For example:
+
+   (gdb) set width <TAB>
+   NUMBER     unlimited
+
+  and consequently:
+
+   (gdb) complete set width
+   set width NUMBER
+   set width unlimited
+
 * New commands
 
 maintenance set ignore-prologue-end-flag on|off
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index a15283421fe..fde554c7e6c 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -989,6 +989,8 @@ integer_unlimited_completer (struct cmd_list_element *ignore,
       NULL,
     };
 
+  if (*text == '\0')
+    tracker.add_completion (make_unique_xstrdup ("NUMBER"));
   complete_on_enum (tracker, keywords, text, word);
 }
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 39c49f29edd..f7b02c262b8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1960,6 +1960,21 @@ After displaying the available possibilities, @value{GDBN} copies your
 partial input (@samp{b make_} in the example) so you can finish the
 command.
 
+If the command you are trying to complete expects either a keyword or a
+number to follow, then @samp{NUMBER} will be shown among the available
+completions, for example:
+
+@smallexample
+(@value{GDBP}) print -elements @key{TAB}@key{TAB}
+NUMBER     unlimited
+(@value{GDBP}) print -elements@tie{}
+@end smallexample
+
+@noindent
+Here, the option expects a number (e.g., @code{100}), not literal
+@code{NUMBER}.  Such metasyntactical arguments are always presented in
+uppercase.
+
 If you just want to see the list of alternatives in the first place, you
 can press @kbd{M-?} rather than pressing @key{TAB} twice.  @kbd{M-?}
 means @kbd{@key{META} ?}.  You can type this either by holding down a
diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
index dafc5e4d8fd..890a2befc59 100644
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -215,8 +215,14 @@ proc test-integer {variant} {
 	test_gdb_complete_none \
 	    "$set_cmd "
     } else {
+	test_gdb_complete_multiple "$set_cmd " "" "" {
+	    "NUMBER"
+	    "unlimited"
+	}
+	test_gdb_complete_none \
+	    "$set_cmd 1"
 	test_gdb_complete_unique \
-	    "$set_cmd " \
+	    "$set_cmd u" \
 	    "$set_cmd unlimited"
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-30 18:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 18:58 [binutils-gdb] GDB: Add `NUMBER' completion to `set' integer commands Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).