From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Bozhidar Batsov" Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] add outline regexp to ruby-mode Date: Wed, 06 Jul 2022 10:04:49 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bce8811bbdd24fdb89a940ec615af0b2 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21405"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.7.0-alpha0-713-g1f035dc716-fm-20220617.001-g1f035dc7 To: "Emacs Devel" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 06 09:06:57 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 1o8z7e-0005M1-FH for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Jul 2022 09:06:55 +0200 Original-Received: from localhost ([::1]:51666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8z7d-0006W6-81 for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Jul 2022 03:06:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8z66-000531-JI for emacs-devel@gnu.org; Wed, 06 Jul 2022 03:05:21 -0400 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:43239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8z64-00073z-Bl for emacs-devel@gnu.org; Wed, 06 Jul 2022 03:05:18 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id D44A43200915 for ; Wed, 6 Jul 2022 03:05:11 -0400 (EDT) Original-Received: from imap43 ([10.202.2.93]) by compute5.internal (MEProxy); Wed, 06 Jul 2022 03:05:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=batsov.dev; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1657091111; x=1657177511; bh=Axdhs6VN+c kVbSQtrDfMbhcbK65XTNlvygJWNtom0UI=; b=XrcMjFxohskE/+SRFFhlICpKKj cbpGKarfid7x3vdTfIDw6ExVWaW4BK+pf5HxQUNeZDmZ+qdXgjm7fdztzRcod4a1 4OqE2zFChygBz8PtEXSEKaEuVtwOftHAbnH8IAKhGH9lobPNZCl/9kuub64W3uag jlPD4W+5FKKPNwduoJo4BeBYbgkpwRY6nY6svcVUK4Ctg5sGi4mpVRZs2ig5fRXt ATvoggU1P16/5v0UOkcLgh/0cmlDGnYO9H5rfI7pc3f/FP6ZnEl+OPwROGAYUMz6 2VzMKKu89ef1yDMagWsK3PD76YjZW8N8iaKF5DwmaL2lIufE+K4BUK/7rMiw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1657091111; x=1657177511; bh=Axdhs6VN+ckVbSQtrDfMbhcbK65X TNlvygJWNtom0UI=; b=JMhrcm0SI43OnBOHdWbEs/SHuPqhASOvawzhOjAugFaq goByk29YlSFKXZFXiATfJh/OLN1lnF0BIUQD1ENspOKh+l46ryJT10ZqTTozD45d zt2Pfb1tHfkCmLQu7ol9wvCNsGP6IfnAejPKmhzJFLRt3bP5Qr/A3+uyVTPknUVI vcdzFZWChlrrmI8Ezx59RQdjjrQhc3+AyI5dKSMF9eAqiqEio+vxAekLOsWGZAD0 Lh/QqIGv8t+3QGoUpoDpWHwz7EtQ60Sl+/BTTgnMFuSppEvLWpfuPVUGr/l18MzU OgwCwjQmcNiZOnXT+iDRNBkPCmFxEB0xRcOxNKpWjQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudeivddgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsegrtderreerreejnecuhfhrohhmpedfueho iihhihgurghruceurghtshhovhdfuceosghoiihhihgurghrsegsrghtshhovhdruggvvh eqnecuggftrfgrthhtvghrnhepfeffhfehkeefkeekudetfffghfevgfdtvdelfeeghefh feduleehtdelheefgeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepsghoiihhihgurghrsegsrghtshhovhdruggvvh X-ME-Proxy: Feedback-ID: i025946a9:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 32A2A2D40071; Wed, 6 Jul 2022 03:05:11 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: Received-SPF: pass client-ip=64.147.123.25; envelope-from=bozhidar@batsov.dev; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:291897 Archived-At: --bce8811bbdd24fdb89a940ec615af0b2 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable I like this suggestion, although I don't think that's the right regexp t= o use for an outline. Shouldn't it be limited to definitions only (simil= ar to what imenu typically does)?=20 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" . ?=CE=BB)) > > "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. >=20 > 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) >=20 > - (setq-local syntax-propertize-function #'ruby-syntax-propertize)) > + (setq-local syntax-propertize-function #'ruby-syntax-propertize) > + (setq-local outline-regexp ruby-indent-beg-re)) >=20 > ;;; Invoke ruby-mode when appropriate >=20 >=20 >=20 > On Wed, Jul 6, 2022 at 2:28 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" . ?=CE=BB)) > > "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 >=20 >=20 --bce8811bbdd24fdb89a940ec615af0b2 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
I like this sug= gestion, although I don't think that's the right regexp to use for an ou= tline. Shouldn't it be limited to definitions only (similar to what imen= u 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
> allo= w for code folding and an example of this is python-mode.
= > "ruby-mode" on the other hand does does not have this feature. Sinc= e
> it is a very handy feature to have it might be wort= h adding with the
> following simple patch.
>
> diff --git a/lisp/progmodes/ruby-mode.el b/li= sp/progmodes/ruby-mode.el
> index a197724634..6437b8462= 8 100644
> --- a/lisp/progmodes/ruby-mode.el
<= div>> +++ b/lisp/progmodes/ruby-mode.el
> @@ -2447,6= +2447,7 @@ ruby--prettify-symbols-alist
>  &= nbsp;   ("lambda" . ?=CE=BB))
>  &n= bsp; "Value for `prettify-symbols-alist' in `ruby-mode'.")
>
> +
>  ;;;###autoload
>  (define-derived-mode ruby-mode prog-mode "Ruby"
<= /div>
>    "Major mode for editing Ruby code."
=
> @@ -2465,7 +2466,8 @@ ruby-mode
> =             =             =             ((?_ = . "w"))))
>    (setq-local prettify-symb= ols-alist ruby--prettify-symbols-alist)
>
> -  (setq-local syntax-propertize-function #'ruby-syntax-prope= rtize))
> +  (setq-local syntax-propertize-functio= n #'ruby-syntax-propertize)
> +  (setq-local outli= ne-regexp ruby-indent-beg-re))
>
>&nbs= p; ;;; 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.

d= iff --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<= br>
@@ -2465,7 +2465,8 @@ ruby-mode
  =             =             =           ((?_ . "w"))))
   (setq-local prettify-symbols-alist ruby--pretti= fy-symbols-alist)

-  (setq-local synta= x-propertize-function #'ruby-syntax-propertize))
+  (= setq-local syntax-propertize-function #'ruby-syntax-propertize)
+  (setq-local outline-regexp ruby-indent-beg-re))
<= div>
;;; Invoke ruby-mode when appropriate
<= br>


On Wed, Jul 6, 2022 at 2:28 = AM Yilkal Argaw
>=
> Hello guys.
> Some programming mode= s built into emacs provide outline-regexp to
> allow fo= r 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 ad= ding with the
> following simple patch.
&= gt;
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/p= rogmodes/ruby-mode.el
> index a197724634..6437b84628 10= 0644
> --- a/lisp/progmodes/ruby-mode.el
= > +++ b/lisp/progmodes/ruby-mode.el
> @@ -2447,6 +24= 47,7 @@ ruby--prettify-symbols-alist
>   = ;   ("lambda" . ?=CE=BB))
>   = "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
> &nbs= p;           &nbs= p;           &nbs= p;           ((?_ . "w= "))))
>    (setq-local prettify-symbols-= alist ruby--prettify-symbols-alist)
>
>= ; -  (setq-local syntax-propertize-function #'ruby-syntax-propertiz= e))
> +  (setq-local syntax-propertize-function #'= ruby-syntax-propertize)
> +  (setq-local outline-r= egexp ruby-indent-beg-re))
>
>  ;= ;; Invoke ruby-mode when appropriate



--bce8811bbdd24fdb89a940ec615af0b2--