Here are my basics...
1. Every rear derailleur has a shift ratio, which means how much the derailleur will move for the amount of cable the shifter pulls. For the sake of argument, original Shimano SIS would move 1.7mm for every 1mm of cable pull.
2. Every manufacturer has a different shift ratio than the other manufacturers. Campy, Suntour, Shimano all move a different amount for every 1mm of cable pull. There are some other mfg's made their products compatible.
3. As already stated, derailleur have a range (distance) that they can move that will limit how many cogs can be used.
Based on this, the shifter will pull a certain amount of cable. If it is a friction shifter you can manipulate the amount of swing to shift. The only caveat is a possible limit to the overall throw, 180 degrees, the shifter can move; i.e, Simplex Retrofriction.
An index shifter will pull a certain amount of cable, click, to move a compatible derailleur from one cog to another. The derailleur doesn't care as long as the shift ratio is compatible. So a 6 speed shifter shifts 6 and a 7 speed shifter shifts 7, etc.
I haven't been able to re-space a freewheel, but I have re-spaced cassettes to that a 7 speed shifter works with 6 speed cassette, 8 speed shifter with 7 cassette, etc.
There are work-arounds between shifters and derailleurs and cable attach points to hack the system. Here are a couple of sites...
https://www.cyclinguk.org/cyclists-l...gears/shimergo
Science Behind the Magic | Drivetrain Compatibility ? Art's SLO Cyclery
John
Edit Added: If you really want to get knee deep into this, you can measure the actual amount of cable pull to derailleur movement. There are those who have done this and believe the amount is not consistent (identical) from one cog shift to the next. I have never been so inclined, especiually since I used friction shifters for years, to do this. I'd rather just ride and take it for granted.