From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] add outline regexp to ruby-mode Date: Fri, 08 Jul 2022 20:18:02 +0300 Organization: LINKOV.NET Message-ID: <86let3ttf9.fsf@mail.linkov.net> References: <867d4qvep9.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23105"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: Bozhidar Batsov , Dmitry Gutov , Emacs Devel To: Yilkal Argaw Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 08 19:22:03 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9rg3-0005tA-GF for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Jul 2022 19:22:03 +0200 Original-Received: from localhost ([::1]:49238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9rfy-00017L-GO for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Jul 2022 13:22:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9rdG-0006tn-DP for emacs-devel@gnu.org; Fri, 08 Jul 2022 13:19:10 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:37517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9rdD-0004sY-J5 for emacs-devel@gnu.org; Fri, 08 Jul 2022 13:19:08 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id EFF53C0002; Fri, 8 Jul 2022 17:19:00 +0000 (UTC) In-Reply-To: (Yilkal Argaw's message of "Fri, 8 Jul 2022 11:27:48 +0300") Received-SPF: pass client-ip=217.70.183.198; envelope-from=juri@linkov.net; helo=relay6-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291973 Archived-At: >>>> 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!