Skip to content

Instantly share code, notes, and snippets.

@AeroNotix
Created May 14, 2014 18:40
Show Gist options
  • Save AeroNotix/ff3ad7d142896695bba8 to your computer and use it in GitHub Desktop.
Save AeroNotix/ff3ad7d142896695bba8 to your computer and use it in GitHub Desktop.
(defun trim-string (string)
(replace-regexp-in-string
"\\`[ \t\n]*" ""
(replace-regexp-in-string "[ \t\n]*\\'" "" string)))
(defun move-to-export ()
(search-backward "-export"))
(defun go-to-export-end ()
(search-forward "])."))
(defun split-erlang-exports ()
(interactive)
(save-excursion
(if (not (looking-at "-export"))
(move-to-export))
(forward-char (length "-export(["))
(push-mark)
(if (not (looking-at "])"))
(progn
(go-to-export-end)
(backward-char 3)))
(let* ((selection
(buffer-substring-no-properties (region-beginning) (region-end)))
(exports (split-string selection ",")))
(move-to-export)
(push-mark)
(go-to-export-end)
(kill-region (region-beginning) (region-end))
(dolist (e exports)
(let ((s (format "-export([%s]).\n" (trim-string e))))
(insert s))))))
-export([start_vnode/1,
init/1,
terminate/2,
handle_command/3,
is_empty/1,
delete/1,
handle_handoff_command/3,
handoff_starting/2,
handoff_cancelled/1,
handoff_finished/2,
handle_handoff_data/2,
encode_handoff_item/2,
handle_coverage/4,
handle_exit/3]).
%% TO =>
-export([start_vnode/1]).
-export([init/1]).
-export([terminate/2]).
-export([handle_command/3]).
-export([is_empty/1]).
-export([delete/1]).
-export([handle_handoff_command/3]).
-export([handoff_starting/2]).
-export([handoff_cancelled/1]).
-export([handoff_finished/2]).
-export([handle_handoff_data/2]).
-export([encode_handoff_item/2]).
-export([handle_coverage/4]).
-export([handle_exit/3]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment