regexemacssyntaxpreprocessormajor-mode

Emacs Adding Preprocessor to Major Mode


I am trying to modify the fortran major mode to work with a preprocessor a colleague wrote. The preprocessor directives are all prefixed by a "."

for example:

.set

.macro

function similar to C's #define

This far, I have:

(font-lock-add-keywords 'fortran-mode
 '(("\\<\\(set\\|macro\\|endmacro\\)\\>" . font-lock-preprocessor-face)))

Unfortunately, This does not highlight the "." which is desirable. Also, the pattern should only match if it appears at the start of the line. I've tried:

(font-lock-add-keywords 'fortran-mode
 '(("\\<\\(^\.set\\|^\.macro\\|^\.endmacro\\)\\>" . font-lock-preprocessor-face)))

but that didn't work.

Any help on how to make this regex match would be greatly appreciated.


Solution

  • try this: "^\\s-*\\.\\(set\\|macro\\|endmacro\\)\\>"