Skip to content

R magic extension interferes with tab completion #2759

Closed

Description

@takluyver

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.

Activity

  1. bfroehle commented on Jan 8, 2013

    @bfroehle
    Contributor

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

  2. bfroehle commented on Jan 8, 2013

    @bfroehle
    Contributor

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

    import rpy2.rinterface._rinterface
    rpy2.rinterface._rinterface.initr()
  3. bfroehle commented on Jan 8, 2013

    @bfroehle
    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.

  4. bfroehle commented on Jan 8, 2013

    @bfroehle
    Contributor
  5. added a commit that references this issue on Jan 9, 2013
    1d350ef
  6. added a commit that references this issue on Jan 26, 2013
    558aeaf
  7. added a commit that references this issue on Nov 3, 2014
    cfb3995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions