greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
681 stars 93 forks source link

Folding a function definition #286

Closed pmatos closed 6 years ago

pmatos commented 7 years ago

As far as I understand, there's no way to currently fold a function definition / s-exp. Can we add that to a wishlist please?

greghendershott commented 7 years ago

Although it's not at all obvious, you can already do this using hideshow mode which racket-mode already enables to use to fold tests. As a result, these commands should already work for you (copied from hideshow.el):

;; * Commands provided
;;
;; This file provides Hideshow Minor Mode.  When active, nine commands
;; are available, implementing block hiding and showing.  They (and their
;; keybindings) are:
;;
;;   hs-hide-block                      C-c @ C-h
;;   hs-show-block                      C-c @ C-s
;;   hs-hide-all                        C-c @ C-M-h
;;   hs-show-all                        C-c @ C-M-s
;;   hs-hide-level                      C-c @ C-l
;;   hs-toggle-hiding                   C-c @ C-c
;;   hs-mouse-toggle-hiding             [(shift mouse-2)]
;;   hs-hide-initial-comment-block
;;
;; Blocks are defined per mode.  In c-mode, c++-mode and java-mode, they
;; are simply text between curly braces, while in Lisp-ish modes parens
;; are used.  Multi-line comment blocks can also be hidden.  Read-only
;; buffers are not a problem, since hideshow doesn't modify the text.

At least, C-c @ C-h and C-c @ C-s do work for me with point in an s-expression.

(Personally, I find those keystrokes super-awkward and would rebind them if I were going to use this a lot, but that's just me.)