all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Matching parenthesis for long constructs
@ 2024-05-09 12:33 Heime
  2024-05-09 14:00 ` Pierre Rouleau
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Heime @ 2024-05-09 12:33 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


When I have long constructs the current way that parenthesis are highlighted
is not very useful because the matching parenthesis resides outside the work
window.  Are there future possibilities or capabilities to address this ?





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 12:33 Matching parenthesis for long constructs Heime
@ 2024-05-09 14:00 ` Pierre Rouleau
  2024-05-09 14:22   ` Heime
  2024-05-09 14:24   ` Emanuel Berg
  2024-05-09 14:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-05-09 21:49 ` Daniel Martín
  2 siblings, 2 replies; 25+ messages in thread
From: Pierre Rouleau @ 2024-05-09 14:00 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Thu, May 9, 2024 at 8:34 AM Heime <heimeborgia@protonmail.com> wrote:

>
> When I have long constructs the current way that parenthesis are
> highlighted
> is not very useful because the matching parenthesis resides outside the
> work
> window.  Are there future possibilities or capabilities to address this ?
>
> There's already plenty of ways to handle this.
1- You can spend your money and buy a monitor that tilts vertically and use
small fonts.
2- OR you can use time to learn:
  - coding techniques to reduce code size, but mostly
  - navigation techniques with the editor you use.
     Emacs is wonderful for Lisp editing.
     - Without anything added: use C-M-<right>  to move from ( to ) and
C-M-<left> from ) to (
     - Learn how to use Lispy.  Typing 'd' with point before ( or after )
does the same.

When I started learning Emacs, I wrote documentation for myself.
I learn better by reading, and writing about it.
I organized the information in topics while I learned and the way,
for me, was to organize the info in tables.
You may be interested in the tables I created for Emacs Lisp and Lispy.
They are part of my PEL project.

See :
- PEL @ Github: https://github.com/pierre-rouleau/pel#readme
- PDF files (use a browser that renders them, not download them):
  - Index (links to all others):
https://raw.githubusercontent.com/pierre-rouleau/pel/master/doc/pdf/-index.pdf
  - Emacs Lisp table:
https://raw.githubusercontent.com/pierre-rouleau/pel/master/doc/pdf/pl-emacs-lisp.pdf
  - Lispy:
https://raw.githubusercontent.com/pierre-rouleau/pel/master/doc/pdf/plm-lispy.pdf

You should be able to find all you need.
-- 
/Pierre


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 12:33 Matching parenthesis for long constructs Heime
  2024-05-09 14:00 ` Pierre Rouleau
@ 2024-05-09 14:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-05-09 21:49 ` Daniel Martín
  2 siblings, 0 replies; 25+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-05-09 14:20 UTC (permalink / raw)
  To: help-gnu-emacs

> When I have long constructs the current way that parenthesis are
> highlighted is not very useful because the matching parenthesis
> resides outside the work window.

There are various existing behaviors for that in Emacs.  So please
describe what you see (and don't like) rather than say "current way"
because I personally don't know what you consider as the "current way".

Have you tried to search manuals or web sites for something like "Emacs
parenthesis highlight"?

> Are there future possibilities or capabilities to address this ?

Definitely.  There also past ones.


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 14:00 ` Pierre Rouleau
@ 2024-05-09 14:22   ` Heime
  2024-05-09 14:48     ` [External] : " Drew Adams
  2024-05-09 15:14     ` Pierre Rouleau
  2024-05-09 14:24   ` Emanuel Berg
  1 sibling, 2 replies; 25+ messages in thread
From: Heime @ 2024-05-09 14:22 UTC (permalink / raw)
  To: Pierre Rouleau; +Cc: Heime via Users list for the GNU Emacs text editor

On Friday, May 10th, 2024 at 2:00 AM, Pierre Rouleau <prouleau001@gmail.com> wrote:

> On Thu, May 9, 2024 at 8:34 AM Heime heimeborgia@protonmail.com wrote:
> 
> > When I have long constructs the current way that parenthesis are
> > highlighted
> > is not very useful because the matching parenthesis resides outside the
> > work
> > window. Are there future possibilities or capabilities to address this ?
> > 
> > There's already plenty of ways to handle this.
> 
> 1- You can spend your money and buy a monitor that tilts vertically and use
> small fonts.

