From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.devel 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 Message-ID: References: <20160308132530.861.91488@vcs.savannah.gnu.org> <20160308183010.GB6269@acm.fritz.box> <20160308200753.GC6269@acm.fritz.box> <20160309104900.GA3948@acm.fritz.box> <56E05831.9070900@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113d3b74ba9510052da0fbde X-Trace: ger.gmane.org 1457544337 14213 80.91.229.3 (9 Mar 2016 17:25:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Mar 2016 17:25:37 +0000 (UTC) Cc: Emacs developers To: =?UTF-8?B?Q2zDqW1lbnQgUGl0LS1DbGF1ZGVs?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 09 18:25:36 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1adhrZ-0004QM-Bp for ged-emacs-devel@m.gmane.org; Wed, 09 Mar 2016 18:25:33 +0100 Original-Received: from localhost ([::1]:42914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adhrY-0006Rf-8y for ged-emacs-devel@m.gmane.org; Wed, 09 Mar 2016 12:25:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adhrS-0006RY-Ki for emacs-devel@gnu.org; Wed, 09 Mar 2016 12:25:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adhrR-0004s7-OB for emacs-devel@gnu.org; Wed, 09 Mar 2016 12:25:26 -0500 Original-Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:32846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adhrR-0004ry-Iy for emacs-devel@gnu.org; Wed, 09 Mar 2016 12:25:25 -0500 Original-Received: by mail-oi0-x229.google.com with SMTP id d205so40931132oia.0 for ; Wed, 09 Mar 2016 09:25:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gw5EMc/9BlzY6Nx/vP8IQW8vxWK8iOHhyuwvPe03uQw=; b=Dmv3VVkUMgP8Kxth4Pw0Yo8Kp8v6xbXLFplf7Z9PylKIKyj2GDeHw0N5VxJ/oXVz9b Vb1Zgr4Dc1+DUWh8mAm5G/QGQj/OI6LuE11WzAKVcsC44NbIIDMeFCVk1qud9mfHRrNi Hjf+jmfi2UX1HOD2ldIvNHIl+CttFp6bS+yBji69dPBfeFpYRBN+mZSiJEy0n0XcKz+T tz6ZEQdTDi1dniR1Ku933C5bu/yDhdwZopSGXjJNw32xbyq776SKVr5yWkIJEWUNhHdr RNtoQ+Tzswr9zyF3Knz+kDuQypB4xWUOJ6IdMKMXfUxmv5U3+5sC/6t0TyjKGjPERKT6 qq2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gw5EMc/9BlzY6Nx/vP8IQW8vxWK8iOHhyuwvPe03uQw=; b=AyT0/1JnRhF5qrjHtzVz8+XwMD+TAIjAoH9UhIorUuRqnTjk4vraHoWlVyQDIK+MSl 3dAqYm4YqS43S/prigEfQ/D9o/bOB7cnwLIpVF9d1H2OGSEer7Dyof0t4DvJ1OYdgtmH 3Rii1hFsjeJekWcbbKGvJkZfEOVE8u93G+mqE2t/WlcOvcwUPLvoy+UVni1+Ot01V/Ak 6fBl/b0iqMqJmkBwMuZJ2jt/49GPqedwe0bZNJo7m8QG2mnj9lFPrfDXo1yWqm1XVQ3Z tN6yb29GvQ06Zjryoi62yO4aibnKq1qBodwD8Y8dsfuCqrS6m8MUNXFUo0ERwdYUKqfr xQCw== X-Gm-Message-State: AD7BkJKreX4fuDjixCj3/bM2uK6Fj84wbylomH7nGvNk4+hFnsMzgpiW/y4CX8LiZVSHNS/TkP4xa7/gFj0ybw== X-Received: by 10.202.207.13 with SMTP id f13mr21112908oig.44.1457544324868; Wed, 09 Mar 2016 09:25:24 -0800 (PST) Original-Received: by 10.202.172.198 with HTTP; Wed, 9 Mar 2016 09:24:45 -0800 (PST) In-Reply-To: <56E05831.9070900@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:201259 Archived-At: --001a113d3b74ba9510052da0fbde Content-Type: text/plain; charset=UTF-8 > 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 --001a113d3b74ba9510052da0fbde Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> I keep running into this, actually. There a= re plenty of examples out there of
> people checking whether t= he face at point is font-lock-comment-face or
> font-lock-stri= ng-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 w= orks, 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-li= sp-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)) ; strin= g
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (nth 4 (syntax= -ppss))) ; comment

=

PS: I am on the lates= t emacs-25 build as of today.

--
Kaushal Modi<= /div>
--001a113d3b74ba9510052da0fbde--