emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you check if the current point is in a comment or a string? (


From: Kaushal Modi
Subject: Re: How do you check if the current point is in a comment or a string? (Was Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.])
Date: Wed, 9 Mar 2016 12:24:45 -0500

> 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


PS: I am on the latest emacs-25 build as of today.

--
Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]