[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about readline
From: |
Neil Jerram |
Subject: |
Re: about readline |
Date: |
Sat, 11 Mar 2006 17:03:08 +0000 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
William Xu <address@hidden> 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