tags:

views:

151

answers:

1

Hi emacs gurus - I wonder if you know how to get hideshow work with new modes. For instance, I have some extraneous code I want to hide with R. With folding-mode it can simply be

(load "folding" 'nomessage 'noerror)
(folding-add-to-marks-list 'ess-mode "# {{{"  "# }}}" nil t)
(add-hook 'ess-mode-hook 'turn-on-folding-mode)

I thought the hideshow equivalent would be

(add-to-list 'hs-special-modes-alist
         '(ess-mode "# {{{" "# }}}" "#[ #]?"
      hs-forward-sexp 
      hs-c-like-adjust-block-beginning
      ))
(add-hook 'ess-mode-hook '(lambda()
          (hs-minor-mode 1)
          (hs-hide-all)
          (custom-set-variables
           (hs-hide-comments-when-hiding-all 0)
           )
))

but I think there is some magic in hs-forward-sexp that I am not sure how to figure out?

I tried adapting a function written for c-sharp (replacing the regex search on region/endregion with {{{ and }}}) but no luck! I wonder if the solution is obvious to a veteran out there...

Thanks much!

+2  A: 

You didn't specify what actually went wrong. When I tried using your configuration, I found that the (hs-hide-all) call failed with the wrong number of arguments because hs-forward-sexp takes two arguments, but was being called with one.

Long story short, I can get the hiding to work properly for text mode (with the changes you had above) after fixing your initialization to be:

(add-to-list 'hs-special-modes-alist
             '(ess-mode "# {{{" "# }}}" "#[ #]?"
                         forward-sexp 
                         hs-c-like-adjust-block-beginning))

You had hs-forward-sexp on the 3rd line, but what you really wanted was just regular forward-sexp.

Note: my testing was actually in text-mode, but that shouldn't affect the results.

Trey Jackson
I see, did not know about forward-sexp. Thanks Trey!
Stephen