2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ErlangのindentをEmacsのerlang-modeで整形する簡単スクリプト

Last updated at Posted at 2015-04-08

intelliJ等でErlangを書きたいが、コーディング規約のindentが「Emacsのindentにあわせる」 みたいなパターンの時に使える。
Emacsではコマンドラインよりスクリプトをファイルに適用出来るので、それを利用。

erlang_indent.el
(find-file (nth 0 command-line-args-left)) ; 第一引数に指定されたファイルを開く
(setq override-mode t) ; 上書き前提
(require 'erlang-start) ; erlang-mode
(setq indent-tabs-mode nil) ;;ソフトタブ
(setq c-basic-offset 4) ;; 4タブ
(indent-region (point-min) (point-max)) ; 最初から最後まで整形
(untabify (point-min) (point-max)) ; tab禁止
(fset 'yes-or-no-p 'y-or-n-p) ; 質問をy/n に
(save-buffer) ; SAVE

より、

$ emacs --script ~/.emacs.d/erlang-indent.el $FILE

gitでコミットする時にhookしたりすれば楽かなと思うけど、たまーにとんでもないindentになったりする問題があるので要検証。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?