examples/insert-lambda.rkt
#lang racket/base
(require racket/class)

;; Surrounds the selection with a lambda
;; and places the cursor in the argument list position.
;; string? -> string?
(provide item-callback)
(define (item-callback str #:definitions edit) 
  (send edit begin-edit-sequence)
  (let ([selection-start (send edit get-start-position)]
        [selection-end (+ 1 (send edit get-end-position))])
    (send* edit 
      (set-position selection-start)
      (insert ")")
      (set-position selection-end)
      (insert ")")
      (set-position selection-start)
      (insert "(λ(")))
  (send edit end-edit-sequence)
  #f)