unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tpeplt <tpeplt@gmail.com>
To: "Daniel Martín" <mardani29@yahoo.es>
Cc: Heime <heimeborgia@protonmail.com>,
	 Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Matching parenthesis for long constructs
Date: Fri, 10 May 2024 15:38:39 -0400	[thread overview]
Message-ID: <87wmo1bgow.fsf@gmail.com> (raw)
In-Reply-To: <m1zfsyzmd8.fsf@yahoo.es> ("Daniel Martín"'s message of "Thu, 09 May 2024 23:49:55 +0200")

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.



      reply	other threads:[~2024-05-10 19:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [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=87wmo1bgow.fsf@gmail.com \
    --to=tpeplt@gmail.com \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mardani29@yahoo.es \
    /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.
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).