Never give way to melancholy; resist it steadily, for the habit will encroach.
Sydney Smith (1771-1845) English clergyman, essayist, wit
Memoir of the Reverend Sydney Smith, by His Daughter, Lady Holland, Vol. 1, ch. 10 (1855)
(Source)
In chapter 11 is a parallel quotation from Smith: "Never give way to melancholy: nothing encroaches more; I fight against it vigorously."
But Lady Holland observes that in Smith's notebook he also wrote, "I wish I were of a more sanguine temperament; I always anticipate the worst."