Sir Keir Starmer said he will not repeat the mistakes which "decimated" coal mining communities in the 1980s with his plan to phase out new oil and gas drilling.