I am looking to add an additional single line style of comments !* to the Fortran mode on emacs, I'd add this to my init.el file.
From what I can see this should be doable using the modify-syntax-entry
command, but I am struggling to succeed and there doesn't seem to be a fortran-mode-syntax-table
so I can't see how I'd hook it to the mode.
My current effort (which causes an error).
(modify-syntax-entry ?\!\* "< \n")
(modify-syntax-entry ?\n "< \!\*")
The error reads An error occurred while loading 'init.el':
Invalid read syntax: ?
I finally figured out how to do this, and it's worth mentioning that with a normal Fortran setup ! causes comments, but not in mine.
So what I add to my init.el is
(add-hook 'fortran-mode-hook
(lambda ()
(modify-syntax-entry ?\! ". 1")
(modify-syntax-entry ?\* ". 2")
(modify-syntax-entry ?\n ">") ))
The first two modify-syntax-entry use the numeric syntax flags for a two character comment start sequence !* and > is the syntax class for comment ended, for which I have used \n to end the comment with a newline.
See https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Flags.html and https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html#Syntax-Class-Table for more details