unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How does one set up a syntax table for (* and //?
@ 2017-01-11 15:44 Clément Pit--Claudel
  2017-01-12  1:19 ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Clément Pit--Claudel @ 2017-01-11 15:44 UTC (permalink / raw)
  To: Emacs developers

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-13  1:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-11 15:44 How does one set up a syntax table for (* and //? Clément Pit--Claudel
2017-01-12  1:19 ` 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

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