R magic extension interferes with tab completion #2759

Closed
takluyver opened this Issue Jan 8, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@takluyver
Member

takluyver commented Jan 8, 2013

To reproduce:

  1. Start IPython in the terminal.
  2. Enter %lsm and hit tab a couple of times. The first press completes %lsmagic, the second does nothing, and subsequent presses show %lsmagic as the only completion available, returning you to the prompt.
  3. Clear the line (e.g. with backspace), type %load_ext rmagic, and hit return.
  4. Repeat step 2. This time, each press of tab adds another % to the start of the line.
In [1]: %lsmagic
%lsmagic

In [1]: %load_ext rmagic

In [2]: %%%%lsmagic

It seems specific to rmagic - neither sympyprinting nor cythonmagic has the same effect.

@bfroehle

This comment has been minimized.

Show comment
Hide comment
@bfroehle

bfroehle Jan 8, 2013

Contributor

It seems to stem from the import rpy2.robjects as ro line in rmagic.py.

Contributor

bfroehle commented Jan 8, 2013

It seems to stem from the import rpy2.robjects as ro line in rmagic.py.

@bfroehle

This comment has been minimized.

Show comment
Hide comment
@bfroehle

bfroehle Jan 8, 2013

Contributor

But you can trace that back to a minimal example which breaks it:

import rpy2.rinterface._rinterface
rpy2.rinterface._rinterface.initr()
Contributor

bfroehle commented Jan 8, 2013

But you can trace that back to a minimal example which breaks it:

import rpy2.rinterface._rinterface
rpy2.rinterface._rinterface.initr()
@bfroehle

This comment has been minimized.

Show comment
Hide comment
@bfroehle

bfroehle Jan 8, 2013

Contributor

I'd guess the root cause is something to do with this C code from _rinterface.c (in EmbeddedR_init()):

/*FIXME: setting readline variables so R's oddly static declarations
   become harmless*/
#ifdef HAS_READLINE
  char *rl_completer, *rl_basic;
  rl_completer = strndup(rl_completer_word_break_characters, 200);
  rl_completer_word_break_characters = rl_completer;

  rl_basic = strndup(rl_basic_word_break_characters, 200);
  rl_basic_word_break_characters = rl_basic;
#endif
  /* --- */

Or perhaps the lack of --no-readline in the arguments when R is spun up. We need to forward this upstream to the r2py folks.

Contributor

bfroehle commented Jan 8, 2013

I'd guess the root cause is something to do with this C code from _rinterface.c (in EmbeddedR_init()):

/*FIXME: setting readline variables so R's oddly static declarations
   become harmless*/
#ifdef HAS_READLINE
  char *rl_completer, *rl_basic;
  rl_completer = strndup(rl_completer_word_break_characters, 200);
  rl_completer_word_break_characters = rl_completer;

  rl_basic = strndup(rl_basic_word_break_characters, 200);
  rl_basic_word_break_characters = rl_basic;
#endif
  /* --- */

Or perhaps the lack of --no-readline in the arguments when R is spun up. We need to forward this upstream to the r2py folks.

@bfroehle

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment