emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] add outline regexp to ruby-mode


From: Bozhidar Batsov
Subject: Re: [PATCH] add outline regexp to ruby-mode
Date: Wed, 06 Jul 2022 10:04:49 +0300
User-agent: Cyrus-JMAP/3.7.0-alpha0-713-g1f035dc716-fm-20220617.001-g1f035dc7

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

On Wed, Jul 6, 2022, at 2:48 AM, Yilkal Argaw wrote:
> 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
<yilkalargawworkneh@gmail.com> wrote:
>
> 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




reply via email to

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