From: Drew Adams <drew.adams@oracle.com>
To: "Andreas Röhler" <andreas.roehler@easy-emacs.de>,
"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : forward-sexp
Date: Fri, 11 Aug 2023 20:01:06 +0000 [thread overview]
Message-ID: <SJ0PR10MB548859AB2024EB5AB4C727D6F310A@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <d422a471-9188-69bb-247b-a0a86328bf8a@easy-emacs.de>
> > The syntactic definition of "sexp" depends on the context, e.g., the
> > current major mode. Without knowing how a "sexp" is defined in your
> > context, we can't help much. That said, trying it in a Lisp mode tells
> > me that an error is raised when I try it at the beginning of the
> > second line, because: Debugger entered--Lisp error: (scan-error
> > "Unbalanced parentheses" 450 459) scan-sexps(450 1) forward-sexp(1)
> > funcall-interactively(forward-sexp 1) call-interactively(forward-sexp
> > nil nil) command-execute(forward-sexp) IOW, the `(' char isn't
> > balanced with a `)' char, so parsing to the end of the `[' sexp isn't
> > possible.
>
> let assume fundamental mode, cursor at opening bracket: what puzzles me,
>
> with [ asdf ] it recognizes the opening bracket.
>
> In such a case, it should not look inside, just travel onto the closing one.
>
> But with [(&asdf] it fails.
As I said, it all depends on how `forward-sexp' is defined in the current mode, which essentially means it depends on what constitutes a sexp.
With point before the second [ or after the first ], `forward-sexp' raises the error (user-error "No next sexp"):
Debugger entered--Lisp error: (user-error "No next sexp")
user-error("No next sexp")
forward-sexp(1 10)
funcall-interactively(forward-sexp 1 10)
command-execute(forward-sexp)
The code defining `forward-sexp' has this, for interactive use:
(condition-case _
(forward-sexp arg nil)
(scan-error (user-error (if (> arg 0)
"No next sexp"
"No previous sexp"))))
The Elisp manual, node `Motion Via Parsing', says this about `scan-error':
If the scan reaches the beginning or end of the accessible part of
the buffer before it has scanned over COUNT parenthetical
groupings, the return value is ‘nil’ if the depth at that point is
zero; if the depth is non-zero, a ‘scan-error’ error is signaled.
So it seems that the `(' starts a "parenthetical grouping", which has no end.
IOW, even `fundamental-mode' recognizes parentheses as paired delimiters.
next prev parent reply other threads:[~2023-08-11 20:01 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 17:23 forward-sexp Andreas Röhler
2023-08-11 17:43 ` [External] : forward-sexp Drew Adams
2023-08-11 17:58 ` Emanuel Berg
2023-08-11 19:20 ` Andreas Röhler
2023-08-11 19:47 ` Pierre Rouleau
2023-08-11 20:02 ` Andreas Röhler
2023-08-11 20:07 ` Drew Adams
2023-08-11 20:09 ` Pierre Rouleau
2023-08-11 20:17 ` Emanuel Berg
2023-08-11 20:14 ` Emanuel Berg
2023-08-12 20:41 ` Drew Adams
2023-08-12 22:23 ` Emanuel Berg
2023-08-13 14:02 ` Pierre Rouleau
2023-08-13 15:42 ` Drew Adams
2023-08-13 16:45 ` Pierre Rouleau
2023-08-20 4:08 ` Emanuel Berg
2023-08-20 4:04 ` Emanuel Berg
2023-08-20 3:50 ` Emanuel Berg
2023-08-13 15:08 ` Drew Adams
2023-08-11 20:23 ` Drew Adams
2023-08-11 20:30 ` Emanuel Berg
2023-08-12 20:42 ` Drew Adams
2023-08-12 22:12 ` Emanuel Berg
2023-08-13 15:08 ` Drew Adams
2023-08-12 6:44 ` Andreas Röhler
2023-08-11 20:09 ` Emanuel Berg
2023-08-11 20:01 ` Drew Adams [this message]
2023-08-11 20:06 ` Emanuel Berg
2023-08-12 20:41 ` Drew Adams
2023-08-12 22:14 ` Emanuel Berg
2023-08-13 6:53 ` Andreas Röhler
2023-08-13 6:57 ` Eli Zaretskii
2023-08-13 15:04 ` Drew Adams
2023-08-20 4:48 ` Emanuel Berg
2023-09-09 7:22 ` Andreas Röhler
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=SJ0PR10MB548859AB2024EB5AB4C727D6F310A@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=andreas.roehler@easy-emacs.de \
--cc=help-gnu-emacs@gnu.org \
/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).