Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Give a name to the TUI SingleKey keymap
@ 2019-09-11  0:44 Tom Tromey
  2019-09-11  2:39 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2019-09-11  0:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Readline 8.0 has a feature that lets an application name a keymap.
This in turn makes it simpler for users to bind keys in keymaps in
their .inputrc.

This patch gives a name to the TUI SingleKey keymap, so that
additional bindings can be made there.  For example:

    $if gdb
    set keymap SingleKey
    "X": "echo hello\\n\n"
    $endif

The call to rl_initialize, in tui_initialize_readline, had to be
removed so that .inputrc was not read too early.  Note that Readline
explicitly documents that this call is not needed.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
	call rl_initialize.
	(tui_enable): Do not call rl_initialize.

gdb/doc/ChangeLog
2019-09-10  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Editing): Document readline application name.
	(TUI Single Key Mode): Document TUI SingleKey keymap name.
---
 gdb/ChangeLog       | 6 ++++++
 gdb/doc/ChangeLog   | 5 +++++
 gdb/doc/gdb.texinfo | 6 ++++++
 gdb/tui/tui.c       | 9 ++++++---
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 53b7de91e47..5d82155a3b0 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -24975,6 +24975,9 @@ for more details about the Readline
 interface.  Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
 encouraged to read that chapter.
 
+@value{GDBN} sets the Readline application name to @samp{gdb}.  This
+is useful for conditions in @file{.inputrc}.
+
 @node Command History
 @section Command History
 @cindex command history
@@ -27577,6 +27580,9 @@ with the TUI SingleKey mode.  Once the command is entered the TUI
 SingleKey mode is restored.  The only way to permanently leave
 this mode is by typing @kbd{q} or @kbd{C-x s}.
 
+If @value{GDBN} was built with Readline 8.0 or later, the TUI
+SingleKey keymap will be named @samp{SingleKey}.  This can be used in
+@file{.inputrc} to add additional bindings to this keymap.
 
 @node TUI Commands
 @section TUI-specific Commands
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index db34e0c0441..5d6b9f32036 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -329,13 +329,17 @@ tui_initialize_readline (void)
   int i;
   Keymap tui_ctlx_keymap;
 
-  rl_initialize ();
-
   rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1);
   rl_add_defun ("gdb-command", tui_rl_command_key, -1);
   rl_add_defun ("next-keymap", tui_rl_next_keymap, -1);
 
   tui_keymap = rl_make_bare_keymap ();
+
+  /* The named keymap feature was added in Readline 8.0.  */
+#if RL_READLINE_VERSION >= 0x800
+  rl_set_keymap_name ("SingleKey", tui_keymap);
+#endif
+
   tui_ctlx_keymap = rl_make_bare_keymap ();
   tui_readline_standard_keymap = rl_get_keymap ();
 
@@ -467,7 +471,6 @@ tui_enable (void)
       nodelay(w, FALSE);
       nl();
       keypad (w, TRUE);
-      rl_initialize ();
       tui_set_term_height_to (LINES);
       tui_set_term_width_to (COLS);
       def_prog_mode ();
-- 
2.17.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Give a name to the TUI SingleKey keymap
  2019-09-11  0:44 [PATCH] Give a name to the TUI SingleKey keymap Tom Tromey
@ 2019-09-11  2:39 ` Eli Zaretskii
  2019-09-17 21:23   ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-09-11  2:39 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>
> Date: Tue, 10 Sep 2019 18:43:52 -0600
> 
> Readline 8.0 has a feature that lets an application name a keymap.
> This in turn makes it simpler for users to bind keys in keymaps in
> their .inputrc.
> 
> This patch gives a name to the TUI SingleKey keymap, so that
> additional bindings can be made there.  For example:
> 
>     $if gdb
>     set keymap SingleKey
>     "X": "echo hello\\n\n"
>     $endif
> 
> The call to rl_initialize, in tui_initialize_readline, had to be
> removed so that .inputrc was not read too early.  Note that Readline
> explicitly documents that this call is not needed.

The documentation part is OK, but please add index entries to the new
information, so that it could be easily found if someone forgets the
details.

Also, should this be in NEWS?

Thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Give a name to the TUI SingleKey keymap
  2019-09-11  2:39 ` Eli Zaretskii
