> I keep running into this, actually. There are plenty of examples out there of
> people checking whether the face at point is font-lock-comment-face or
> font-lock-string-face or font-lock-doc-face to know whether the current point is
> in a comment or string. Using (nth 8 (syntax-ppss)) instead mostly works, except
> that it's nil in comment openers (e.g. in ;; in ELisp) and closers.
(nth 8 (syntax-ppss)) works fine for me in something like ";; some comment in an emacs-lisp-mode buffer"; it returns the starting point of the comment.
But I use something like below in my emacs config in one of the functions:
(or (nth 3 (syntax-ppss)) ; string
(nth 4 (syntax-ppss))) ; comment