首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sml模式为emacs做了非常奇怪的事情。有没有其他的解决办法,或者简单的解决办法?

sml模式为emacs做了非常奇怪的事情。有没有其他的解决办法,或者简单的解决办法?
EN

Stack Overflow用户
提问于 2014-06-02 08:42:40
回答 1查看 328关注 0票数 1

我很难在Emacs中找到sml-mode来正确地缩进我的代码。例如,这里有一个街区,它的行为特别奇怪:

代码语言:javascript
复制
    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

对于巨大的代码转储表示歉意,但是内容并不重要--只是非常不一致的缩进。试图在structure Foo : sig ... end = struct ... end块中定义签名甚至更糟:

代码语言:javascript
复制
structure Attrs : sig
              type t
              datatype node
                = Attributes of string list
                                       include WRAPPED
                                       sharing type node' = node
                                                                sharing type obj = t
          end

或者:

代码语言:javascript
复制
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

我是一个顽固的Emacs的球迷,我不想在这个项目中避免它,因为这是我将在未来几个月的工作。但是,我不能把这样的代码交给我的主管。以上是当我选择一个文本块和indent-region时所得到的行为。

我看过this answer,但是解决方案不适用,因为这是M-C-\给我的行为,如果不能够自动缩进整个文件,那么在代码上工作将是一件非常痛苦的事情。

有什么简单的办法吗?是否有替代的sml-mode实现?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-02 10:35:20

假设您正在使用来自GNU ELPA的SML模式的最新版本,看起来您已经碰到了SML模式内置SMIE语法崩溃的拐角。我对OCaml的Tuareg模式也有类似的问题。

您可能需要将SML模式的版本降级为4.0或更低版本,这可以从http://www.iro.umontreal.ca/~monnier/elisp/获得。这些版本还没有使用SMIE进行缩进,而是使用一些特殊的缩进代码.至少对于OCaml和Tuareg来说,我发现这种老式的方法可以产生更好、更可靠的缩进。

不过,您可能希望向SML模式的维护者报告此问题,SML模式的邮件地址可以在SML模式的页眉或上述网站的页脚中找到。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23990487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档