In Star Trek IV: The Voyage Home (1986), the crew find themselves in 1980’s San Francisco, and promptly realize that they are perceived as socially awkward. Kirk, in an apparent effort to explain the behavior of Spock, comments
“Oh, him? He’s harmless. Part of the free speech movement at Berkeley in the sixties. I think he did a little too much LDS.”
Obviously, Kirk had intended to refer to the drug LSD rather than “LDS,” and I've always understood this as an out-of-universe joke about the Church of Jesus Christ of Latter-day Saints, who sometimes refer to themselves as “LDS.” The joke seems to work both because the LDS have a reputation in comedy of being somewhat socially awkward and also maintain a strong stand against drug use.
This strikes me as odd, as Star Trek has historically avoided cheap religious jokes in favor of broader stories hinting at religious themes.
Is there any official word or other strong indication as to whether this was the intended meaning of this joke? In other words, does Kirk mess this up solely because he is not familiar enough with 20th century US culture or did Paramount and/or Shatner intend to drop a “Mormon joke” into the script?