From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: How does one set up a syntax table for (* and //? Date: Thu, 12 Jan 2017 20:33:19 -0500 Message-ID: References: <18d576b9-fe12-c09a-32f9-ad0da86f2d27@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uJ1oTeP2BHgohPvwntUdi1eEhxmntVTC7" X-Trace: blaine.gmane.org 1484271262 427 195.159.176.226 (13 Jan 2017 01:34:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 13 Jan 2017 01:34:22 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 13 02:34:16 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRqkq-0007Vq-3m for ged-emacs-devel@m.gmane.org; Fri, 13 Jan 2017 02:34:08 +0100 Original-Received: from localhost ([::1]:38532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRqku-0006VW-72 for ged-emacs-devel@m.gmane.org; Thu, 12 Jan 2017 20:34:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRqkH-0006VQ-I3 for emacs-devel@gnu.org; Thu, 12 Jan 2017 20:33:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRqkE-00062y-74 for emacs-devel@gnu.org; Thu, 12 Jan 2017 20:33:33 -0500 Original-Received: from mout.kundenserver.de ([212.227.126.133]:63706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cRqkD-00061Q-Sa for emacs-devel@gnu.org; Thu, 12 Jan 2017 20:33:30 -0500 Original-Received: from [18.111.103.8] ([18.111.103.8]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.168]) with ESMTPSA (Nemesis) id 0M53xy-1cehw01BqY-00zFrB for ; Fri, 13 Jan 2017 02:33:26 +0100 In-Reply-To: X-Provags-ID: V03:K0:EC0WxjqjLa5CZiYWXlLijZ3ZXowI3n2AvYMHmsbJIKDl9Nhazxh osu1EOY4xKPM2l7wEaPQBCLTyGwL4/t6jEj00zoEEQ90keoHtIoBHYloYnDSHLq65x+HbFo QrVHaDSWxMXhwmZvViyA54+hy5MKuR5+vjZmMCw2PhTVUbaw/BCA83cIVdmBHNTXBA+MICT MHYC+u+PTXji+f6XAzTyA== X-UI-Out-Filterresults: notjunk:1;V01:K0:PMC7VQslFIE=:MUJ965Lh3K4vEBHwfvqVf2 wkXtAhFmXaptrVNjZoGzDAWe7+CXwtb99cK6EibOEeWZ+JGGXV/i9YF2CBxg9GJ+8OM3O+y3X jxAWzTdAbX5aqFBftFq2SFQiEcaOhrcZZmIpptAOQP5ptE9bKSg4rDAbkWP6O7Ud0cJ8si1iZ ztkaoEvFjOlP3WJ9WDj978R3FVT8s5J2gmqKadTyPzO3p1vAs0Y6VD4tAuB4uNcUlb4f+tcvg 5Fugh4sjSPpha3LGJy9bzKu09SB/G0n2eibMzKJbk8y+uB3KoVftLUhEdu2tjp7Nb9YtBfkot r6LnOhT7W6/59OpxqCECK8YHSzJ+JLtDRg6uWIFLWdX7kzjnMkAnBw/2PGfM7AUVnqlhwh20l UHzDitXasrFHWCSXANQ3qfbygnESXr9NeKqiW4ed8tdShZKVP2/D+2pMW9V84m9Hry0HDd+NC hIz4AGHExQSSX1YzTsn9bugSLjP2JT9Tg0nEGjnitiLyGjTRh3BPPJNssYGrwCGwvHlhwRTKk RcxXi6Mw1DUE0SN6pH0xg5JJnbbULN1ibJ8TNBdJuKtPkkSbDtSWJf4uMjmapBFuh0jEQLmcs 1lUsUvGKJWY04caeZFgWHZhvBkKtWn+Q9dq8cug+c72Jocv/siUuhPRZ2aWtOAcB70eggeOUK 0zkQ4VUIjF+9TjYYqBDH3IZ/Tg10Sj4mu8hcexm2EiVpGsNj9svv5+ZiFa70WWhljjPQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:211235 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uJ1oTeP2BHgohPvwntUdi1eEhxmntVTC7 Content-Type: multipart/mixed; boundary="OTd59vGUGJotLeKXdKr4UDarfhWpOPCQJ"; protected-headers="v1" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: emacs-devel@gnu.org Message-ID: Subject: Re: How does one set up a syntax table for (* and //? References: <18d576b9-fe12-c09a-32f9-ad0da86f2d27@gmail.com> In-Reply-To: --OTd59vGUGJotLeKXdKr4UDarfhWpOPCQJ Content-Type: multipart/mixed; boundary="------------ABDE126075D4834782812FBE" This is a multi-part message in MIME format. --------------ABDE126075D4834782812FBE Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2017-01-12 08:55, Stefan Monnier wrote: >> Is there code that depends on this (a mixing with c)? If not, could we= >> consider changing the semantics of "c" instead? This mixing isn't clea= r from >> the documentation, AFAICT. >=20 > `c` is a fairly recent introduction (introduced for opascal.el, FWIW), > so maybe it's not too late to change its semantics. That would be nice :) In the meantime, I implemented Noam's suggestion in= the attached patch. Cl=E9ment. --------------ABDE126075D4834782812FBE Content-Type: text/x-diff; name="0001-Use-a-syntax-propertize-function-to-properly-handle-.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Use-a-syntax-propertize-function-to-properly-handle-.pa"; filename*1="tch" =46rom 3a9be64827bbed8e34d38803b5c44d8d4f6cd688 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Cl=3DC3=3DA9ment=3D20Pit--Claudel?=3D Date: Thu, 12 Jan 2017 20:26:04 -0500 Subject: [PATCH] Use a syntax-propertize-function to properly handle '(//= ' comments Fixes #42. --- fstar-mode.el | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/fstar-mode.el b/fstar-mode.el index b9d1899..8582f9e 100755 --- a/fstar-mode.el +++ b/fstar-mode.el @@ -423,15 +423,30 @@ If MUST-FIND-TYPE is nil, the :type part is not nec= essary." ;; Comments and strings (modify-syntax-entry ?\\ "\\" table) (modify-syntax-entry ?\" "\"" table) - (modify-syntax-entry ?* ". 23" table) - (modify-syntax-entry ?/ ". 12b" table) - (modify-syntax-entry ?\n "> b" table) - (modify-syntax-entry ?\^m "> b" table) - (modify-syntax-entry ?\( "()1n" table) - (modify-syntax-entry ?\) ")(4n" table) + ;; =E2=80=98/=E2=80=99 is handled by a `syntax-propertize-function'.= For background on this + ;; see http://lists.gnu.org/archive/html/emacs-devel/2017-01/msg0014= 4.html. + ;; The comment enders are left here, since they don't match the =E2=80= =98(*=E2=80=99 openers. + ;; (modify-syntax-entry ?/ ". 12c" table) + (modify-syntax-entry ?\n ">" table) + (modify-syntax-entry ?\^m ">" table) + (modify-syntax-entry ?\( "()1nb" table) + (modify-syntax-entry ?* ". 23b" table) + (modify-syntax-entry ?\) ")(4nb" table) table) "Syntax table for F*.") =20 +(defconst fstar-mode-syntax-propertize-function + (let ((opener-1 (string-to-syntax ". 1")) + (opener-2 (string-to-syntax ". 2"))) + (syntax-propertize-rules + ("//" (0 (let* ((pt (match-beginning 0)) + (state (syntax-ppss pt))) + (goto-char (match-end 0)) ;; syntax-ppss adjusts point + (unless (or (nth 3 state) (nth 4 state)) + (put-text-property pt (+ pt 1) 'syntax-table opener-1)= + (put-text-property (+ pt 1) (+ pt 2) 'syntax-table ope= ner-2) + (ignore (goto-char (point-at-eol)))))))))) + ;;; Mode map =20 (defvar fstar-mode-map @@ -1228,7 +1243,8 @@ into blocks; process it as one large block instead.= " (setq-local comment-continue " *") (setq-local comment-end "*)") (setq-local comment-start-skip "\\(//+\\|(\\*+\\)[ \t]*") - (setq-local font-lock-syntactic-face-function #'fstar-syntactic-face-f= unction)) + (setq-local font-lock-syntactic-face-function #'fstar-syntactic-face-f= unction) + (setq-local syntax-propertize-function fstar-mode-syntax-propertize-fu= nction)) =20 ;;; Main mode =20 --=20 2.7.4 --------------ABDE126075D4834782812FBE-- --OTd59vGUGJotLeKXdKr4UDarfhWpOPCQJ-- --uJ1oTeP2BHgohPvwntUdi1eEhxmntVTC7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYeC5kAAoJEPqg+cTm90wjVqUQALGcD/pRfO9ORFB9pmjgH1e8 myHIQJ159kp+JcOjminGI0TbxVkCH+3XBVRUltIfQaca8KWTYMvMe7WRhd6C4YCK DTQsjBk5rW827cg4bkEvkrDmBaK4zIcFIkZe13MjnfT1uQmJR37D5o1w+/S98LyP a75DNdTxsXH2KPnNFiZcIKUBuNknwswRwd+9pNEU14PSvFg8tTDMs6jQb5uGLqWi 0y9XTcpJuMX+4n/eTlv6DlPm0RMaZMkH3DOoFFlldAJ3XM5fjOAfr2o2I8mySGDF R9tk4uCmCuu1GXFK0GXiHxkhLq2oi35y/K0CVqQFIOziZXO3FBmrclox89smjAii 8Bix2KWLzo0uzUUj1TkdzihYKzN6TPyHBvwt389Q93eSukwCJFrTpBRp747+/1LH t+noHSu6g/zhnh7FmGP4w4JTuiyA9MAS4eQcbQpE/i+YZCxrfO1n2U0J1ukr9NoK zV2Fjwwuk35wNeAkrm3TSOx5kZW3XMyUnZSnq9K2jJduGg6EZjMy1P9r0BIVa7xL QqX0xO8TFcVBaItqSqZk0hpzFJZgmDNj/70mN99nVuKIkF98LY+a6A0zGUgFtZK5 S6S6kgZF6Pv9Lp4U4bH/Eurel3fAX3xQ+QGcmUTR+uqzZihUfOtw4lTPjsHaOqmT P361t1LIut0l5nAlmE4n =1m0c -----END PGP SIGNATURE----- --uJ1oTeP2BHgohPvwntUdi1eEhxmntVTC7--