unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* about readline
@ 2006-03-11 14:56 William Xu
  2006-03-11 15:09 ` Neil Jerram
  0 siblings, 1 reply; 6+ messages in thread
From: William Xu @ 2006-03-11 14:56 UTC (permalink / raw)


Hi, 

I'd like to control the completing candicates when doing readline
completion. For instance, suppose there's a variable
readline-completing-string with value "foo bar", then completions will
be based on either "foo" or "bar". Is there such a variable in readline?

-- 
William


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: about readline
  2006-03-11 14:56 about readline William Xu
@ 2006-03-11 15:09 ` Neil Jerram
  2006-03-11 15:42   ` William Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Neil Jerram @ 2006-03-11 15:09 UTC (permalink / raw)
  Cc: guile-user

William Xu <william.xwl@gmail.com> writes:

> Hi, 
>
> I'd like to control the completing candicates when doing readline
> completion. For instance, suppose there's a variable
> readline-completing-string with value "foo bar", then completions will
> be based on either "foo" or "bar". Is there such a variable in readline?

Yes, please see with-readline-completion-function in
ice-9/readline.scm.

    Neil 



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: about readline
  2006-03-11 15:09 ` Neil Jerram
@ 2006-03-11 15:42   ` William Xu
  2006-03-11 17:03     ` Neil Jerram
  0 siblings, 1 reply; 6+ messages in thread
From: William Xu @ 2006-03-11 15:42 UTC (permalink / raw)


Neil Jerram <neil@ossau.uklinux.net> writes:

> William Xu <william.xwl@gmail.com> writes:
>
>> Hi,
>>
>> I'd like to control the completing candicates when doing readline
>> completion. For instance, suppose there's a variable
>> readline-completing-string with value "foo bar", then completions will
>> be based on either "foo" or "bar". Is there such a variable in readline?
>
> Yes, please see with-readline-completion-function in
> ice-9/readline.scm.

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

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

-- 
William


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: about readline
  2006-03-11 15:42   ` William Xu
@ 2006-03-11 17:03     ` Neil Jerram
  2006-03-12 11:19       ` William Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Neil Jerram @ 2006-03-11 17:03 UTC (permalink / raw)
  Cc: guile-user

William Xu <william.xwl@gmail.com> 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
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: about readline
  2006-03-11 17:03     ` Neil Jerram
@ 2006-03-12 11:19       ` William Xu
  2006-03-12 14:38         ` Neil Jerram
  0 siblings, 1 reply; 6+ messages in thread
From: William Xu @ 2006-03-12 11:19 UTC (permalink / raw)


Neil Jerram <neil@ossau.uklinux.net> writes:

> William Xu <william.xwl@gmail.com> 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?

Hmm, not really. I think i'm okay with it at present.

>> 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.)
>

[...]

That works. Thanks. And i thought maybe this function can be included in
readline module. It is very useful.

-- 
William


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: about readline
  2006-03-12 11:19       ` William Xu
@ 2006-03-12 14:38         ` Neil Jerram
  0 siblings, 0 replies; 6+ messages in thread
From: Neil Jerram @ 2006-03-12 14:38 UTC (permalink / raw)
  Cc: guile-user

William Xu <william.xwl@gmail.com> writes:

> [...]
>
> That works. Thanks. And i thought maybe this function can be included in
> readline module. It is very useful.

Yes, I was thinking that too.  I'll add it.

    Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-12 14:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-11 14:56 about readline William Xu
2006-03-11 15:09 ` Neil Jerram
2006-03-11 15:42   ` William Xu
2006-03-11 17:03     ` Neil Jerram
2006-03-12 11:19       ` William Xu
2006-03-12 14:38         ` Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).