unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Yilkal Argaw <yilkalargawworkneh@gmail.com>
Cc: Bozhidar Batsov <bozhidar@batsov.dev>,
	 Dmitry Gutov <dgutov@yandex.ru>,
	Emacs Devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] add outline regexp to ruby-mode
Date: Fri, 08 Jul 2022 20:18:02 +0300	[thread overview]
Message-ID: <86let3ttf9.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAJddU=qH0vxQMi9QvjOzXOLpT7gNnu=fX_8-Rzw-5Tye58mjFQ@mail.gmail.com> (Yilkal Argaw's message of "Fri, 8 Jul 2022 11:27:48 +0300")

>>>> 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	other threads:[~2022-07-08 17:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 23:28 [PATCH] add outline regexp to ruby-mode Yilkal Argaw
2022-07-05 23:48 ` Yilkal Argaw
2022-07-06  7:04   ` Bozhidar Batsov
2022-07-06  8:06     ` Juri Linkov
2022-07-08  1:12       ` Dmitry Gutov
2022-07-08  5:38         ` Bozhidar Batsov
2022-07-08  8:27           ` Yilkal Argaw
2022-07-08 17:18             ` Juri Linkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86let3ttf9.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=bozhidar@batsov.dev \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=yilkalargawworkneh@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).