manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8.3.2 Completion

Function: with-readline-completion-function completer thunk

Call (thunk) with completer as the readline tab completion function to be used in any readline calls within that thunk. completer can be #f for no completion.

completer will be called as (completer text state), as described in (see How Completing Works in GNU Readline Library). text is a partial word to be completed, and each completer call should return a possible completion string or #f when no more. state is #f for the first call asking about a new text then #t while getting further completions of that text.

Here’s an example completer for user login names from the password file (see section User Information), much like readline’s own rl_username_completion_function,

(define (username-completer-function text state)
  (if (not state)
      (setpwent))  ;; new, go to start of database
  (let more ((pw (getpwent)))
    (if pw
        (if (string-prefix? text (passwd:name pw))
            (passwd:name pw)     ;; this name matches, return it
            (more (getpwent)))   ;; doesn't match, look at next
        (begin
          ;; end of database, close it and return #f
          (endpwent)
          #f))))
Function: apropos-completion-function text state

A completion function offering completions for Guile functions and variables (all defines). This is the default completion function.

Function: filename-completion-function text state

A completion function offering filename completions. This is readline’s rl_filename_completion_function (see Completion Functions in GNU Readline Library).

Function: make-completion-function string-list

Return a completion function which offers completions from the possibilities in string-list. Matching is case-sensitive.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on February 3, 2012 using texi2html 5.0.