[ocaml-ctypes] Setting completion function variable for Readline

Phil Hagelberg phil at hagelb.org
Sun Sep 22 20:50:22 BST 2013


I've been using ctypes to call into GNU Readline, and it's been working
out nicely so far. However, I'd like to implement my own custom
completer functionality, and I'm having some difficulty with
that. Readline's documentation[1] says you can set the
"rl_completion_entry_function" variable to a function pointer which can
handle your completion:

> Variable: rl_compentry_func_t * rl_completion_entry_function
>     This is a pointer to the generator function for
>     rl_completion_matches(). If the value of
>     rl_completion_entry_function is NULL then the default filename
>     generator function, rl_filename_completion_function(), is used. An
>     application-specific completion function is a function whose address
>     is assigned to rl_completion_entry_function and whose return values
>     are used to generate possible completions. 

But I can't find any way to do this from OCaml, with or without
Ctypes. I see some mention of passing OCaml functions as arguments to C
functions, but in this case I need to put it in a variable instead. I
don't actually know C myself, or I'd imagine it'd be easy to do with a
small shim written in C. Is this possible with Ctypes?

thanks,
Phil

[1] - http://tiswww.case.edu/php/chet/readline/readline.html#SEC44
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://lists.ocaml.org/pipermail/ctypes/attachments/20130922/a4c3b4d6/attachment.sig>


More information about the Ctypes mailing list