Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outline or fold mode for editing Emacs Lisp code

Is there a minor mode that I can use in combination with Emacs-Lisp mode such that each function definition can be switched on or off easily without inserting special code in the text file?

for instance

(defun test1()
  (message "Hi!"))

(defun test2()
  (message "Bye"))

Pressing F1 will fold each function definition into the top line/header as

+ (defun test1()
+ (defun test2()

Pressing the + sign in front will unfold a given function and make it editable.. Pressing F2 will unfold all definitions..

like image 374
Håkon Hægland Avatar asked Jan 14 '14 15:01

Håkon Hægland


3 Answers

Here's my setup:

(require 'hideshow)
(global-set-key (kbd "C-M-h") 'hs-toggle-hiding)
(global-set-key (kbd "<f2> h h") 'hs-hide-all)
(global-set-key (kbd "<f2> h j") 'hs-show-all)
like image 65
abo-abo Avatar answered Sep 28 '22 10:09

abo-abo


outline-minor-mode does that. Look into its menu. Instead of the +-sign you get the typical ellipsis .... That should not hurt. You can do the key-bindings for yourself. (I know that you are clever enough!)

like image 24
Tobias Avatar answered Sep 28 '22 08:09

Tobias


outshine is a variation of outline-minor-mode that lets you use org-mode syntax, which is more powerful than the ordinary outline-mode.

like image 44
Peter Westlake Avatar answered Sep 28 '22 09:09

Peter Westlake