emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How does one set up a syntax table for (* and //?


From: Clément Pit--Claudel
Subject: How does one set up a syntax table for (* and //?
Date: Wed, 11 Jan 2017 10:44:04 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]