如何在Emacs中以F90模式获得正确的自动续行?
假设我在F90模式下编写了一些(自由格式)Fortran代码,如何在键入时获得正确的自动续行,以及如何在使用如何在Emacs中以F90模式获得正确的自动续行?,emacs,fortran,fortran90,Emacs,Fortran,Fortran90,假设我在F90模式下编写了一些(自由格式)Fortran代码,如何在键入时获得正确的自动续行,以及如何在使用填充段落时获得正确的续行 代码示例: subroutine procedure_with_many_arguments(argument1, argument2, argument3, argument4, argument5, argument6, argument7) real :: argument1, argument2, argument3, argument4, argum
填充段落时获得正确的续行
代码示例:
subroutine procedure_with_many_arguments(argument1, argument2, argument3, argument4, argument5, argument6, argument7)
real :: argument1, argument2, argument3, argument4, argument5, argument6, argument7
end subroutine
1。当使用自动填充模式键入此代码时,我在两行上都得到了连续字符&
,还有一些奇怪的固定格式,如缩进(此处输入第二和第三条语句):
2。在已经存在的、太宽的代码上使用填充段落时,我既没有得到任何连续字符&
,也没有任何缩进:
subroutine procedure_with_many_arguments(argument1, argument2, argument3,
argument4, argument5, argument6, argument7)
real :: argument1, argument2, argument3, argument4, argument5, argument6,
argument7
end subroutine
预期结果:
subroutine procedure_with_many_arguments(argument1, argument2, &
argument4, argument5, argument6, argument7)
real :: argument1, argument2, argument3, argument4, argument5, &
argument6, argument7)
end subroutine
在这里回答我的问题:
1。要删除前导的“与”,请在.emacs
文件中添加以下行:
(setq f90-mode-hook
'(lambda () (setq f90-beginning-ampersand nil)))
2。要打断已存在代码的过宽行,请使用f90填充区域
,而不是填充段落
请注意,f90 fill region
命令在注释行(已测试版本24.5.1和25.3.1)上使用时会使Emacs崩溃,fill段落
命令对它们不起任何作用。似乎没有适用于代码行和注释行的填充命令
更新:自由格式Fortran主模式f90.el的维护者刚刚向GitHub添加了一个函数f90填充段落
。这个命令同时适用于注释行和代码。如果25年前存在堆栈溢出怎么办?是的,我真的不知道如何处理该注释…在两行上都有延续标记并没有错,只是没有太多人喜欢。@Michael我不知道你的意思,但问题是关于25年前引入的源表单。即使在当前的Fortran 2015中,它仍然有效。我可以确认这一点。。额外的“与”符号可能看起来是在试图制造混合的固定-自由兼容代码,但这也不正确,因为第一个符号需要被推过第72列。
(setq f90-mode-hook
'(lambda () (setq f90-beginning-ampersand nil)))