Readline.completion_append_character

$B$$$^$$$G$9!#(B

GNU readline library $B$G$NOC$G$9$,!"(B6 $B7O$N$b$N$r;H$&$H(B TAB
$B%-!<$G$NJd40(B
$B8e$K(B Readline.completion_append_character $B$,%G%U%)%k%H$N(B " "
$B$KLa$C$F$7(B
$B$^$$$^$9!#$7$+$b!"(B" "
$B0J30$K%;%C%H$7$F$b!"Jd40$5$l$?C18l$K$O%G%U%)%k%H(B
$B$N(B " " $B$,IU2C$5$l$^$9!#(B

require “readline”

p RUBY_DESCRIPTION
p Readline::VERSION
p Readline.completion_append_character
Readline.completion_proc = ->(input){[input]}
IO.pipe do |r, w|
Readline.output = (w << “Readline\t”).reopen("/dev/null")
Readline.input = r
Readline.completion_append_character = nil
p Readline.completion_append_character
p Readline.readline
p Readline.completion_append_character
end

Debian GNU/Linux (sid) libreadline-gplv2-dev (5.2-8)

>> “ruby 1.9.3dev (2011-04-29 trunk 31382) [x86_64-linux]”

>> “5.2”

>> " "

>> nil

>> “Readline”

>> nil

Debian GNU/Linux (sid) libreadline6-dev (6.2-1)

>> “ruby 1.9.3dev (2011-04-29 trunk 31382) [x86_64-linux]”

>> “6.2”

>> " "

>> nil (nil $B$K%;%C%H$O=PMh$k$1$I(B)

>> "Readline " ($BKvHx$K%9%Z!<%9$,IU$$$F$7$^$C$F(B)

>> " " ($B%j%;%C%H$5$l$F$7$^$&(B)

changelog
$B$K0J2<$N$h$&$K=q$$$F$"$C$F!"Jd408e$K%j%;%C%H$5$l$k$N$O0U?^E*(B
$B$J$h$&$G$9!#(BRuby $B$N(B readline
$BB&$G2?$H$+$J$i$J$$$b$N$G$7$g$&$+!)(B

This document details the changes between this version, readline-6.0,
and the previous version, readline-5.2.
(snip)
f. Fixed a bug that caused the completion append character to not be
reset to
the default after an application-specified completion function
changed it.

$B$$$^$$$G$9!#(B

From: Takao K. <kouji_at_takao7.net>
Date: Sat, 30 Apr 2011 13:35:51 +0900

$B>e5-$K4X$7$F3NG’$5$;$F$/[email protected]$5$$!#(B

Readline$B$K$D$$$F!"$$$^$$$5$s$+$i(B2$B$D$NAjCL$,$"$C$?$HG’<1$7$F$$$^$9!#(B

$B$O$$!#(B

1)GNU Readline
6$B$N>l9g$K(BReadline.completion_append_character$B$K(Bnil$B$r;XDj$G$-$J$$IT6q9g$,$"$k(B

nil$B$r%;%C%H$7$F$bJd408e$K%9%Z!<%9$,DI2C$5$l$kLdBj$G$9$M!#(B
$B$3$A$i$O860x$rD4::$7$FBP1~$7$?$[$&$,$h$$$H9M$($F$$$^$9!#(B

$B$=$&$G$9$M!#%;%C%H$G$-$J$$$H$$$&$+!"%;%C%H$7$F$b8z2L$,[email protected][email protected]$&(B
$B46$8$G$9!#(Bnil
$B$K8B$i$:!"2?$r%;%C%H$7$F$b0lEYJd40$7$F$7$^$&$H%G%U%)%k(B
$B%HCM$K%j%;%C%H$5$l$F$7$^$$$^$9!#(B

2)GNU Readline 6$B$N>l9g$G$b(B5$B0JA0$HF1MM$NF0:n$K$7$F$[$7$$(B

GNU Readline 6$B$G$O!“Jd408e$K(BReadline.completion_append_character$B$,%G(B
$B%U%)%k%HCM$X%j%;%C%H$5$l$k$N$G!”(B5$B0JA0$HF1MM$K%j%;%C%H$5$l$J$$$h$&$K(B
$B$7$F$[$7$$$3$H$G4V0c$$$J$$$G$7$g$&$+!#$3$A$i$K$D$$$F$O!";d$O(BGNU
Readline$B$G$=$N$h$&$J5sF0$J$N$G$"$l$P$=$l$K=>$C$?$[$&$,$h$$$H;W$C$F$$(B
$B$^$9!#(BGNU Readline$BK\BN$G$O!“2?$+$7$i$NM}M3$,$”$C$F$=$NJ}$,$h$$$H9M$((B
[email protected]$7$?$N$G$O$J$$$G$7$g$&$+!#$=$N287C$r<u$1$i$l$kJ}$,$h$$$N$G$O$J(B
$B$$$G$7$g$&$+!#$=$l$,LdBj$G$"$l$P(BGNU Readline$BK\[email protected]$7$F$b$i$&J}$,(B
$B$h$$$H;W$$$^$9!#(B

$B?dB,$G$9$,!"(Bchangelog $B$rFI$`8B$j!"(BGNU readline
$B$rMxMQ$9$k%"%W%j%1!<%7%g(B
$B%sB&$G(B rl_completion_append_character
$B$rJQ99$9$k$H!"%i%$%V%i%jB&$G2?$+(B
$BLdBj$,@8$8$k$N$G!“Jd40$9$kEY$K%j%;%C%H$9$k$h$&[email protected]$HG’<1$7$F$$(B
$B$^$9!#I,MW$K1~$8$F!“Jd40$9$k4X?t(B(rl_attempted_completion_function
$B$+(B
$B$J!)(B)$B$r8F$S=P$9EY$K%”%W%j%1!<%7%g%sB&$G(B
rl_completion_append_character
$B$r%;%C%H$7$F$M!”$H$$$&$3$H$J$s$8$c$J$$$G$7$g$&$+!#(B

$B1F6AHO0O$,$h$/J,$+$C$F$$$^$;$s$,!"(BRuby $B$N(B readline $BB&$G(B
rl_completion_append_character
$BAjEv$N$b$N$rJ];}$7$F$*$$$F!"Jd40$9$k;~(B
$B$K%;%C%H$7$F$d$l$P$$$$$N$G$O$J$$$G$7$g$&$+!)(B

$B$d$C$F$$?$i2?$+F0$$$F$=$&!"$H$$$&%l%Y%k$N$b$N$G$9$,!";29M$^$G$K%Q%C%A(B
$B$rIU$1$F$
$^$9!#(BRuby $B$N%9%/%j%W%H$+$i(B readline.so
$B$r;H$&8B$j$O$3$l$G$h(B
$B$5$=$&$G$9$,!“3HD%%i%$%V%i%j$+$iD>@(B rl_completion_append_character
$B$r(B
$B$$$8$k$h$&$J$3$H$,$”$k(B($B$N$+$I$&$+$OJ,$+$C$F$^$;$s(B)$B$HGKC>$7$A$c$$$=$&$G$9!#(B

$B9bHx$G$9!#(B

GNU readline library $B$G$NOC$G$9$,!"(B6 $B7O$N$b$N$r;H$&$H(B TAB
$B%-!<$G$NJd40(B
$B8e$K(B Readline.completion_append_character $B$,%G%U%)%k%H$N(B " "
$B$KLa$C$F$7(B
$B$^$$$^$9!#$7$+$b!"(B" " $B0J30$K%;%C%H$7$F$b!“Jd40$5$l$?C18l$K$O%G%U%)%k%H(B
$B$N(B " " $B$,IU2C$5$l$^$9!#(B
($B>JN,(B)
changelog $B$K0J2<$N$h$&$K=q$$$F$”$C$F!"Jd408e$K%j%;%C%H$5$l$k$N$O0U?^E*(B
$B$J$h$&$G$9!#(BRuby $B$N(B readline $BB&$G2?$H$+$J$i$J$$$b$N$G$7$g$&$+!)(B

$B>e5-$K4X$7$F3NG’$5$;$F$/[email protected]$5$$!#(B

Readline$B$K$D$$$F!"$$$^$$$5$s$+$i(B2$B$D$NAjCL$,$"$C$?$HG’<1$7$F$$$^$9!#(B

1)GNU Readline
6$B$N>l9g$K(BReadline.completion_append_character$B$K(Bnil$B$r;XDj$G$-$J$$IT6q9g$,$"$k(B

nil$B$r%;%C%H$7$F$bJd408e$K%9%Z!<%9$,DI2C$5$l$kLdBj$G$9$M!#(B
$B$3$A$i$O860x$rD4::$7$FBP1~$7$?$[$&$,$h$$$H9M$($F$$$^$9!#(B

2)GNU Readline 6$B$N>l9g$G$b(B5$B0JA0$HF1MM$NF0:n$K$7$F$[$7$$(B

GNU Readline
6$B$G$O!“Jd408e$K(BReadline.completion_append_character$B$,%G%U%)%k%HCM$X%j%;%C%H$5$l$k$N$G!”(B5$B0JA0$HF1MM$K%j%;%C%H$5$l$J$$$h$&$K$7$F$[$7$$$3$H$G4V0c$$$J$$$G$7$g$&$+!#$3$A$i$K$D$$$F$O!";d$O(BGNU
Readline$B$G$=$N$h$&$J5sF0$J$N$G$"$l$P$=$l$K=>$C$?$[$&$,$h$$$H;W$C$F$$$^$9!#(BGNU
Readline$BK\BN$G$O!“2?$+$7$i$NM}M3$,$”$C$F$=$NJ}$,$h$$$H9M$([email protected]$7$?$N$G$O$J$$$G$7$g$&$+!#$=$N287C$r<u$1$i$l$kJ}$,$h$$$N$G$O$J$$$G$7$g$&$+!#$=$l$,LdBj$G$"$l$P(BGNU
Readline$BK\[email protected]$7$F$b$i$&J}$,$h$$$H;W$$$^$9!#(B

$B0J>e$G$9!#(B
$B$h$m$7$/$*4j$$$7$^$9!#(B

On 2011/04/29, at 22:37, Nobuhiro IMAI wrote:

p RUBY_DESCRIPTION
end

>> “ruby 1.9.3dev (2011-04-29 trunk 31382) [x86_64-linux]”

This document details the changes between this version, readline-6.0,
and the previous version, readline-5.2.
(snip)
f. Fixed a bug that caused the completion append character to not be reset to
the default after an application-specified completion function changed it.

Nobuhiro IMAI [email protected]
Key fingerprint = E57F 2482 4074 13BC 3B9A 165B C689 5B16 A620 4657


TAKAO Kouji [email protected]
blog: http://d.hatena.ne.jp/kouji0625/
twitter: takaokouji / projects: ruby, s7-seven

なかだです。

(11/04/30 14:40), Nobuhiro IMAI wrote:

影響範囲がよく分かっていませんが、Ruby の readline 側で
rl_completion_append_character 相当のものを保持しておいて、補完する時
にセットしてやればいいのではないでしょうか?

やってみたら何か動いてそう、というレベルのものですが、参考までにパッチ
を付けてみます。Ruby のスクリプトから readline.so を使う限りはこれでよ
さそうですが、拡張ライブラリから直接 rl_completion_append_character を
いじるようなことがある(のかどうかは分かってません)と破綻しちゃいそうです。

もうちょっとシンプルに、readline()呼び出し前に保存しておいて補完すると
きにはそれを使うというのはどうでしょうか。readline()呼び出しの最中に他
のスレッドから変更しても上書きされてしまいますが、元々マルチスレッドで
動かせるものでもないと思います。

diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 198f0e6…e1c8316 100644
— a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -70,6 +70,9 @@ static ID id_orig_prompt, id_last_prompt;

static int (*history_get_offset_func)(int);
static int (*history_replace_offset_func)(int);
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+static int readline_completion_append_character;
+#endif

static char **readline_attempted_completion_function(const char *text,
int start, int
end);
@@ -258,6 +261,9 @@ insert_ignore_escape(VALUE self, VALUE prompt)
static VALUE
readline_get(VALUE prompt)
{
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER

  • readline_completion_append_character =
    rl_completion_append_character;
    +#endif
    return (VALUE)readline((char *)prompt);
    }

@@ -642,6 +648,9 @@ readline_attempted_completion_function(const char
*text, int start, int end)
proc = rb_attr_get(mReadline, completion_proc);
if (NIL_P(proc))
return NULL;
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER

  • rl_completion_append_character =
    readline_completion_append_character;
    +#endif
    #ifdef HAVE_RL_ATTEMPTED_COMPLETION_OVER
    rl_attempted_completion_over = 1;
    #endif

$B9bHx$G$9!#(B

On 2011/12/22, at 22:52, Nobuhiro IMAI wrote:

$B$($k$H$&$l$7$$$G$9!#(B
[email protected]$1$G?=$7Lu$J$$$N$G$9$,!"(B
$BCY$/$J$j$^$7$?$,!"<h$j9~$`J}8~$GF0$$$F$$$^$9!#(B
$B$b$&>/$7$*BT$A$/[email protected]$5$$$^$;!#(B


TAKAO Kouji [email protected]
blog: http://d.hatena.ne.jp/kouji0625/
twitter: takaokouji / projects: ruby, s7-seven

$B$$$^$$$G$9!#(B

From: Nobuyoshi N. <nobu_at_ruby-lang.org>
Date: Wed, 21 Dec 2011 17:06:48 +0900

$B$b$&$A$g$C$H%7%s%W%k$K!"(Breadline()$B8F$S=P$7A0$KJ]B8$7$F$*$$$FJd40$9$k$H(B
$B$-$K$O$=$l$r;H$&$H$$$&$N$O$I$&$G$7$g$&$+!#(Breadline()$B8F$S=P$7$N:GCf$KB>(B
$B$N%9%l%C%I$+$iJQ99$7$F$b>e=q$-$5$l$F$7$^$$$^$9$,!"85!9%^%k%A%9%l%C%I$G(B
$BF0$+$;$k$b$N$G$b$J$$$H;W$$$^$9!#(B

$B$J$k$[$I!#$"$j$,$H$&$4$6$$$^$9!#(Br34098
$B$KEv$F$F$_$F!"$&$^$/F0$/$N$r3N(B
$BG’$7$^$7$?!#8D?ME*$JMQES$H$7$F$O$3$l$G==J,[email protected]$H;W$&$N$G!"<h$j9~$s$G$b$i(B
$B$($k$H$&$l$7$$$G$9!#(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs