Skip to content

Instantly share code, notes, and snippets.

@littlemove
Created March 18, 2016 11:40
Show Gist options
  • Save littlemove/5c55dfe0bb724f4420c0 to your computer and use it in GitHub Desktop.
Save littlemove/5c55dfe0bb724f4420c0 to your computer and use it in GitHub Desktop.

Revisions

  1. littlemove created this gist Mar 18, 2016.
    15 changes: 15 additions & 0 deletions my-ruby.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    ;; Code folding
    (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" "{" "[")) ; Block start
    ,(rx (or "}" "]" "end")) ; Block end
    ,(rx (or "#" "=begin")) ; Comment start
    ruby-forward-sexp nil)))

    (global-set-key (kbd "C-c h <left>") 'hs-hide-block)
    (global-set-key (kbd "C-c h <right>") 'hs-show-block)
    (global-set-key (kbd "C-c h <up>") 'hs-hide-level)