Emacs Lisp: Determine Cursor is Inside String/Comment

By Xah Lee. Date: . Last updated: .

Check If Cursor is Inside String

(nth 3 (syntax-ppss))
returns true if cursor is inside a string.

Check If Cursor is Inside Comment

(nth 4 (syntax-ppss))
returns true if cursor is inside a comment.

(info "(elisp) Parsing Expressions")

thanks to Elias Martenson [https://plus.google.com/+EliasMartenson/posts] for feedback.

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Elisp Write Major Mode

Basics

Package Name/Load

Syntax Table