I like this suggestion, although I don't think that's the right regexp to use for an outline. Shouldn't it be limited to definitions only (similar to what imenu typically does)?
> Hello guys.
> Some programming modes built into emacs provide outline-regexp to
> allow for code folding and an example of this is python-mode.
> "ruby-mode" on the other hand does does not have this feature. Since
> it is a very handy feature to have it might be worth adding with the
> following simple patch.
>
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> index a197724634..6437b84628 100644
> --- a/lisp/progmodes/ruby-mode.el
> +++ b/lisp/progmodes/ruby-mode.el
> @@ -2447,6 +2447,7 @@ ruby--prettify-symbols-alist
> ("lambda" . ?λ))
> "Value for `prettify-symbols-alist' in `ruby-mode'.")
>
> +
> ;;;###autoload
> (define-derived-mode ruby-mode prog-mode "Ruby"
> "Major mode for editing Ruby code."
> @@ -2465,7 +2466,8 @@ ruby-mode
> ((?_ . "w"))))
> (setq-local prettify-symbols-alist ruby--prettify-symbols-alist)
>
> - (setq-local syntax-propertize-function #'ruby-syntax-propertize))
> + (setq-local syntax-propertize-function #'ruby-syntax-propertize)
> + (setq-local outline-regexp ruby-indent-beg-re))
>
> ;;; Invoke ruby-mode when appropriate
> Sorry I just noticed the extra line break after I pressed send. Here is the
> patch without that line break.
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index a197724634..7a62d72e06 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -2465,7 +2465,8 @@ ruby-mode
((?_ . "w"))))
(setq-local prettify-symbols-alist ruby--prettify-symbols-alist)
- (setq-local syntax-propertize-function #'ruby-syntax-propertize))
+ (setq-local syntax-propertize-function #'ruby-syntax-propertize)
+ (setq-local outline-regexp ruby-indent-beg-re))
;;; Invoke ruby-mode when appropriate
On Wed, Jul 6, 2022 at 2:28 AM Yilkal Argaw
>
> Hello guys.
> Some programming modes built into emacs provide outline-regexp to
> allow for code folding and an example of this is python-mode.
> "ruby-mode" on the other hand does does not have this feature. Since
> it is a very handy feature to have it might be worth adding with the
> following simple patch.
>
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> index a197724634..6437b84628 100644
> --- a/lisp/progmodes/ruby-mode.el
> +++ b/lisp/progmodes/ruby-mode.el
> @@ -2447,6 +2447,7 @@ ruby--prettify-symbols-alist
> ("lambda" . ?λ))
> "Value for `prettify-symbols-alist' in `ruby-mode'.")
>
> +
> ;;;###autoload
> (define-derived-mode ruby-mode prog-mode "Ruby"
> "Major mode for editing Ruby code."
> @@ -2465,7 +2466,8 @@ ruby-mode
> ((?_ . "w"))))
> (setq-local prettify-symbols-alist ruby--prettify-symbols-alist)
>
> - (setq-local syntax-propertize-function #'ruby-syntax-propertize))
> + (setq-local syntax-propertize-function #'ruby-syntax-propertize)
> + (setq-local outline-regexp ruby-indent-beg-re))
>
> ;;; Invoke ruby-mode when appropriate