summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-02 23:27:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-02 23:27:08 +0000
commit074f1c913346abbd6d47b3e1147719e2cf0e023f (patch)
treeb8be35499d5036171385d6676b26cb81432ba621 /ext
parentf7717185c86fce4019d2af245143faa981908780 (diff)
Readline: expose rl_completion_quote_character variable
[Feature #13050] From: georgebrock (George Brocklehurst) <ruby@georgebrock.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/readline/extconf.rb1
-rw-r--r--ext/readline/readline.c31
2 files changed, 32 insertions, 0 deletions
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index 5266e07..fcc6292 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -71,6 +71,7 @@ readline.have_func("rl_completion_matches")
readline.have_func("rl_refresh_line")
readline.have_var("rl_deprep_term_function")
readline.have_var("rl_completion_append_character")
+readline.have_var("rl_completion_quote_character")
readline.have_var("rl_basic_word_break_characters")
readline.have_var("rl_completer_word_break_characters")
readline.have_var("rl_basic_quote_characters")
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 8f82738..402e215 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -1303,6 +1303,35 @@ readline_s_get_completion_append_character(VALUE self)
#define readline_s_get_completion_append_character rb_f_notimplement
#endif
+#ifdef HAVE_RL_COMPLETION_QUOTE_CHARACTER
+/*
+ * call-seq:
+ * Readline.completion_quote_character -> char
+ *
+ * When called during a completion (e.g. from within your completion_proc),
+ * it will return a string containing the chracter used to quote the
+ * argument being completed, or nil if the argument is unquoted.
+ *
+ * When called at other times, it will always return nil.
+ *
+ * Note that ``Readline.completer_quote_characters`` must be set,
+ * or this method will always return nil.
+ */
+static VALUE
+readline_s_get_completion_quote_character(VALUE self)
+{
+ char buf[1];
+
+ if (rl_completion_quote_character == '\0')
+ return Qnil;
+
+ buf[0] = (char) rl_completion_quote_character;
+ return rb_locale_str_new(buf, 1);
+}
+#else
+#define readline_s_get_completion_quote_character rb_f_notimplement
+#endif
+
#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
/*
* call-seq:
@@ -1958,6 +1987,8 @@ Init_readline(void)
readline_s_set_completion_append_character, 1);
rb_define_singleton_method(mReadline, "completion_append_character",
readline_s_get_completion_append_character, 0);
+ rb_define_singleton_method(mReadline, "completion_quote_character",
+ readline_s_get_completion_quote_character, 0);
rb_define_singleton_method(mReadline, "basic_word_break_characters=",
readline_s_set_basic_word_break_characters, 1);
rb_define_singleton_method(mReadline, "basic_word_break_characters",