unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: ndame <emacsuser@freemail.hu>
Cc: 36970@debbugs.gnu.org
Subject: bug#36970: 26.2; invalid-read-syntax could print the location of the error
Date: Sat, 30 Jan 2021 08:54:21 +0100	[thread overview]
Message-ID: <87tuqyx3ki.fsf@gnus.org> (raw)
In-Reply-To: <Axwg9w.YgkU5DyrorMt.sdmtj9lTEHqHgAJeA1@freemail.hu> (ndame's message of "Thu, 8 Aug 2019 10:27:55 +0200 (CEST)")

ndame <emacsuser@freemail.hu> writes:

> It only says:
>
>     (invalid-read-syntax ". in wrong context")
>
> It could also print the character location or even the line number and
> the position in the line to make it easy to find the error.

Poking around in read1 and friends, this doesn't seem very difficult to
implement -- the errors are signalled from the invalid_syntax function.

The wrinkle is that we may be reading from a string or something else
based on readcharfun.  However, the common case is reading from a
buffer, and we could improve the error message there.

So my idea here would be to change all the calls that are like this:

	      invalid_syntax (". in wrong context");

into

	      invalid_syntax (". in wrong context", readcharfun);

and then, in that function do

  if (BUFFERP (readcharfun))
    make_string_based_on_point ()

Since point is at the problematic element, that could just do a
Fcount_lines/Fcurrent_column to get the line number/column number,
presumably.

Before starting to hack away at this, does anybody see any problems with
this approach?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  reply	other threads:[~2021-01-30  7:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08  8:27 bug#36970: 26.2; invalid-read-syntax could print the location of the error ndame
2021-01-30  7:54 ` Lars Ingebrigtsen [this message]
2021-01-31  9:14   ` Lars Ingebrigtsen
2021-01-31 10:15     ` Lars Ingebrigtsen
2021-01-31 14:57     ` Eli Zaretskii
2021-02-01  8:40       ` Lars Ingebrigtsen
2021-02-01 15:06         ` Eli Zaretskii
2021-02-01 16:10           ` Lars Ingebrigtsen

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=87tuqyx3ki.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=36970@debbugs.gnu.org \
    --cc=emacsuser@freemail.hu \
    /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.
Code repositories for project(s) associated with this public inbox

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

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).