I cannot recognise words in small font.  It is a problem even with a large monitor.
In a few decades, you might find you have a problem as well. 

> 2- OR you can use time to learn:
> - coding techniques to reduce code size, but mostly

This is for most things not possible 

> - navigation techniques with the editor you use.
> Emacs is wonderful for Lisp editing.
> - Without anything added: use C-M-<right> to move from ( to ) and
> 
> C-M-<left> from ) to (

I do not want myself to move from one to another.  But to display for me
the line content of the corresponding match whilst staying at point.
 
> - Learn how to use Lispy. Typing 'd' with point before ( or after )
> does the same.
> 
> When I started learning Emacs, I wrote documentation for myself.
> I learn better by reading, and writing about it.
> I organized the information in topics while I learned and the way,
> for me, was to organize the info in tables.
> You may be interested in the tables I created for Emacs Lisp and Lispy.
> They are part of my PEL project.
> 
> See :
> - PEL @ Github: https://github.com/pierre-rouleau/pel#readme
> - PDF files (use a browser that renders them, not download them):
> - Index (links to all others):
> https://raw.githubusercontent.com/pierre-rouleau/pel/master/doc/pdf/-index.pdf
> - Emacs Lisp table:
> https://raw.githubusercontent.com/pierre-rouleau/pel/master/doc/pdf/pl-emacs-lisp.pdf
> - Lispy:
> https://raw.githubusercontent.com/pierre-rouleau/pel/master/doc/pdf/plm-lispy.pdf
> 
> You should be able to find all you need.
> --
> /Pierre



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 14:00 ` Pierre Rouleau
  2024-05-09 14:22   ` Heime
@ 2024-05-09 14:24   ` Emanuel Berg
  1 sibling, 0 replies; 25+ messages in thread
From: Emanuel Berg @ 2024-05-09 14:24 UTC (permalink / raw)
  To: help-gnu-emacs

Pierre Rouleau wrote:

>> When I have long constructs the current way that
>> parenthesis are highlighted is not very useful because the
>> matching parenthesis resides outside the work window.
>> Are there future possibilities or capabilities to address
>> this ?
>>
>> There's already plenty of ways to handle this.
>
> 1- You can spend your money and buy a monitor that tilts
> vertically and use small fonts.
> 2- OR you can use time to learn:
>   - coding techniques to reduce code size, but mostly
>   - navigation techniques with the editor you use.

I don't think one should have to buy or learn anything to have
such a simple and basic feature in a Lisp editor, when one
inputs ')' it says what it matches if it isn't displayed, one
could have such a thing show up when one has point right after
it as well in that situation.

It could be an option to `paren' to disable for people who
prefer the other alternatives.

(require 'paren)
(setq show-paren-delay 0)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 14:22   ` Heime
@ 2024-05-09 14:48     ` Drew Adams
  2024-05-09 15:35       ` Emanuel Berg
  2024-05-09 16:58       ` Heime
  2024-05-09 15:14     ` Pierre Rouleau
  1 sibling, 2 replies; 25+ messages in thread
From: Drew Adams @ 2024-05-09 14:48 UTC (permalink / raw)
  To: Heime, Pierre Rouleau; +Cc: Heime via Users list for the GNU Emacs text editor

> > > When I have long constructs the current way that parenthesis are
> > > highlighted is not very useful because the matching parenthesis
> > > resides outside the work window. 
> > >
> > > There's already plenty of ways to handle this.
>
> I do not want myself to move from one to another.  But to display for me
> the line content of the corresponding match whilst staying at point.

Emacs manual, node Matching (Programs > Parentheses >
Matching) tells you all you need to know:

https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html

I assume you've already turned on `show-paren-mode'.

In particular, `blink-matching-paren'.  Increase the
value of `blink-matching-paren-distance', if you like.
___

You really should Ask Emacs, to help yourself.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 14:22   ` Heime
  2024-05-09 14:48     ` [External] : " Drew Adams
@ 2024-05-09 15:14     ` Pierre Rouleau
  2024-05-09 15:38       ` Emanuel Berg
  1 sibling, 1 reply; 25+ messages in thread
From: Pierre Rouleau @ 2024-05-09 15:14 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Thu, May 9, 2024 at 10:23 AM Heime <heimeborgia@protonmail.com> wrote:

>
> I do not want myself to move from one to another.  But to display for me
> the line content of the corresponding match whilst staying at point.
>
> Then, use parenthesis highlighting, activate follow-mode (M-x follow-mode)
in the current window, split that window vertically (C-x 3) as many times
are required to see the end of the function inside the other window.

Several packages support parenthesis highlighting.  Lispy is one of them.
-- 
/Pierre


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 14:48     ` [External] : " Drew Adams
@ 2024-05-09 15:35       ` Emanuel Berg
  2024-05-11  1:43         ` Drew Adams
  2024-05-11  5:40         ` tomas
  2024-05-09 16:58       ` Heime
  1 sibling, 2 replies; 25+ messages in thread
From: Emanuel Berg @ 2024-05-09 15:35 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> I do not want myself to move from one to another. But to
>> display for me the line content of the corresponding match
>> whilst staying at point.
>
> Emacs manual, node Matching (Programs > Parentheses >
> Matching) tells you all you need to know:
>
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html
>
> I assume you've already turned on `show-paren-mode'.

But that only helps if the left (opening) parenthesis is in
the same window, but the OP asked what do when that isn't
the case.

I agree with him it is a pretty bad state, I think it should
be outputted in the echo area the same that happens when you
write a right (closing) parenthesis and the left one isn't in
the window.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 15:14     ` Pierre Rouleau
@ 2024-05-09 15:38       ` Emanuel Berg
  2024-05-11  4:58         ` Pierre Rouleau
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2024-05-09 15:38 UTC (permalink / raw)
  To: help-gnu-emacs

Pierre Rouleau wrote:

> in the current window, split that window vertically (C-x 3)
> as many times are required to see the end of the function
> inside the other window.

One shouldn't have to do anything for this.

> Several packages support parenthesis highlighting. Lispy is
> one of them.

One shouldn't have to install anything for this and it should
be the default behavior.

Also highlighting in its basic form does not help if one of
the parenthesis isn't in the window so cannot be highlighted
for that very reason, this was very clearly explained by the
OP in the initial post.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 14:48     ` [External] : " Drew Adams
  2024-05-09 15:35       ` Emanuel Berg
@ 2024-05-09 16:58       ` Heime
  2024-05-09 17:45         ` Drew Adams
                           ` (2 more replies)
  1 sibling, 3 replies; 25+ messages in thread
From: Heime @ 2024-05-09 16:58 UTC (permalink / raw)
  To: Drew Adams
  Cc: Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

On Friday, May 10th, 2024 at 2:48 AM, Drew Adams <drew.adams@oracle.com> wrote:

> > > > When I have long constructs the current way that parenthesis are
> > > > highlighted is not very useful because the matching parenthesis
> > > > resides outside the work window.
> > > >
> > > > There's already plenty of ways to handle this.
> >
> > I do not want myself to move from one to another. But to display for me
> > the line content of the corresponding match whilst staying at point.
>
>
> Emacs manual, node Matching (Programs > Parentheses >
>
> Matching) tells you all you need to know:
>
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html
>
> I assume you've already turned on `show-paren-mode'. In particular,` blink-matching-paren'. Increase the
> value of `blink-matching-paren-distance', if you like.
> ___
>
> You really should Ask Emacs, to help yourself.

This is what the manual says

"Whenever you type a self-inserting character that is a closing delimiter, 
Emacs briefly indicates the location of the matching opening delimiter, 
provided that is on the screen. If it is not on the screen, Emacs displays 
some of the text near it in the echo area. Either way, you can tell which 
grouping you are closing off."

Basically the feature is useful only for short expressions.  If the 
opening expression is not on the screen, you cannot tell which grouping 
you are closing off.  Because emacs show you the text of the construct  
that is one level higher up.

Try going to the closing parenthesis of a pcase construct where the closing
parenthesis start to blink.  You are effectively within the construct that
encloses the pcase (the construct at the next higher level) and you get shown
that rather than the pcase construct in the echo area.  

You cannot tell what you are closing off.




^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 16:58       ` Heime
@ 2024-05-09 17:45         ` Drew Adams
  2024-05-09 17:52         ` Eli Zaretskii
  2024-05-09 18:24         ` Yuri Khan
  2 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2024-05-09 17:45 UTC (permalink / raw)
  To: Heime; +Cc: Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

> Basically the feature is useful only for short expressions.  If the
> opening expression is not on the screen, you cannot tell which grouping
> you are closing off.  Because emacs show you the text of the construct
> that is one level higher up.
> 
> Try going to the closing parenthesis of a pcase construct where the
> closing
> parenthesis start to blink.  You are effectively within the construct that
> encloses the pcase (the construct at the next higher level) and you get
> shown
> that rather than the pcase construct in the echo area.
> 
> You cannot tell what you are closing off.

`M-x report-emacs-bug'

That's for both bugs and enhancement requests.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 16:58       ` Heime
  2024-05-09 17:45         ` Drew Adams
@ 2024-05-09 17:52         ` Eli Zaretskii
  2024-05-09 18:09           ` Emanuel Berg
  2024-05-09 18:24         ` Yuri Khan
  2 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2024-05-09 17:52 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 09 May 2024 16:58:55 +0000
> From: Heime <heimeborgia@protonmail.com>
> Cc: Pierre Rouleau <prouleau001@gmail.com>,
>  Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
> 
> On Friday, May 10th, 2024 at 2:48 AM, Drew Adams <drew.adams@oracle.com> wrote:
> 
> > I assume you've already turned on `show-paren-mode'. In particular,` blink-matching-paren'. Increase the
> > value of `blink-matching-paren-distance', if you like.
> > ___
> >
> > You really should Ask Emacs, to help yourself.
> 
> This is what the manual says
> 
> "Whenever you type a self-inserting character that is a closing delimiter, 
> Emacs briefly indicates the location of the matching opening delimiter, 
> provided that is on the screen. If it is not on the screen, Emacs displays 
> some of the text near it in the echo area. Either way, you can tell which 
> grouping you are closing off."
> 
> Basically the feature is useful only for short expressions.

No, not only.  Don't stop reading where you stopped, read on.  You
will find there the description of show-paren-mode and the variables
that control how far forward/back Emacs looks for the patching paren,
and what it does when the matching paren in outside of the window.
There are options there that we believe should fit anyone's taste,
just choose what you like best.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 17:52         ` Eli Zaretskii
@ 2024-05-09 18:09           ` Emanuel Berg
  2024-05-11  6:27             ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2024-05-09 18:09 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:

>> Basically the feature is useful only for short expressions.
>
> No, not only. Don't stop reading where you stopped, read on.
> You will find there the description of show-paren-mode and
> the variables that control how far forward/back Emacs looks
> for the patching paren, and what it does when the matching
> paren in outside of the window. There are options there that
> we believe should fit anyone's taste, just choose what you
> like best.

This is good, no idea why it isn't set by default.

(setq show-paren-context-when-offscreen t)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 16:58       ` Heime
  2024-05-09 17:45         ` Drew Adams
  2024-05-09 17:52         ` Eli Zaretskii
@ 2024-05-09 18:24         ` Yuri Khan
  2024-05-09 18:29           ` Emanuel Berg
  2024-05-09 18:57           ` Heime
  2 siblings, 2 replies; 25+ messages in thread
From: Yuri Khan @ 2024-05-09 18:24 UTC (permalink / raw)
  To: Heime
  Cc: Drew Adams, Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

On Thu, 9 May 2024 at 23:59, Heime <heimeborgia@protonmail.com> wrote:

> Try going to the closing parenthesis of a pcase construct where the closing
> parenthesis start to blink.  You are effectively within the construct that
> encloses the pcase (the construct at the next higher level) and you get shown
> that rather than the pcase construct in the echo area.
>
> You cannot tell what you are closing off.

Are you typing programs from a print magazine? Because in real
programming you close off parentheses as you open them (or
electric-pair-mode or smartparens does it for you), then you go inside
and add inner forms, keeping parentheses balanced most of the time.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 18:24         ` Yuri Khan
@ 2024-05-09 18:29           ` Emanuel Berg
  2024-05-09 18:57           ` Heime
  1 sibling, 0 replies; 25+ messages in thread
From: Emanuel Berg @ 2024-05-09 18:29 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> Try going to the closing parenthesis of a pcase construct
>> where the closing parenthesis start to blink. You are
>> effectively within the construct that encloses the pcase
>> (the construct at the next higher level) and you get shown
>> that rather than the pcase construct in the echo area.
>>
>> You cannot tell what you are closing off.
>
> Are you typing programs from a print magazine? Because in
> real programming you close off parentheses as you open them
> (or electric-pair-mode or smartparens does it for you), then
> you go inside and add inner forms, keeping parentheses
> balanced most of the time.

He is talking about a very common situation with Lisp
programming in Emacs when the left (opening) parenthesis is in
a part of the buffer not within the current window.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 18:24         ` Yuri Khan
  2024-05-09 18:29           ` Emanuel Berg
@ 2024-05-09 18:57           ` Heime
  2024-05-09 19:45             ` Heime
  2024-05-09 19:46             ` Yuri Khan
  1 sibling, 2 replies; 25+ messages in thread
From: Heime @ 2024-05-09 18:57 UTC (permalink / raw)
  To: Yuri Khan
  Cc: Drew Adams, Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

On Friday, May 10th, 2024 at 6:24 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:

> On Thu, 9 May 2024 at 23:59, Heime heimeborgia@protonmail.com wrote:
> 
> > Try going to the closing parenthesis of a pcase construct where the closing
> > parenthesis start to blink. You are effectively within the construct that
> > encloses the pcase (the construct at the next higher level) and you get shown
> > that rather than the pcase construct in the echo area.
> > 
> > You cannot tell what you are closing off.
> 
> 
> Are you typing programs from a print magazine? Because in real
> programming you close off parentheses as you open them (or
> electric-pair-mode or smartparens does it for you), then you go inside
> and add inner forms, keeping parentheses balanced most of the time.

Most times I am changing existing code, and encounter this problem whilst
removing things.  I quite like the idea of typing programs from a print 
magazine like byte magazine from 1975.  Quite a shame people can't do that
anymore.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 18:57           ` Heime
@ 2024-05-09 19:45             ` Heime
  2024-05-09 19:46             ` Yuri Khan
  1 sibling, 0 replies; 25+ messages in thread
From: Heime @ 2024-05-09 19:45 UTC (permalink / raw)
  To: Heime
  Cc: Yuri Khan, Drew Adams, Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

On Friday, May 10th, 2024 at 6:57 AM, Heime <heimeborgia@protonmail.com> wrote:

> On Friday, May 10th, 2024 at 6:24 AM, Yuri Khan yuri.v.khan@gmail.com wrote:
> 
> > On Thu, 9 May 2024 at 23:59, Heime heimeborgia@protonmail.com wrote:
> > 
> > > Try going to the closing parenthesis of a pcase construct where the closing
> > > parenthesis start to blink. You are effectively within the construct that
> > > encloses the pcase (the construct at the next higher level) and you get shown
> > > that rather than the pcase construct in the echo area.
> > > 
> > > You cannot tell what you are closing off.
> > 
> > Are you typing programs from a print magazine? Because in real
> > programming you close off parentheses as you open them (or
> > electric-pair-mode or smartparens does it for you), then you go inside
> > and add inner forms, keeping parentheses balanced most of the time.
> 
> 
> Most times I am changing existing code, and encounter this problem whilst
> removing things. I quite like the idea of typing programs from a print
> magazine like byte magazine from 1975. Quite a shame people can't do that
> anymore.

Could users have Emacs Magazine ?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 18:57           ` Heime
  2024-05-09 19:45             ` Heime
@ 2024-05-09 19:46             ` Yuri Khan
  2024-05-09 20:44               ` Drew Adams
  1 sibling, 1 reply; 25+ messages in thread
From: Yuri Khan @ 2024-05-09 19:46 UTC (permalink / raw)
  To: Heime
  Cc: Drew Adams, Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

On Fri, 10 May 2024 at 01:58, Heime <heimeborgia@protonmail.com> wrote:

> Most times I am changing existing code, and encounter this problem whilst
> removing things.

If you stand on an opening parenthesis and press C-M-SPC
(‘mark-sexp’), the corresponding form, up to and including its closing
parenthesis, will be marked as a region. You can then delete or kill
it keeping surrounding parentheses balanced. (Alternatively, bind
‘kill-sexp’ to a key. )



^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 19:46             ` Yuri Khan
@ 2024-05-09 20:44               ` Drew Adams
  0 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2024-05-09 20:44 UTC (permalink / raw)
  To: Yuri Khan, Heime
  Cc: Pierre Rouleau,
	Heime via Users list for the GNU Emacs text editor

> (Alternatively, bind ‘kill-sexp’ to a key.)

Bound to `C-M-k' by default, which is a good choice.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 12:33 Matching parenthesis for long constructs Heime
  2024-05-09 14:00 ` Pierre Rouleau
  2024-05-09 14:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2024-05-09 21:49 ` Daniel Martín
  2024-05-10 19:38   ` tpeplt
  2 siblings, 1 reply; 25+ messages in thread
From: Daniel Martín @ 2024-05-09 21:49 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> When I have long constructs the current way that parenthesis are highlighted
> is not very useful because the matching parenthesis resides outside the work
> window.  Are there future possibilities or capabilities to address this ?

If you configure the variable show-paren-context-when-offscreen to t, if
show-paren-mode is enabled, then the echo area will show the context
around the opening parenthesis when you place the cursor at the
corresponding closing parenthesis.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 21:49 ` Daniel Martín
@ 2024-05-10 19:38   ` tpeplt
  0 siblings, 0 replies; 25+ messages in thread
From: tpeplt @ 2024-05-10 19:38 UTC (permalink / raw)
  To: Daniel Martín
  Cc: Heime, Heime via Users list for the GNU Emacs text editor

Daniel Martín <mardani29@yahoo.es> writes:

> Heime <heimeborgia@protonmail.com> writes:
>
>> When I have long constructs the current way that parenthesis are highlighted
>> is not very useful because the matching parenthesis resides outside the work
>> window.  Are there future possibilities or capabilities to address this ?
>
> If you configure the variable show-paren-context-when-offscreen to t, if
> show-paren-mode is enabled, then the echo area will show the context
> around the opening parenthesis when you place the cursor at the
> corresponding closing parenthesis.

Just so it is clear, the option ‘show-paren-context-when-offscreen’ was
introduced in Emacs 29.1, so it won’t be available to users of earlier
versions of Emacs.

Also, if you are not aware of them, there are the commands
‘backward-sexp’ and ‘forward-sexp’.  (Both of these commands have been
available since Emacs 21.1.)  These commands enable you to move backward
and forward by symbolic expressions (sexps).  So, when at the end of
long sexp, you can easily move to the beginning of expression by typing
the key sequence bound to the corresponding command and vice versa to
return.

By default, ‘backward-sexp’ is bound to C-M-b (and C-M-<left> and
ESC C-<left>).  ‘forward-sexp’ is bound to C-M-f (and C-M-<right>
and and ESC C-<right>).

These bindings are not described in the Emacs tutorial (C-h t), which
contains the following:

>Here is a summary of simple cursor-moving operations, including the
>word and sentence moving commands:
>
>	C-f	Move forward a character
>	C-b	Move backward a character
>
>	M-f	Move forward a word
>	M-b	Move backward a word
>
>	C-n	Move to next line
>	C-p	Move to previous line
>
>	C-a	Move to beginning of line
>	C-e	Move to end of line
>
>	M-a	Move back to beginning of sentence
>	M-e	Move forward to end of sentence

Note that moving among units of text is a progression from characters
(C-b/C-f) to words (M-b/M-f) to symbolic expressions (M-C-b/M-C-f).

Note that with symbolic expressions, you are not limited to expressions
in parentheses and you are not limited to the outermost parenthetical
expression.  It can be used to move among sexps at any level within a
nested expression.

Some packages that help with moving among sexps and editing them that
are available via ‘list-packages’ are ‘paredit’, ‘smartparens’,
‘lispy’ (as mentioned by another poster), ‘evil-smartparens’,
‘evil-lispops’, and probably some others.

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 15:35       ` Emanuel Berg
@ 2024-05-11  1:43         ` Drew Adams
  2024-05-11  5:40         ` tomas
  1 sibling, 0 replies; 25+ messages in thread
From: Drew Adams @ 2024-05-11  1:43 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> >> I do not want myself to move from one to another. But to
> >> display for me the line content of the corresponding match
> >> whilst staying at point.
> >
> > Emacs manual, node Matching (Programs > Parentheses >
> > Matching) tells you all you need to know:
> 
> But that only helps if the left (opening) parenthesis is in
> the same window, but the OP asked what do when that isn't
> the case.

No.  Neither of these require the left, matching
paren to be visible in the same window:

1. 'blink-matching-paren'
2. 'show-paren-context-when-offscreen'

> I agree with him it is a pretty bad state, I think it should
> be outputted in the echo area the same that happens when you
> write a right (closing) parenthesis and the left one isn't in
> the window.




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Matching parenthesis for long constructs
  2024-05-09 15:38       ` Emanuel Berg
@ 2024-05-11  4:58         ` Pierre Rouleau
  0 siblings, 0 replies; 25+ messages in thread
From: Pierre Rouleau @ 2024-05-11  4:58 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, May 10, 2024 at 5:45 PM Emanuel Berg <incal@dataswamp.org> wrote:

> Pierre Rouleau wrote:
>
> > in the current window, split that window vertically (C-x 3)
> > as many times are required to see the end of the function
> > inside the other window.
>
> One shouldn't have to do anything for this.
>
> Perhaps a little clarification is required.
The OP was asking about ways to see both ends of a long construct, stating
that
highlighting was not helping much when one end does not show in the same
window.

I suggested a technique the OP could use (and that I have used often):
activating the follow-mode and splitting the window in 2 or more vertical
windows.
With point on the '(' in the left window you might be able to see the end
paren
inside one of the window to the right (with both being highlighted).
It provides more vertical space to see the entire construct.
It might or might not be enough, but it's more than only 1 window.

I was trying to address the OP last question,
   "Are there future possibilities or capabilities to address this ?",
by explaining a technique that can be used now.

The follow-mode has been available for a while (docs states >= 19.31).
It does not require using the option ‘show-paren-context-when-offscreen’,
only available
on  Emacs >= 29.1.


> > Several packages support parenthesis highlighting. Lispy is
> > one of them.
>
> One shouldn't have to install anything for this and it should
> be the default behavior.
>
>
Correct.  You don't need Lispy. paren highlighting is available out of the
box.
I mentioned it, because of a previous post.


> Also highlighting in its basic form does not help if one of
> the parenthesis isn't in the window so cannot be highlighted
> for that very reason, this was very clearly explained by the
> OP in the initial post.
>
> Correct. But see my first comment.


-- 
/Pierre


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 15:35       ` Emanuel Berg
  2024-05-11  1:43         ` Drew Adams
@ 2024-05-11  5:40         ` tomas
  1 sibling, 0 replies; 25+ messages in thread
From: tomas @ 2024-05-11  5:40 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2629 bytes --]

On Thu, May 09, 2024 at 05:35:01PM +0200, Emanuel Berg wrote:

[...]

> I agree with him it is a pretty bad state, I think it should
> be outputted in the echo area the same that happens when you
> write a right (closing) parenthesis and the left one isn't in
> the window.

Folks, I know the OP doesn't take the bother to even look at
the docs (that's why I've given up to engage with them too much).

But from you, Emanuel, I'd expect better. This is straight from
the Emacs docs, "28.4.3 Matching Parentheses", specifically about
Show Paren (minor) mode:

     To customize the mode, type
  ‘M-x customize-group <RET> paren-showing’.  The customizable options
  which control the operation of this mode include:

   • ‘show-paren-highlight-openparen’ controls whether to highlight an
     open paren when point is just before it, and hence its position is
     marked by the cursor anyway.  The default is non-‘nil’ (yes).

   • ‘show-paren-style’ controls whether just the two parens, or also
     the text between them get highlighted.  The valid options here are
     ‘parenthesis’ (show the matching paren), ‘expression’ (highlight
     the entire expression enclosed by the parens), and ‘mixed’
     (highlight the matching paren if it is visible in the window, the
     expression otherwise).

   • ‘show-paren-when-point-inside-paren’, when non-‘nil’, causes
     highlighting also when point is inside of the parentheses.  The
     default is ‘nil’.

   • ‘show-paren-when-point-in-periphery’, when non-‘nil’, causes
     highlighting also when point is in whitespace at the beginning of a
     line and there is a paren at the first or last non-whitespace
     position on the line, or when point is at the end of a line and
     there is a paren at the last non-whitespace position on the line.

   • ‘show-paren-context-when-offscreen’, when non-‘nil’, shows some
     context in the echo area when point is in a closing delimiter and
     the opening delimiter is offscreen.  The context is usually the
     line that contains the opening delimiter, except if the opening
     delimiter is on its own line, in which case the context includes
     the previous nonblank line.

So there /is/ a provision for the "matching delimiter is offscreen"
case. And it is documented, in a place where one might stumble upon
it with a search term nearly identical to this thread's subject.

Now we could go on to discuss whether this is Good Enough or whether
it can be improved, and how.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Matching parenthesis for long constructs
  2024-05-09 18:09           ` Emanuel Berg
@ 2024-05-11  6:27             ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2024-05-11  6:27 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Emanuel Berg <incal@dataswamp.org>
> Date: Thu, 09 May 2024 20:09:24 +0200
> 
> Eli Zaretskii wrote:
> 
> >> Basically the feature is useful only for short expressions.
> >
> > No, not only. Don't stop reading where you stopped, read on.
> > You will find there the description of show-paren-mode and
> > the variables that control how far forward/back Emacs looks
> > for the patching paren, and what it does when the matching
> > paren in outside of the window. There are options there that
> > we believe should fit anyone's taste, just choose what you
> > like best.
> 
> This is good, no idea why it isn't set by default.
> 
> (setq show-paren-context-when-offscreen t)

Because it gets in the way of fast typing, and distracts by flashing
something in the echo area.



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2024-05-11  6:27 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 12:33 Matching parenthesis for long constructs Heime
2024-05-09 14:00 ` Pierre Rouleau
2024-05-09 14:22   ` Heime
2024-05-09 14:48     ` [External] : " Drew Adams
2024-05-09 15:35       ` Emanuel Berg
2024-05-11  1:43         ` Drew Adams
2024-05-11  5:40         ` tomas
2024-05-09 16:58       ` Heime
2024-05-09 17:45         ` Drew Adams
2024-05-09 17:52         ` Eli Zaretskii
2024-05-09 18:09           ` Emanuel Berg
2024-05-11  6:27             ` Eli Zaretskii
2024-05-09 18:24         ` Yuri Khan
2024-05-09 18:29           ` Emanuel Berg
2024-05-09 18:57           ` Heime
2024-05-09 19:45             ` Heime
2024-05-09 19:46             ` Yuri Khan
2024-05-09 20:44               ` Drew Adams
2024-05-09 15:14     ` Pierre Rouleau
2024-05-09 15:38       ` Emanuel Berg
2024-05-11  4:58         ` Pierre Rouleau
2024-05-09 14:24   ` Emanuel Berg
2024-05-09 14:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-05-09 21:49 ` Daniel Martín
2024-05-10 19:38   ` tpeplt

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.