unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: modify-syntax-entry with single and two character comments
Date: Wed, 27 Oct 2004 19:11:26 GMT	[thread overview]
Message-ID: <jwvoeioc8hk.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: 10nvo8bjdmul85@corp.supernews.com

>      (modify-syntax-entry ?\n ">" st)
>      (modify-syntax-entry ?\| "<1b4b" st)
>      (modify-syntax-entry ?\* ".2b3b" st)

The syntax string has the following structure:
- 1st char is the main syntax category.
- 2nd char is only used for ( and ) categories.
- the rest are flags with no ordering.

I.e. in your above code the "<1b4b" is equivalent to "< b4b" because the
`1' is ignored.  It's also equivalent to "< 4bb" (because ordering of
flags is ignored) which is equivalent to "< 4b" (because turning ON a flag
twice is the same as turning it ON once).

A correct syntax-table would be:

      (modify-syntax-entry ?\n ">" st)
      (modify-syntax-entry ?\| "< 14" st)
      (modify-syntax-entry ?\* ". 23b" st)

which says:
- | starts a non-b comment and \n ends such a non-b comment.
- | can be the 1nd char of a 2-char comment-starter or the 2nd char of
  a 2-char comment-ender.
- * can be the 2nd char of a 2-char b-style comment-starter or the 3rd char
  of a 2-char b-style comment-ender.

Sadly, this will not work because current Emacsen will immediately think
that | starts the comment without checking the subsequent char to see if
it's a *.

Please report a bug via M-x report-emacs-bug about it.

To work around this problem, two solutions:

1 - use "| " instead of "|" as the non-b comment-starter:

      (modify-syntax-entry ?\n ">" st)
      (modify-syntax-entry ?\| ". 14" st)
      (modify-syntax-entry ?\* ". 23b" st)
      (modify-syntax-entry ?\  "  2" st)

    Any char that can reasonably be expected to appear after a |
    comment-starter should then have the `2' flag added to its syntax :-(

2 - use font-lock-syntactic-keywords to change the syntax of | when it is
    followed by a *.  This is less intrusive but will only work when
    font-lock is used and has been applied to the text.


-- Stefan

  reply	other threads:[~2004-10-27 19:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-27 17:55 modify-syntax-entry with single and two character comments Spike Ilacqua
2004-10-27 19:11 ` Stefan Monnier [this message]
2004-10-27 20:16   ` Stefan Monnier

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=jwvoeioc8hk.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=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.
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).