William Xu <[EMAIL PROTECTED]> writes:

> While this is a function? It seems the very variable is
> *readline-completion-function*, but which is not exported from the
> module?

Yes.  I guess the point is to protect the normal value of
*readline-completion-function* from being permanently lost.  Is this
interface a problem in practice for you?

> Also, i have no clue how to contruct a proper `completer' for
> with-readline-completion-function. The docstring is too simple... 

It is a bit odd, but basically follows the corresponding C interface.
Here's an example which worked some time ago for me.  (I haven't
tested it recently.)

  ...
  (with-readline-completion-function
      (command-completion-function commands)
    (lambda ()
      ...))
  ...

(define (command-completion-function commands)
  ;; commands is a list of strings representing the possible
  ;; completions.
  (letrec ((cmds '())
           (regexp #f)
           (completer (lambda (text continue?)
                        (if continue?
                            (if (null? cmds)
                                #f
                                (let ((cmd (car cmds)))
                                  (set! cmds (cdr cmds))
                                  (if (string-match regexp cmd)
                                      cmd
                                      (completer text #t))))
                            (begin
                              (set! cmds commands)
                              (set! regexp
                                    (string-append "^" (regexp-quote text)))
                              (completer text #t))))))
    completer))

Regards,
        Neil



_______________________________________________
Guile-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/guile-user

Reply via email to