Changeset 12493 in project


Ignore:
Timestamp:
11/14/08 05:28:28 (12 years ago)
Author:
mfredrickson
Message:

Providing basic file globbing and restructuring the way completion callback procedures are created, stored, and retrieved (an alist like list of lists -- though technically not an alist. I may switch to an alist later. I haven't made up my mind).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/readline/readline.scm

    r10881 r12493  
    105105  gnu-readline-parse-and-bind
    106106  gnu-readline-set-bounce-ms
     107 
     108  gnu-readline-completions
    107109  ))
    108110
     
    511513
    512514;; Creates a list of closures that enumerate anything the user would want to type
    513 (define (create-enum-funcs word len)
    514   ;; Environment symbols
    515   (define (create-symbol-ef)
     515(define (create-symbol-ef word)
    516516        (let ((global-symbol-index (cons -1 '()))
    517517                  (global-symbol-pointer (find-symbol-table ".")))
     
    530530                                                str
    531531                                                (string-append (substring str 3) ":"))))))))))
    532   ;; R5RS keywords (including some special forms not included in above)
    533   (define (create-static-ef)
     532                                               
     533;; R5RS keywords (including some special forms not included in above)
     534(define (create-static-ef word)
    534535        (let ((index -1)
    535536                  (v-len (vector-length static-keywords)))
     
    539540                  (vector-ref static-keywords index)
    540541                  ""))))
    541   ;; Macros (thanks to Kon Lovett for suggesting ##sys#macro-environment)
    542   (define (create-macro-ef)
     542                 
     543;; Macros (thanks to Kon Lovett for suggesting ##sys#macro-environment)
     544(define (create-macro-ef word)
    543545        (let ((index -1))
    544546          (lambda ()
     
    552554                                          (loop)
    553555                                          (symbol->string (caar ref))))))))))
    554   ;; Return a list of the above closures
    555   (list (create-symbol-ef) (create-static-ef) (create-macro-ef)))
    556 
     556
     557(define (create-file-ef word)
     558  (let ((files (glob (string-append word "*"))))
     559    (lambda ()
     560      (if (null? files) ""
     561        (let ((current (car files)))
     562          (set! files (cdr files))
     563          current)))))
     564         
     565(define gnu-readline-completions
     566  (make-parameter
     567    (list
     568      (list 'macros create-macro-ef)
     569      (list 'statics create-static-ef)
     570      (list 'symbols create-symbol-ef)
     571      (list 'files create-file-ef))))
    557572
    558573
     
    565580         (when (zero? state)
    566581           (if (not (zero? len))
    567                  (set! enum-funcs (create-enum-funcs word len))
     582                 (set! enum-funcs
     583                   (map (lambda (pair) ((cadr pair) word)) (gnu-readline-completions)))
    568584                 ""))
    569585         ;; Call the enumeration funcs, discarding the ones that are done
Note: See TracChangeset for help on using the changeset viewer.