plugins.scm
(module plugins mzscheme
        (require "hwikireq.scm")
        (provide plugin-function
                 plugin-editor
                 register-plugin
                 plugin-exists?
                 enumerate-plugins
                 )

        (define PLUGINS (make-hash-table))
        (define PLUGIN-EDITORS (make-hash-table))

        (define (plugin-exists? name)
          (if (string? name)
              (plugin-exists? (string->symbol (string-downcase name)))
              (if (eq? (hash-table-get PLUGINS name (lambda () '%not%)) '%not%)
                  #f
                  #t)))

        (define (plugin-function name)
          (if (string? name)
              (plugin-function (string->symbol (string-downcase name)))
              (hash-table-get PLUGINS name)))

        (define (plugin-editor name)
          (if (string? name)
              (plugin-editor (string->symbol (string-downcase name)))
              (hash-table-get PLUGIN-EDITORS name)))

        (define (register-plugin _name plugin-function . args)
          (let ((name (if (string? _name)
                          (string->symbol (string-downcase _name))
                          _name))
                (editor (=> 'editor args 'html)))
            (debug (format "registering plugin: ~s, ~s, ~s" name plugin-function editor))
            (hash-table-put! PLUGINS name plugin-function)
            (hash-table-put! PLUGIN-EDITORS name editor)
            ))
        
        (define (enumerate-plugins)
          (hash-table-map PLUGINS (lambda (key val)
                                    (list key val (hash-table-get PLUGIN-EDITORS key)))))

        )