Re: Readline completion example?

Pascal Bourguignon <[email protected]>
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
> On 18 Feb 2017, at 21:06, Jean Louis <[email protected]> wrote:
> 
> Hello,
> 
> While I am using CLISP to add the console based editing of values in a
> database, may somebody tell me how to implement the readline
> completion?
> 
> I have been searching for the function, I was expecting to find
> something like readline completion function and example, but
> failed. And on mailing list I don't get results that I wish.
> 
> My idea is to provide a list or plist or similar, so that by
> completing a string, one get the value related to the string,
> something like that.
> 
> Any example of completion for built-in readline in CLISP?


It looks like rl_completion_entry_function is not mentionned in clisp/modules/readline/readline.lisp and that no variable readline:completion-entry-function is present in the readline package.

Indeed, I don’t see how to specify the completions with the API defined in readline.lisp Perhaps it correspond to an older readline library version that didn’t have it? Perhaps the mechanism is preempted by clisp, since we can see that in the terminal, clisp has completion on the the symbol names (operators, variables), and shows the documentation of the operator when they are complete. 

See init_streamvars in stream.d:
  rl_attempted_completion_function = &lisp_completion_matches;
  rl_completion_entry_function = &lisp_completion_more;

they call lisp_completion, which calls (SYS::COMPLETION text start end) in complete.lisp


So this would be the definitive example, and you could override this function, (unlocking the SYSTEM package to do so).  I guess your overriding function could determine whether you’re completing lisp input or user input and call the original sys::complete to complete lisp input.

It would be nice to provide a patch to this sys::completion with a hook so that applications may provide their own completions. (I would make it a per-stream hook).

-- 
__Pascal J. Bourguignon__



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.