diff --git a/ice-9/ChangeLog b/ice-9/ChangeLog index 610756417..ccf01cd14 100644 --- a/ice-9/ChangeLog +++ b/ice-9/ChangeLog @@ -1,3 +1,10 @@ +1998-05-11 Mikael Djurfeldt + + * boot-9.scm: Load readline module if readline is present. + + * readline.scm (apropos-completion-function): New procedure: + Symbolic completion. (Thanks to Andrew Archibald!) + 1998-04-22 Mikael Djurfeldt * boot-9.scm (process-define-module): Added keyword use-syntax. diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index ae073261e..19302af80 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -2885,6 +2885,12 @@ (if (%search-load-path "ice-9/session.scm") (define-module (guile) :use-module (ice-9 session))) +;;; {Use readline if present.} +;;; + +(if (memq 'readline *features*) + (define-module (guile) :use-module (ice-9 readline))) + ;;; {Load thread code if threads are present.} ;;; diff --git a/ice-9/readline.scm b/ice-9/readline.scm index cb47d6522..7008fc379 100644 --- a/ice-9/readline.scm +++ b/ice-9/readline.scm @@ -17,8 +17,11 @@ ;;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;;; ;;;; Contributed by Daniel Risacher . +;;;; Extensions based upon code by +;;;; Andrew Archibald . -(define-module (ice-9 readline)) +(define-module (ice-9 readline) + :use-module (ice-9 session)) (define prompt "") @@ -36,7 +39,9 @@ #\nl)) ((= string-index -1) (begin - (set! read-string (readline prompt)) + (set! read-string (readline (if (string? prompt) + prompt + (prompt)))) (set! string-index 0) (if (not (eof-object? read-string)) (begin @@ -66,7 +71,21 @@ (define-public (set-readline-prompt! p) (set! prompt p)) - +(define-public apropos-completion-function + (let ((completions '())) + (lambda (text cont?) + (if (not cont?) + (set! completions + (map symbol->string + (apropos-internal (string-append "^" text))))) + (if (null? completions) + #f + (let ((retval (car completions))) + (begin (set! completions (cdr completions)) + retval)))))) + +(set! *readline-completion-function* apropos-completion-function) + ;(define myport (make-readline-port)) ;(define (doit) ; (set-current-input-port myport))