如何将注释样式添加到emacs模式 [英] How to add a comment style to an emacs mode

查看:227
本文介绍了如何将注释样式添加到emacs模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在emacs上添加额外的单行风格的评论!*到Fortran模式,我将其添加到我的init.el文件。

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.

从我可以看到这应该是可以使用 modify-syntax-entry 命令,但我正在努力取得成功,似乎没有一个 fortran-mode-syntax-table 所以我看不到我如何挂钩到这个模式。

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 "< \!\*")

错误读取加载'init.el'时发生错误:
无效的读取语法:?

推荐答案

我终于明白了如何做到这一点,值得一提的是,使用正常的Fortran设置!导致评论,但不在我的。

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.

所以我添加到我的init.el是

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 ">") ))

前两个modify-syntax-entry使用两个字符注释开始序列的数字语法标志!*和>是我已经使用的注释结束的语法类\\\
以结尾的换行符。

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.

请参阅 https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Flags.html https://www.gnu.org/software/emacs/manual/html_node/elisp/ Syntax-Class-Table.html#Syntax-Class-Table 了解更多详情

这篇关于如何将注释样式添加到emacs模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