unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 24767@debbugs.gnu.org
Subject: bug#24767: jgraph comments not recognized any more
Date: Sat, 29 Oct 2016 11:02:29 +0000	[thread overview]
Message-ID: <20161029110228.GA5696@acm.fritz.box> (raw)
In-Reply-To: <jwva8dsbktv.fsf-monnier+emacsbugs@gnu.org>

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).





  reply	other threads:[~2016-10-29 11:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-22 21:24 bug#24767: jgraph comments not recognized any more Stefan Monnier
2016-10-23  6:17 ` Eli Zaretskii
2016-10-23 15:34   ` Alan Mackenzie
2016-10-24 19:34 ` Alan Mackenzie
2016-10-25 13:52   ` Stefan Monnier
2016-10-29 11:02     ` Alan Mackenzie [this message]
2016-10-29 15:12       ` Stefan Monnier
2016-10-30 17:37         ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161029110228.GA5696@acm.fritz.box \
    --to=acm@muc.de \
    --cc=24767@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).