[erlang-questions] erlang emacs mode question

Martin Bjorklund mbj@REDACTED
Thu Dec 17 21:15:52 CET 2009


Hi,

Joe Armstrong <erlang@REDACTED> wrote:
> What I'd like is "org mode erlang editing"
> 
> hit tab on the first line of a function definition hides or reveals
> the body of the function.
> hit meta-uparrow on the first line of a function move the function up
> in the file.

You can configure outline mode to do this, sort of.  Put this in
.emacs.  Instead of <tab> as you suggested, use C-left / C-right.

This way it shows / hides each function clause as a separate item, but
you probably want to treat the complete function as one entity.  I'm
sure it is doable...


(defun show-onelevel ()
  "show entry and children in outline mode"
  (interactive)
  (show-entry)
  (show-children))

(defun my-outline-bindings ()
  "sets shortcut bindings for outline minor mode"
  (interactive)
  (local-set-key [C-up] 'outline-previous-visible-heading)
  (local-set-key [C-down] 'outline-next-visible-heading)
  (local-set-key [C-left] 'hide-subtree)
  (local-set-key [C-right] 'show-onelevel))

(add-hook
 'outline-minor-mode-hook
 'my-outline-bindings) 

(add-hook
 'erlang-mode-hook
 '(lambda ()
    (outline-minor-mode)
    (setq outline-regexp 
	  (concat "^-?" erlang-atom-regexp "\\s *("))))

[ref: http://www.emacswiki.org/emacs/EasyCodeOutline]



/martin


More information about the erlang-questions mailing list