Enable hideshow for more modes, e.g. Ruby?

5

1

hideshow is cool, but it's limited to only a few programming languages. Can someone help me add support for more, such as Ruby and Haskell?

mcandre

Posted 2013-04-01T16:57:04.723

Reputation: 2 696

The emacs wiki page you linked to has some suggestions. Look at the Universal code folding section. Try some of the suggestions out and report back with ay specific problems.

– terdon – 2013-04-01T19:10:39.550

@terdon Yes, I'm looking at this page and I have no idea how to apply it. I'd like to use indentation-based folding, with hideshowvis, for all modes. – mcandre – 2013-04-01T20:38:59.870

Answers

0

(add-hook 'ruby-mode-hook
          (lambda () (hs-minor-mode)))

(eval-after-load "hideshow"
  '(add-to-list 'hs-special-modes-alist
              `(ruby-mode
                ,(rx (or "def" "class" "module" "do" "{" "[" "if" "else" "unless")) ; Block start
                ,(rx (or "}" "]" "end"))                       ; Block end
                ,(rx (or "#" "=begin"))                        ; Comment start
                ruby-forward-sexp nil)))

Found it here https://coderwall.com/p/u-l0ra/ruby-code-folding-in-emacs

CyJimmy264

Posted 2013-04-01T16:57:04.723

Reputation: 1