4

Emacs supports syntax flags for 1- and 2-characters comment delimiters. Can it be made to recognize and properly highlight 3-characters delimiters?

For example:

In Emacs Lisp:
    ;;; Headings

In C#:
    /// XML Comment

In Java:
    /** Javadoc comment */

In Coq:
    (** Codoc comment (nestable with (* ... *) and (** ... *)) *)
10

AFAIK the example you give are actually 2-char comment delimiters, except that depending on the 3rd character, these comments are treated in different ways (but always as comments in the sense that the semantics of the code is unaffected).

So, the support offered by Emacs's syntax tables should be sufficient in most cirsumstances. If you want to highlight them differently, you can use font-lock-syntactic-face-function so as to return different faces for those different comments (typically by looking at the chracters after (nth 8 state) to recognize which kind of element is being processed).

2

Take a look at the docs for syntax-propertize-function also. That's used for scanning a buffer and applying syntax categories programmatically, rather than using the syntax table.

This Stack Overflow answer has a couple examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.