启用 hideshow 获得更多模式,例如 Ruby?

启用 hideshow 获得更多模式,例如 Ruby?

隐藏显示很酷,但它仅限于几种编程语言。有人能帮我添加对更多语言的支持吗,比如 Ruby 和 Haskell?

答案1

(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)))

在这里找到https://coderwall.com/p/u-l0ra/ruby-code-folding-in-emacs

相关内容