I had to do this lately -- it was easy on my machine, though I'm not sure it would be on any ol' machine!
First, I hunted my resource center for something black, with lycra. Found some Malden 2000 "aqua shell" -- a fleece with 4-way stretch and a "bike short like outer finish" I cut squares a bit bigger than my holes.
Pant leg on the free arm, patch on the outside of the fabric, I chose a stitch that would cover the edges of the fabric square, on the stitch menu that does the 4-way stitching. No turning the fabric -- this is essential to mending happiness! Stitched along one side, then had the machine turn the corner and stitch the next direction. Told the machine to turn at each corner, and stitched all the way 'round the patch. Then moved on to the other leg!
I thought the patch should go on the outside -- seemed like the shorts would rub my legs less if the patch was out instead of in, and so far, so good (it's been a couple of weeks, and a hundred or so miles)
My machine is Husqvarna Viking -- there have been several models over the years that have this "4-way stitching" feature, and I'm sure glad I have it!
If you don't have the 4-way thing, you'll be turning your fabric, but pick a stretchy stitch that will hold the edges of the patch down pretty well, so the fabric is well secured to your shorts -- this will help prevent the edges from getting frayed!
Karen in Boise