Refactoring Erlang

Posted: May 25th, 2008 | Author: kevin | Filed under: Erlang | View Comments

I’ve been playing around a bit with Wrangler—an Erlang refactoring package for Emacs. I like what I’ve seen of it so far but turning it on and off is a little ugly. Typing M-x erlang-refactor-on and M-x erlang-refactor-off gets tiresome after the third time.

So I whipped up a function to toggle Wrangler on and off:

(setq erlang-refactor-status 0)
(defun toggle-erlang-refactor ()
  (interactive)
  (cond ((= erlang-refactor-status 0)
	 (call-interactively 'erlang-refactor-on)
	 (setq erlang-refactor-status 1))
	((= erlang-refactor-status 1)
	 (call-interactively 'erlang-refactor-off)
	 (setq erlang-refactor-status 0))))

I dropped this into distel_config.el and bound it to C-c C-r like so:

(global-set-key (kbd "C-c C-r") 'toggle-erlang-refactor)

Voila! Instant refactor mode toggle with two keystrokes.


  • No problem at all -- I'm happy to see it included.
  • Thanks very much for this. We'll include in Wrangler if that's OK with you.

    Regards

    Simon
blog comments powered by Disqus