@ 2019-09-17 21:23   ` Tom Tromey
  2019-09-18  2:37     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2019-09-17 21:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

Eli> The documentation part is OK, but please add index entries to the new
Eli> information, so that it could be easily found if someone forgets the
Eli> details.

Eli> Also, should this be in NEWS?

Yes.

How's this?

Tom

commit 1830e30762c53b88057e33b6044660a3da136099
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Sep 10 17:25:35 2019 -0600

    Give a name to the TUI SingleKey keymap
    
    Readline 8.0 has a feature that lets an application name a keymap.
    This in turn makes it simpler for users to bind keys in keymaps in
    their .inputrc.
    
    This patch gives a name to the TUI SingleKey keymap, so that
    additional bindings can be made there.  For example:
    
        $if gdb
        set keymap SingleKey
        "X": "echo hello\\n\n"
        $endif
    
    The call to rl_initialize, in tui_initialize_readline, had to be
    removed so that .inputrc was not read too early.  Note that Readline
    explicitly documents that this call is not needed.
    
    gdb/ChangeLog
    2019-09-17  Tom Tromey  <tom@tromey.com>
    
            * NEWS: Add entry.
            * tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
            call rl_initialize.
            (tui_enable): Do not call rl_initialize.
    
    gdb/doc/ChangeLog
    2019-09-17  Tom Tromey  <tom@tromey.com>
    
            * gdb.texinfo (Editing): Document readline application name.
            (TUI Single Key Mode): Document TUI SingleKey keymap name.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4c354700c45..f5596f2e809 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-09-17  Tom Tromey  <tom@tromey.com>
+
+	* NEWS: Add entry.
+	* tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
+	call rl_initialize.
+	(tui_enable): Do not call rl_initialize.
+
 2019-09-11  Christian Biesinger  <cbiesinger@google.com>
 
 	* auto-load.c (auto_load_expand_dir_vars): Update.
diff --git a/gdb/NEWS b/gdb/NEWS
index f382e887c0c..8f4ba6c03dd 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -318,6 +318,10 @@ maint show test-options-completion-result
   GDB now bundles GNU readline 8.0, but if you choose to use
   --with-system-readline, only readline >= 7.0 can be used.
 
+* The TUI SingleKey keymap is now named "SingleKey".  This can be used
+  from .inputrc to bind keys in this keymap.  This feature is only
+  available when gdb is built against GNU readline 8.0 or later.
+
 *** Changes in GDB 8.3
 
 * GDB and GDBserver now support access to additional registers on
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 96c04091973..79024096c07 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-09-17  Tom Tromey  <tom@tromey.com>
+
+	* gdb.texinfo (Editing): Document readline application name.
+	(TUI Single Key Mode): Document TUI SingleKey keymap name.
+
 2019-09-10  Tom Tromey  <tromey@adacore.com>
 
 	* gdb.texinfo (Index Files): Update Ada text.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 79824a0226a..5c50a7e28ac 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -24975,6 +24975,10 @@ for more details about the Readline
 interface.  Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
 encouraged to read that chapter.
 
+@cindex Readline application name
+@value{GDBN} sets the Readline application name to @samp{gdb}.  This
+is useful for conditions in @file{.inputrc}.
+
 @node Command History
 @section Command History
 @cindex command history
@@ -27577,6 +27581,10 @@ with the TUI SingleKey mode.  Once the command is entered the TUI
 SingleKey mode is restored.  The only way to permanently leave
 this mode is by typing @kbd{q} or @kbd{C-x s}.
 
+@cindex SingleKey keymap name
+If @value{GDBN} was built with Readline 8.0 or later, the TUI
+SingleKey keymap will be named @samp{SingleKey}.  This can be used in
+@file{.inputrc} to add additional bindings to this keymap.
 
 @node TUI Commands
 @section TUI-specific Commands
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index db34e0c0441..5d6b9f32036 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -329,13 +329,17 @@ tui_initialize_readline (void)
   int i;
   Keymap tui_ctlx_keymap;
 
-  rl_initialize ();
-
   rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1);
   rl_add_defun ("gdb-command", tui_rl_command_key, -1);
   rl_add_defun ("next-keymap", tui_rl_next_keymap, -1);
 
   tui_keymap = rl_make_bare_keymap ();
+
+  /* The named keymap feature was added in Readline 8.0.  */
+#if RL_READLINE_VERSION >= 0x800
+  rl_set_keymap_name ("SingleKey", tui_keymap);
+#endif
+
   tui_ctlx_keymap = rl_make_bare_keymap ();
   tui_readline_standard_keymap = rl_get_keymap ();
 
@@ -467,7 +471,6 @@ tui_enable (void)
       nodelay(w, FALSE);
       nl();
       keypad (w, TRUE);
-      rl_initialize ();
       tui_set_term_height_to (LINES);
       tui_set_term_width_to (COLS);
       def_prog_mode ();


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Give a name to the TUI SingleKey keymap
  2019-09-17 21:23   ` Tom Tromey
@ 2019-09-18  2:37     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-09-18  2:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: tom, gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Tue, 17 Sep 2019 15:23:26 -0600
> 
> Eli> The documentation part is OK, but please add index entries to the new
> Eli> information, so that it could be easily found if someone forgets the
> Eli> details.
> 
> Eli> Also, should this be in NEWS?
> 
> Yes.
> 
> How's this?

LGTM, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-18  2:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  0:44 [PATCH] Give a name to the TUI SingleKey keymap Tom Tromey
2019-09-11  2:39 ` Eli Zaretskii
2019-09-17 21:23   ` Tom Tromey
2019-09-18  2:37     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox