examples/complete-word.rkt
#lang racket/base
(require racket/class racket/dict)

;;; Replaces the text abbreviation right before the caret by some expanded text
;;; Laurent Orseau <laurent orseau gmail com> -- 2012-04-19

(define words
  '(("dsr"   . "(define-syntax-rule (")
    ("ds"    . "(define-syntax ")
    ("sr"    . "(syntax-rules ()\n    [(_ ")
    ("sc"    . "(syntax-case stx ()\n    [(_ ")
    ("lbd"   . "(λ(")
    ("para"  . "(parameterize ([current-")
    ("wh"    . "(with-handlers ([exn:")
    
    ))

(provide item-callback)
(define (item-callback s #:editor ed)
  (define pos (send ed get-end-position)) 
  (define str
    (send ed get-text 
          (send ed get-backward-sexp pos) 
          pos))
  (define str-ext (dict-ref words str #f))
  (and str-ext
       (send ed select-backward-sexp)
       str-ext))