Skip to content

R magic extension interferes with tab completion #2759

takluyver opened this Issue Jan 8, 2013 · 4 comments

2 participants

IPython member

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

In [1]: %load_ext rmagic

In [2]: %%%%lsmagic

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

bfroehle commented Jan 8, 2013

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

bfroehle commented Jan 8, 2013

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

import rpy2.rinterface._rinterface
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*/
  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;
  /* --- */

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.

@takluyver takluyver closed this in 1d350ef Jan 10, 2013
@minrk minrk added a commit to minrk/ipython that referenced this issue Jan 26, 2013
@takluyver takluyver Reset readline delimiters after loading rmagic.
Closes gh-2759
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@takluyver takluyver Reset readline delimiters after loading rmagic.
Closes gh-2759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.