Created
October 25, 2012 17:54
-
-
Save andrzejsliwa/3954316 to your computer and use it in GitHub Desktop.
erlang emacs-style formatting for vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
emacs --batch --eval " | |
(progn (find-file \"$1\") | |
(if (string-equal \"darwin\" (symbol-name system-type)) | |
(setq erlang-root-dir (car (file-expand-wildcards \"/usr/local/Cellar/erlang/R*\"))) | |
(setq erlang-root-dir \"/usr/lib/erlang/\")) | |
(setq load-path (cons (car (file-expand-wildcards (concat erlang-root-dir \"/lib/erlang/lib/tools-*/emacs\"))) load-path)) | |
(require 'erlang-start) | |
(erlang-mode) | |
(untabify (point-min) (point-max)) | |
(delete-trailing-whitespace) | |
(erlang-indent-current-buffer) | |
(save-buffer) | |
(save-buffers-kill-emacs))" > /dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:emacs_indenter = expand('<sfile>:p:h') . '/emacs_indent.sh' | |
function! IndentErlangWithEmacs() | |
exec ':w' | |
silent! exec '!' . s:emacs_indenter . ' ' . expand('%:p') | |
exec ':e ' . expand('%:p') | |
redraw! | |
endfunction | |
command! IndentErl call IndentErlangWithEmacs() | |
silent! nmap <silent> <Leader>f :IndentErl<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment