2

So, for a lisp homework assignment I have, it has a long defparameter expression that's a large data set. What I'm wondering is, does emacs or SLIME have anything to "collapse" that large defparameter into a single line, like, say, MATLAB does?

T. Smit
  • 129
  • 3

2 Answers2

3

Like Bertfred mentioned, hideshow works great, and it comes build in with more recent versions of emacs. To use it simply add the following snippet to your init file:

(add-hook 'prog-mode-hook #'hs-minor-mode)
(global-set-key (kbd "C-c <right>") 'hs-show-block)
(global-set-key (kbd "C-c <left>") 'hs-hide-block)

The first line enables the functionality in any major mode associated with programming. Once there, C-c <left> and C-c <right> should do what you expect - just be mindful of where point is.

https://www.emacswiki.org/emacs/HideShow

AesopHimself
  • 301
  • 2
  • 5
1

There's also a package on Melpa called vimish-fold (or the equivalent evil version of it - evil-vimish-fold).

It is not as "automatic" as hideshow or outline in the sense that you have to select the lines you want to fold, but the advantage is that you can fold any lines. And the folds don't disappear the when you close your file.

You can define your keybindings for creating/deleting folds and for unfolding/refolding folds, and there you go!

(global-set-key (kbd "your-keybinding") 'vimish-fold)
(global-set-key (kbd "your-keybinding") 'vimish-fold-delete)
(global-set-key (kbd "your-keybinding") 'vimish-fold-toggle)
RatonWasher
  • 250
  • 3
  • 9