]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/ruby-mode.el (ruby-mode): Set outline-regexp, outline-level.
authorJuri Linkov <juri@linkov.net>
Fri, 8 Jul 2022 17:17:29 +0000 (20:17 +0300)
committerJuri Linkov <juri@linkov.net>
Fri, 8 Jul 2022 17:17:29 +0000 (20:17 +0300)
Suggested by Yilkal Argaw <yilkalargawworkneh@gmail.com>.

lisp/progmodes/ruby-mode.el

index a1977246341238e9d6a50ca65cc75ffd70952ae9..87bb92908d12578a357a389f484b141fd0b1f254 100644 (file)
@@ -2457,6 +2457,13 @@ If there is no Rubocop config file, Rubocop will be passed a flag
   (setq-local beginning-of-defun-function #'ruby-beginning-of-defun)
   (setq-local end-of-defun-function #'ruby-end-of-defun)
 
+  ;; `outline-regexp' contains the first part of `ruby-indent-beg-re'
+  (setq-local outline-regexp (concat "^\\s *"
+                                     (regexp-opt '("class" "module" "def"))
+                                     "\\_>"))
+  (setq-local outline-level (lambda () (1+ (/ (current-indentation)
+                                              ruby-indent-level))))
+
   (add-hook 'after-save-hook #'ruby-mode-set-encoding nil 'local)
   (add-hook 'electric-indent-functions #'ruby--electric-indent-p nil 'local)
   (add-hook 'flymake-diagnostic-functions #'ruby-flymake-auto nil 'local)