.csirc for parley with scheme completion added by wasamasa on Thu Oct 19 14:20:20 2017

(use (prefix parley "pl-")
     (prefix parley-auto-completion "pl-")
     (only srfi-1 append-map)
     (only apropos apropos-list)
     (only data-structures substring-index substring=? o))

(define (parley-setup)
  (define (apropos-completions prefix)
    (let ((candidates (apropos-list `(: bos ,prefix) #:macros? #t)))
      (remove
       (lambda (candidate) (substring-index "#" candidate))
       (map symbol->string candidates))))
  (define (current-environment-completions prefix)
    (let ((size (string-length prefix)))
      (filter
       (lambda (candidate) (substring=? prefix candidate 0 0 size))
       (map (o symbol->string car) (##sys#current-environment)))))
  (define (scheme-completer prefix)
    (append (apropos-completions prefix)
            (current-environment-completions prefix)))
  (pl-word-class '($ (+ (~ (" \t\n\"\\'`;|(")))))
  (pl-completion-choices
   (lambda (_input _position last-word)
     (scheme-completer last-word)))
  (pl-add-key-binding! #\tab pl-auto-completion-handler)
  (let ((old (current-input-port))
        (history-file (format "~a/.csi_history"
                              (get-environment-variable "HOME"))))
    (current-input-port (pl-make-parley-port old prompt: "#;> "
                                             history-file: history-file))))

(when (not (get-environment-variable "INSIDE_EMACS"))
  (parley-setup))