“如果”的缩进在Emacs下的Ocaml [英] Indentation of "if" in Ocaml under Emacs

查看:257
本文介绍了“如果”的缩进在Emacs下的Ocaml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Emacs编写Ocaml,如果的缩进设置为,那么

  if cond1 then e1 else 
if cond2 then e2 else
if cond3 then e3 else
e4

我想实现与 Caml编程指南

  if cond1 then e1 else 
如果cond2然后e2 else
如果cond3然后e3 else
e4

可以任何人告诉我哪个参数与之相关?谢谢



Edit1:这里是我的。emacs

解决方案

似乎有些错误。您是否使用OCaml发行版的caml模式?因为我根据编程指南而缩小它,而不需要设置任何参数。这是我在我的 .emacs (模式安装在〜/ .emacs.d / caml-mode ):

  ;; Caml模式
(setq load-path(cons〜/ .emacs.d / caml-modeload-path))
(setq auto-mode-alist(cons'(\\ 。$ [

(autoload'caml-modecaml编辑Caml代码的主要模式)t
(自动加载'运行Caml调试器t)
(如果window-system(require' caml-font))

如果您使用tuareg模式,我无法帮助您。然而,请注意,与普遍的观点相反,OCaml的作者仍然保留来自分发的caml模式。


I am coding Ocaml with Emacs, at the moment the setting of the indentation of if gives the following:

if cond1 then e1 else
  if cond2 then e2 else
    if cond3 then e3 else
      e4

I would like to realize the same format as Caml programming guidelines:

if cond1 then e1 else
if cond2 then e2 else
if cond3 then e3 else
e4

Could anyone tell me which parameter is related to that? Thank you

Edit1: here is my .emacs

解决方案

Something seems to be wrong. Are you using the caml-mode from the OCaml distribution ? Because I do and it indents according to the programming guidelines without setting any parameter. That's what I have in my .emacs (the mode is installed in ~/.emacs.d/caml-mode):

;; Caml mode
(setq load-path (cons "~/.emacs.d/caml-mode" load-path))
(setq auto-mode-alist (cons '("\\.ml[iylp]?" . caml-mode) auto-mode-alist))
(autoload 'caml-mode "caml" "Major mode for editing Caml code." t)
(autoload 'run-caml "inf-caml" "Run an inferior Caml process." t)
(autoload 'camldebug "camldebug" "Run the Caml debugger." t)
(if window-system (require 'caml-font))

If you are using tuareg-mode I cannot help you. Note however that, contrary to popular belief, the caml-mode from the distribution is perfectly fine and is still maintained by OCaml's authors.

这篇关于“如果”的缩进在Emacs下的Ocaml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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