emacs的sml模式做了非常奇怪的事情。是否有替代方案或简单的elisp修复方案?
要让Emacs中的sml模式合理地缩进代码,我遇到了很多麻烦。例如,下面是一个行为异常的块:emacs的sml模式做了非常奇怪的事情。是否有替代方案或简单的elisp修复方案?,emacs,formatting,indentation,sml,Emacs,Formatting,Indentation,Sml,要让Emacs中的sml模式合理地缩进代码,我遇到了很多麻烦。例如,下面是一个行为异常的块: datatype type_node = Param of TyParam.t | LongId of LongId.t | Offset of field * field list option | List of type_t list | Fun of type_t list * t list | Any
datatype type_node
= Param of TyParam.t
| LongId of LongId.t
| Offset of field * field list option
| List of type_t list
| Fun of type_t list * t list
| Any
| VProc
| Cont of TyArg.t list option
| Addr of type_t
and dataconsdef_node
= ConsDef of BomId.t * type_t option
and field_node
= Immutable of int * type_t
| Mutable of int * type_t
and fundef_node
= Def of Attrs.t option * BomId.t * TyParam.t list option
* Param.t list option * Param.t list option * type_t * exp_t
and varpat_node
= Wild
| Var of BomId.t * type_t option
and caserule_node
= LongRule of LongId.t * varpat_t list * exp_t
| LiteralRule Literal.t * exp_t
| DefaultRule of varpat_t * exp_t
and tycaserule_node
= TyRule of type_t * exp_t
| Default of exp_t
and simpleexp_node
= PrimOp of 'var Prim.prim * simpleexp_t list
| AllocId of LongId.t * simpleexp_t list
| AllocType of Type.t * simpleexp_t list
| AtIndex of int * simpleexp_t * simpleexp_t option
| TypeCast of Type.t * simpleexp_t
| HostVproc
| VpLoad of int * simpleexp_t
| VpAddr of int * simpleexp_t
| VpStore of int * simpleexp_t * t
| Id of LongId.t
| Lit of Literal.t
| MLString of string
and exp_node
= Let of VarPat.t list * rhs * t
| Do of SimpleExp.t * t
| Fun of FunDef.t list * t
| Cont of BomId.t * Param.t list option * t * t
| If of SimpleExp.t * t * t
| Case of SimpleExp.t * CaseRule.t list
| Typecase of TyParam.t * TyCaseRule.t list
| Apply of LongId.t * SimpleExp.t list option * SimpleExp.t list option
| Throw of LongId.t * SimpleExp.t list option
| Return of SimpleExp.t list option
and foo_node
= bar
为巨大的代码转储表示歉意,但内容并不重要——只是极不一致的缩进。正在尝试在结构Foo:sig内定义签名。。。结束=结构。。。端块更糟糕:
structure Attrs : sig
type t
datatype node
= Attributes of string list
include WRAPPED
sharing type node' = node
sharing type obj = t
end
或:
我是Emacs的铁杆粉丝,我不想在这个项目上避免它,因为这是我接下来几个月要做的事情。然而,我不能把这样的代码交给我的主管。上面是我在选择文本块和缩进区域时得到的行为
我已经看过了,但是解决方案不适用,因为这是M-C-\给我的行为,如果在不能够自动缩进整个文件的情况下处理代码,那将是一个巨大的痛苦
有没有简单的解决办法?是否有其他sml模式实现 假设您使用的是GNU ELPA最新版本的SML模式,看起来您遇到了一个转折点,SML模式的内置SMIE语法出现了故障。我对OCaml的Tuareg模式也有类似的问题 您可能需要将SML模式的版本降级到4.0或更低版本,这可以从中获得。这些版本还没有使用SMIE进行缩进,而是使用一些特殊的缩进代码。至少对于OCaml和Tuareg,我发现这种老式方法可以产生更好、更可靠的缩进
但是,您可能希望向SML模式的维护人员报告此问题,您可以在SML模式的页眉或上述网站的页脚中找到其邮件地址。看起来像是一个bug。请报告给我。@Stefan你想在错误报告中得到什么信息,我应该把它发送到哪里?只是开玩笑而已。你引用的代码就是我所需要的。[解析SML的函子sigs是一件让人头疼的事。]太棒了,谢谢你的回复。但是如果你给我发电子邮件,我可以给你发补丁进行测试。谢谢你对SMIE的赞扬;-我不知道是否有单独的Tuareg SMIE和Ocaml SMIE支持,因此您的不良体验仅限于一个案例,大概是Tuareg的SMIE代码。这一案例与Tuareg的手动缩进进行了比较,Tuareg的手动缩进已经调整了很多年。所以这不太公平。请用TuaReg的SMIE代码报告你所看到的问题,这样我们就可以把它提高到标准。我的意思是没有冒犯,但我不在乎我是否公平。虽然我喜欢SMIE,但事实是,图阿雷格的旧缩进代码可以工作,而SMIE在许多情况下会中断。我确实向Tuaregs Github tracker报告了其中一些问题,但没有任何反应,因此我失去了兴趣,转而在Tuaregs中禁用了SMIE。
functor DoWrap(type node) : sig
type t = node Wrap.t
include WRAPPED
sharing type node' = node
sharing type obj = t
end = struct
open Wrap
type t = node Wrap.t
type node' = node
type obj = t
end