[Top][All Lists]

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

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

From: Juri Linkov
Subject: Re: [PATCH] add outline regexp to ruby-mode
Date: Fri, 08 Jul 2022 20:18:02 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

>>>> But now I noticed that actually if/unless/case/... in
>>>> ruby-indent-beg-re has no effect on outlines, because
>>>> they are on a separate regexp group.  So using it for
>>>> outline-regexp would be fine.  Then I only suggest
>>>> to add outline-level as well.
>>> If the result looks good to you, please go ahead.
>> I'd still prefer the simpler regexp suggested by Juri, as it's more
>> intention revealing, but I can live with using ruby-indent-beg-re as well.
> For my personal use I used to use a similar approach where I defined
> outline-regexp through ruby-mode-hook. But I did not want to add an
> additional regex that might be left trailing when the regex for the
> syntax parsing changes. It might turn out to be an additional load for
> the package maintainer and it might not be noticed by new contributors
> when changing the syntax parsing rules up top.

When this will become a real problem then it would be possible
to refactor ruby-indent-beg-re into separate variables one of which
could be used for outline-regexp.

> It might also be good to add ```outline-heading-end-regexp``` and
> ```outline-level``` for completeness but my knowledge of regular
> expressions and outline-mode is a bit limited.

It seems outline-heading-end-regexp is not required here.

> Maybe someone might help with that. But for now only defining
> outline-regexp covers most use cases so I don't mind if mine
> or Juri's solution was merged.

For now I pushed a simple version where outline-regexp is an exact copy
of the first part of ruby-indent-beg-re that contains only a regexp
for top-level definitions.

> The regex I used to use personally is the one below incase anyone
> finds it helpful
>  "^\\([ \t]*\\)class \\|^\\([ \t]*\\)module \\|^\\([ \t]*\\)def "

This looks equivalent to the regexp produced by the first part of
ruby-indent-beg-re.  Thanks for the suggestion!

reply via email to

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