Very useful and undoubtedly would allow for less current surge, less strain on motors etc - Not something I'd thought of using Gcode for
I don't have variable speed spindle drives but you could do it like this (I think) as apart from anything else I've become a most beastly evangelist for parametrics.
I've written in some thoroughly verbose comments for each line as I'm well aware there are those who haven't used parametrics much (and those who are just starting out, hopefully this will help)
#1=0 (sets variable "1" to zero, creating it first if it does not already exist)
M98 P111 L56 (calls subroutine "O111", 56 times)
(place this at the end of the code with other subroutines)
O111
#1=[#1+100] (100 is the acceleration incriment)
(this line raises variable 1's value by 100)
M03 S #1 (starts spindle if not already running, sets spindle speed to the value of variable 1)
G04 P2 (waits 10ms)
M99 (exit subroutine and go back to main code)
%
All this does is save you typing really, but it does mean you can just put your subroutine at the end then call
#1=0
M98 P111 L25
Which resets variable "1" and then ramps up the spindle speed to 2,500 RPM. you must put #1=0 before calling the subroutine because variables are persistent within the program, and if you don't zero "1" then the spindle will just hard-start at whatever value it had previously and accelerate from there! Otherwise, two lines of code to start the spindle and set its final speed according to the predefined acceleration ramp you've set in the subroutine - in this case 1,000 RPM per second.
It simulates ok for me on my laptop with no machine attached, I'd be interested to know how it goes on someone else's machine with a variable drive. As usual - own risk, no warranties etc..