From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Date: Thu, 19 Nov 2020 17:47:40 -0500 Message-ID: References: <20200923144824.GD6178@ACM> <20200924102022.GA4714@ACM> <20201119211822.GE6259@ACM> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3749"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 43558@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 19 23:48:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfsis-0000sY-VV for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Nov 2020 23:48:14 +0100 Original-Received: from localhost ([::1]:57086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfsir-00057W-O5 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Nov 2020 17:48:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfsig-00056o-Tu for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2020 17:48:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kfsif-00044C-Nk for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2020 17:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kfsif-0002ay-JM for bug-gnu-emacs@gnu.org; Thu, 19 Nov 2020 17:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Nov 2020 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43558 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 43558-submit@debbugs.gnu.org id=B43558.16058260759956 (code B ref 43558); Thu, 19 Nov 2020 22:48:01 +0000 Original-Received: (at 43558) by debbugs.gnu.org; 19 Nov 2020 22:47:55 +0000 Original-Received: from localhost ([127.0.0.1]:41266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kfsiZ-0002aW-Cx for submit@debbugs.gnu.org; Thu, 19 Nov 2020 17:47:55 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kfsiX-0002aJ-EH for 43558@debbugs.gnu.org; Thu, 19 Nov 2020 17:47:54 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id AE7258025A; Thu, 19 Nov 2020 17:47:47 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DC2448005E; Thu, 19 Nov 2020 17:47:41 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1605826061; bh=vIRgrvRsNOdWfj6o/4o8qJ7XYA6P9pDdWkLVSuS4QBQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=V6CiJ1pqPMfzmKUfvU9n11z47cMMZlnkRO/tGayIUCbUG74JxV0RmWvnajRInOfZA LDHkSzDxv1GjQN9DPXqhJEPC0SvmRB2aotUs6ejH8CVhpAbEu1UdQLTCNCemC6daXL bzBF47Xkne6Clorm37rRWRTv5gyyBSWDZQtwmBJUEZpnTBOAl6v7HtqtJDywdhA78P jl8w2ds/R8Fqi96hxHY9Z4ioVKKT+a936yDlI+Kg5JJ1tDGVycJp1Eq90I6i7WJjIy pjlCstTNWGfo3tk1RAKM73eh365DjINWOp+ySVuc39qyc77QW76rK+fVDSvOlVCVeX fGv7d7iKf6/0g== Original-Received: from alfajor (unknown [157.52.9.240]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6DE3A1203D8; Thu, 19 Nov 2020 17:47:41 -0500 (EST) In-Reply-To: <20201119211822.GE6259@ACM> (Alan Mackenzie's message of "Thu, 19 Nov 2020 21:18:22 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193752 Archived-At: >> So, yeah, you can add yet-another-hack on top of the other syntax.c >> hacks if you want, but there's a good chance it will only ever be used >> by CC-mode. It will take a lot more code changes in syntax.c than >> a quick tweak to your Elisp code to search for "\*/". [...] > OK, here's the patch. I think the patch agrees with my assessment above (even though it's still missing a etc/NEWS entry, adjustment to the docstring of modify-syntax-entry and to the .texi manual). I really can't understand why you resist so much the use of a `syntax-table` property on those rare \\\n sequences. Stefan PS: Also, I just noticed that `gcc -Wall` warns about the use of such multiline comments, so it doesn't seem to be a very popular feature. PPS: For reference, I just tried to add support for it in sm-c-mode and this is the resulting code: @@ -312,7 +315,15 @@ E.g. a #define nested within 2 #ifs will be turned into \"# define\"." 'syntax-table (string-to-syntax "|")) (put-text-property (match-beginning 2) (match-end 2) 'syntax-table (string-to-syntax "|"))) - (sm-c--cpp-syntax-propertize end))))) + (sm-c--cpp-syntax-propertize end)))) + ("\\\\\\(\n\\)" + (1 (let ((ppss (save-excursion (syntax-ppss (match-beginning 0))))) + (when (and (nth 4 ppss) ;Within a comment + (null (nth 7 ppss)) ;Within a // comment + (save-excursion ;The \ is not itself escaped + (goto-char (match-beginning 0)) + (zerop (mod (skip-chars-backward "\\\\") 2)))) + (string-to-syntax ".")))))) (point) end)) (defun sm-c-syntactic-face-function (ppss)