From: "Clément Pit--Claudel" <clement.pit@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: How does one set up a syntax table for (* and //?
Date: Wed, 11 Jan 2017 10:44:04 -0500 [thread overview]
Message-ID: <d54d1cbb-8809-8c83-215e-43971d8f6107@gmail.com> (raw)
Hi Emacs devel,
As far as I can tell from the docs, the following syntax table should recognize // … line comments and nestable (* … *) comments properly:
(defvar example-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?/ ". 12c" table)
(modify-syntax-entry ?\n "> c" table)
(modify-syntax-entry ?\( "()1n" table)
(modify-syntax-entry ?\) ")(4n" table)
table))
Yet it does not:
(with-current-buffer (get-buffer-create "test")
(erase-buffer)
(prog-mode)
(set-syntax-table example-syntax-table)
(insert "// line comment\n")
(insert "regular text\n")
(insert "(* nested (* comments *) *)\n")
(insert "regular text\n")
(insert "(// another line comment,\nwhich incorrectly extends past the newline?\n")
(pop-to-buffer (current-buffer)))
In this example, the last line (“which incorrectly extends past the newline?”), is considered to be a comment, because the sequence "(/" is treated as a multiline comment opener.
How can I work around this? Did I miss something in the manual?
Thanks!
Clément.
next reply other threads:[~2017-01-11 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 15:44 Clément Pit--Claudel [this message]
2017-01-12 1:19 ` How does one set up a syntax table for (* and //? Noam Postavsky
2017-01-12 1:31 ` Clément Pit--Claudel
2017-01-12 13:55 ` Stefan Monnier
2017-01-13 1:33 ` Clément Pit--Claudel
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d54d1cbb-8809-8c83-215e-43971d8f6107@gmail.com \
--to=clement.pit@gmail.com \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.