Stefan Monnier writes: >> Investigating how to fix this leads to the longer story. There are two >> possible approaches: >> >> 1) use a string-style syntax (generic string) instead of c-style >> comments to flag HERE-documents. That way, font-lock picks up the >> correct face automagically. >> >> 2) Keep HERE_docs as c-style comments, but change the face mapping by >> injecting a function into font-lock-defaults which applies the >> string face to c-style comments. > > 3) Use `font-lock-syntactic-face-function`? Ah - thanks for this pointer! I wasn't aware of this function, though this feature is already in use in perl-mode.el. This looks like to be an improved variation of 2): HERE-docs remain marked as c-style comments, and `font-lock-syntactic-face-function` is used to display them as strings. A patch for this variation is attached. Tests and test resources are the same as with the first patch, and this patch also contains the same fix for HERE-doc starters with a trailing comment. -- Cheers, haj