[IPython-user] Re: OSX tab completion

Robert Kern rkern at ucsd.edu
Fri Apr 1 20:38:46 CST 2005

Fernando Perez wrote:
> Robert Kern wrote:
>>> Robert, does this mean you also have the same problem?  I didn't 
>>> realize that this was a widespread OSX issue.  If someone has a 
>>> definitive solution/answer to this, please let me know so I can add 
>>> this information to the user's guide for future reference.
>> Yes, I have the same problem. I am using my own build of readline 5.0. 
>> Unless I get more info very soon, this is also the build that will be 
>> in MacEnthon.
> OK, this is definitely controlled by the python build of readline.c.  
> Here are some pointers.  From the Gnu readline manual at
> http://cnswww.cns.cwru.edu/~chet/readline/readline.html,
> I found this note:
> Variable: int rl_completion_append_character
>     When a single completion alternative matches at the end of the 
> command line, this character is appended to the inserted completion 
> text. The default is a space character (` '). Setting this to the null 
> character (`\0') prevents anything being appended automatically. This 
> can be changed in application-specific completion functions to provide 
> the "most sensible word separator character" according to an 
> application-specific command line syntax specification.
> Indeed, in the Python 2.4.1 source tree, in Modules/readline.c, around 
> line 717 we find:
>         rl_completion_append_character ='\0';
> #endif
> Now, a grep of the whole source tree reveals:
> planck[Python-2.4.1]> egrep -rn HAVE_RL_COMPLETION_APPEND_CHARACTER *
> configure:19433:#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
> Modules/readline.c:487:#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
> Modules/readline.c:579:#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
> Modules/readline.c:716:#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
> Modules/readline.c:858:#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
> pyconfig.h.in:375:#undef HAVE_RL_COMPLETION_APPEND_CHARACTER
> So what appears to occur is that under OSX, for whatever reason, 
> configure is NOT defining the HAVE_RL_COMPLETION_APPEND_CHARACTER macro, 
> and hence the rl_completion_append_character is never reset to '\0'.  In 
> this case, as indicated above, the readline library will default to 
> appending a space.
> With this info, it should be possible to track down why under OSX (at 
> least under certain builds), the HAVE_RL_COMPLETION_APPEND_CHARACTER 
> macro is not being defined.  Worse case, you could just modify 
> readline.c to make the above change unconditionally, without worrying 
> about this macro (just strip the ifdef/endif).

Well, since Apple's core interpreter isn't ./configure'd with readline, 
then of course it wouldn't show up in the pyconfig.h. Fink, of course, 
builds python assuming it's own readline.

Assuming I don't completely bozo it up, MacEnthon's version will have 
this fix.

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

More information about the IPython-user mailing list