From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#24767: jgraph comments not recognized any more Date: Sat, 29 Oct 2016 11:02:29 +0000 Message-ID: <20161029110228.GA5696@acm.fritz.box> References: <20161024193451.GA4544@acm.fritz.box> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1477738999 17826 195.159.176.226 (29 Oct 2016 11:03:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 29 Oct 2016 11:03:19 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: 24767@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 29 13:03:13 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1c0RPt-0003wH-4P for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Oct 2016 13:03:13 +0200 Original-Received: from localhost ([::1]:54008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0RPv-0000kw-Gi for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Oct 2016 07:03:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0RPn-0000kq-GT for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 07:03:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0RPi-0005gc-JR for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 07:03:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c0RPi-0005gX-Fb for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 07:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c0RPi-0000oQ-1c for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 07:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Oct 2016 11:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24767 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24767-submit@debbugs.gnu.org id=B24767.14777389753064 (code B ref 24767); Sat, 29 Oct 2016 11:03:01 +0000 Original-Received: (at 24767) by debbugs.gnu.org; 29 Oct 2016 11:02:55 +0000 Original-Received: from localhost ([127.0.0.1]:35854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0RPa-0000nK-TQ for submit@debbugs.gnu.org; Sat, 29 Oct 2016 07:02:55 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:52026) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0RPZ-0000mt-KW for 24767@debbugs.gnu.org; Sat, 29 Oct 2016 07:02:54 -0400 Original-Received: (qmail 40749 invoked by uid 3782); 29 Oct 2016 11:02:52 -0000 Original-Received: from acm.muc.de (p4FC46D25.dip0.t-ipconnect.de [79.196.109.37]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 29 Oct 2016 13:02:51 +0200 Original-Received: (qmail 5767 invoked by uid 1000); 29 Oct 2016 11:02:29 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:125105 Archived-At: Hello, Stefan. On Tue, Oct 25, 2016 at 09:52:28AM -0400, Stefan Monnier wrote: > > Suppose the jgraph buffer contains: > > > > he(*llo*) > > > > . Is this supposed to analyse as the symbol "he" followed by a comment, > > or should it be the symbol "he(*llo*)"? > Good question. To the extent that src/syntax.c shouldn't be specific to > jgraph-mode, the answer shouldn't depend on the choice made by > Jgraph's author. > > Currently, even Emacs-25 doesn't recognise the "(*llo*)" as a comment. > I think it's good enough to preserve backward compatibility, then. > > It seems to me more likely that the comment should be recognised, but > > I don't know jgraph. > To choose which of the two behavior is desired, the major mode author > can use syntax-propertize to catch this rare corner case anyway. > > Maybe the solution (in master) would be to add the checking of the > > comment flags into this subsidiary loop. > Let's not worry about it. In the end, that's what I've done. The fix was less tricky than I thought it would be. It recognises the comment in he(*llo*). Would you try out the following patch, please, and let me know whether there are still problems with it. Thanks. diff --git a/src/syntax.c b/src/syntax.c index 667de40..d463f7e 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -3124,6 +3124,7 @@ scan_sexps_forward (struct lisp_parse_state *state, ptrdiff_t prev_from; /* Keep one character before FROM. */ ptrdiff_t prev_from_byte; int prev_from_syntax, prev_prev_from_syntax; + int syntax; bool boundary_stop = commentstop == -1; bool nofence; bool found; @@ -3191,8 +3192,6 @@ do { prev_from = from; \ while (from < end) { - int syntax; - if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) && (c1 = FETCH_CHAR (from_byte), syntax = SYNTAX_WITH_FLAGS (c1), @@ -3258,7 +3257,24 @@ do { prev_from = from; \ while (from < end) { int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte); - switch (SYNTAX (symchar)) + + if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) + && (syntax = SYNTAX_WITH_FLAGS (symchar), + SYNTAX_FLAGS_COMSTART_SECOND (syntax))) + { + state->comstyle + = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); + comnested = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) + | SYNTAX_FLAGS_COMMENT_NESTED (syntax)); + state->incomment = comnested ? 1 : -1; + state->comstr_start = prev_from; + INC_FROM; + prev_from_syntax = Smax; + code = Scomment; + goto atcomment; + } + + switch (SYNTAX (symchar)) { case Scharquote: case Sescape: @@ -3280,6 +3296,7 @@ do { prev_from = from; \ case Scomment_fence: /* Can't happen because it's handled above. */ case Scomment: + atcomment: if (commentstop || boundary_stop) goto done; startincomment: /* The (from == BEGV) test was to enter the loop in the middle so > Stefan -- Alan Mackenzie (Nuremberg, Germany).