(script-fu-register
    "script-fu-select-a-layer"  ;func name
    "select-a-layer "    ;menu label
    " "    ;description
    " "    ;author
    " "    ;copyright notice
    " "    ;date created
    "*"    ;image type that the script works on
    SF-IMAGE    "Image"                 0
    SF-DRAWABLE "Drawable"              0
)
(script-fu-menu-register "script-fu-select-a-layer" "<Image>/Select")

(define (script-fu-select-a-layer image drawable)

    ;start
    (gimp-context-push)
    (gimp-image-undo-group-start image)
    
    ;put your procedures here

  (let* ((layer (car (gimp-image-get-selected-layers image drawable)))
         (width (car (gimp-drawable-get-width drawable)))
         (height (car (gimp-drawable-get-height drawable)))
         (posx (car (gimp-drawable-get-offsets drawable)))
         (posy (cadr (gimp-drawable-get-offsets drawable))))
    (gimp-image-select-rectangle image
                                 CHANNEL-OP-REPLACE
                                 posx
                                 posy
                                 width
                                 height
                                 ))
    
    ;finish
    (gimp-image-undo-group-end image)
    (gimp-context-pop)
    (gimp-displays-flush)
)



