emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 033d370a51: * lisp/progmodes/ruby-mode.el (ruby-mode): Set outlin


From: Juri Linkov
Subject: master 033d370a51: * lisp/progmodes/ruby-mode.el (ruby-mode): Set outline-regexp, outline-level.
Date: Fri, 8 Jul 2022 13:17:59 -0400 (EDT)

branch: master
commit 033d370a5140aaba79cbac37399a387390d4c18e
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/progmodes/ruby-mode.el (ruby-mode): Set outline-regexp, 
outline-level.
    
    Suggested by Yilkal Argaw <yilkalargawworkneh@gmail.com>.
---
 lisp/progmodes/ruby-mode.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index a197724634..87bb92908d 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]