The system used in the roguelike Linley's Dungeon Crawl (and its currently-maintained fork, Stone Soup) mostly takes care of that: when you get XP, you also get an equal number skill points; whenever an action practices a skill, some number of points from that skill pool are transferred into the skill, and eventually the skill levels up. If the pool is empty, you don't gain skill. (Also, in the skill screen, skills can be set to not be actively practiced, which greatly reduces the skill points consumed by using them; this is for things like if you're using a given type of weapon but don't plan on specializing in it.)
In practice, there's still some incidence of "victory dancing" --- after a big kill, standing around repeatedly casting some spell to make sure that the points go into some particular magic skill(s) --- but not much, and because the points would have gone into something useful anyway, it's more a question of whether the player actually wants to do that kind of powergaming.
This restaurant was advertising breakfast any time. So I ordered french toast in the renaissance. - Steven Wright, comedian