Today, melancholy means sad or "blue" but it used to have a broader meaning. It encompassed obsessions and compulsions. Samuel Johnson, who published the first English dictionary, defined the term in 1755 this way:
MELANCHOLY.
1. A disease, supposed to proceed from a redundance of black bile; but it is better known to arise from too heavy and too viscid blood: its cure is in evacuation, nervous medicines, and powerful stimuli.
2. A kind of madness, in which the mind is always fixed on one object. [Here there is a Shakespearian quotation about melancholy.]
3. A gloomy, pensive, discontented temper. [More literary quotations here.]