From 96c9af4ab1490766fb1e2229ff3cf565cf7f10d1 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 17 May 2017 22:09:26 +0200 Subject: [PATCH] readline: Avoid interpreting control characters in pastes. * NEWS: Update. * doc/ref/repl-modules.texi (Readline Options): Update for bracketed-paste. * guile-readline/readline.h (SCM_READLINE_BRACKETED_PASTE): Add bracketed-paste option. * guile-readline/readline.c (scm_readline_opts): Add bracketed-paste. (scm_init_readline): Wire up the logic. --- NEWS | 17 +++++++++++++++++ doc/ref/repl-modules.texi | 2 ++ guile-readline/readline.c | 7 ++++++- guile-readline/readline.h | 3 ++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index d2c619785..6d7e58e8e 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,23 @@ See the end for copying conditions. Please send Guile bug reports to bug-guile@gnu.org. + +Changes in 2.2.3 (since 2.2.2): + +* Bug fixes + +** Enable GNU Readline 7.0's support for "bracketed paste". + +Before, when pasting an expression that contained TAB characters into +Guile's REPL with GNU Readline support enabled, the pasted TAB +characters would trigger autocompletion in Readline. This was never +what you wanted. Guile now sets the new "bracketed-paste" option in GNU +Readline 7.0 to on by default, making readline treat pastes into the +terminal as atomic units without control characters. See "Readline +Options" in the manual for full details. + +** Fix time-monotonic from SRFI-19; broken in 2.2.1. + Changes in 2.2.2 (since 2.2.1): diff --git a/doc/ref/repl-modules.texi b/doc/ref/repl-modules.texi index 700867272..e20393ba2 100644 --- a/doc/ref/repl-modules.texi +++ b/doc/ref/repl-modules.texi @@ -108,6 +108,8 @@ history-file yes Use history file. history-length 200 History length. bounce-parens 500 Time (ms) to show matching opening parenthesis (0 = off). +bracketed-paste yes Disable interpretation of control characters + in pastes. @end smalllisp The readline options interface can only be used @emph{after} loading diff --git a/guile-readline/readline.c b/guile-readline/readline.c index a3e890346..c15275dd3 100644 --- a/guile-readline/readline.c +++ b/guile-readline/readline.c @@ -47,6 +47,8 @@ scm_t_option scm_readline_opts[] = { "History length." }, { SCM_OPTION_INTEGER, "bounce-parens", 500, "Time (ms) to show matching opening parenthesis (0 = off)."}, + { SCM_OPTION_BOOLEAN, "bracketed-paste", 1, + "Disable interpretation of control characters in pastes." }, { 0 } }; @@ -545,7 +547,10 @@ scm_init_readline () reentry_barrier_mutex = scm_make_mutex (); scm_init_opts (scm_readline_options, - scm_readline_opts); + scm_readline_opts); + rl_variable_bind ("enable-bracketed-paste", + SCM_READLINE_BRACKETED_PASTE ? "on" : "off"); + #if HAVE_RL_GET_KEYMAP init_bouncing_parens(); #endif diff --git a/guile-readline/readline.h b/guile-readline/readline.h index 2bf5f8000..3c935e2aa 100644 --- a/guile-readline/readline.h +++ b/guile-readline/readline.h @@ -39,7 +39,8 @@ SCM_RL_API scm_t_option scm_readline_opts[]; #define SCM_HISTORY_FILE_P scm_readline_opts[0].val #define SCM_HISTORY_LENGTH scm_readline_opts[1].val #define SCM_READLINE_BOUNCE_PARENS scm_readline_opts[2].val -#define SCM_N_READLINE_OPTIONS 3 +#define SCM_READLINE_BRACKETED_PASTE scm_readline_opts[3].val +#define SCM_N_READLINE_OPTIONS 4 SCM_RL_API SCM scm_readline_options (SCM setting); SCM_RL_API void scm_readline_init_ports (SCM inp, SCM outp);