unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master e38e7b7: Make syntax errors say the line/column they appear at
       [not found] ` <20210201161425.6B83A20DFD@vcs0.savannah.gnu.org>
@ 2021-02-01 19:47   ` Stefan Monnier
  2021-02-02  8:34     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2021-02-01 19:47 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Ingebrigtsen

> +static AVOID
> +invalid_syntax_lisp (Lisp_Object s, Lisp_Object readcharfun)
> +{
> +  if (BUFFERP (readcharfun))
> +    {
> +      xsignal1 (Qinvalid_read_syntax,
> +		CALLN (Fformat, build_string ("%s (line %d, column %d)"),
> +		       s,
> +		       /* We should already be in the readcharfun
> +			  buffer when this error is called, so no need
> +			  to switch to it first. */
> +		       make_fixnum (count_lines (BEGV_BYTE, PT_BYTE) + 1),
> +		       make_fixnum (current_column ())));

Including this info is great, thanks.

But, FWIW, I'd much rather that the error object contains "raw data"
rather than "human-readable" data.  I.e. something like:

    xsignal2 (Qinvalid_read_syntax, s, PT);

and then convert the buf-pos to line+column later on, when the error
is displayed.
[ And if we don't have any ready-made place where we can put
  this display-time conversion, then we should probably change that
  as well.  ]


        Stefan




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

* Re: master e38e7b7: Make syntax errors say the line/column they appear at
  2021-02-01 19:47   ` master e38e7b7: Make syntax errors say the line/column they appear at Stefan Monnier
@ 2021-02-02  8:34     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-02  8:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> But, FWIW, I'd much rather that the error object contains "raw data"
> rather than "human-readable" data.  I.e. something like:
>
>     xsignal2 (Qinvalid_read_syntax, s, PT);
>
> and then convert the buf-pos to line+column later on, when the error
> is displayed.

Good idea; now fixed.

> [ And if we don't have any ready-made place where we can put
>   this display-time conversion, then we should probably change that
>   as well.  ]

We have the same thing with

forward-sexp: Scan error: "Containing expression ends prematurely", 373, 374

which is pretty cryptic, but `M-f' says

user-error: No next sexp

A general display conversion thing would be nice, but I guess some of
the conversions would be context dependent?  The invalid-read-syntax
line/column one wouldn't be, I think...

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



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

end of thread, other threads:[~2021-02-02  8:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210201161423.6054.53972@vcs0.savannah.gnu.org>
     [not found] ` <20210201161425.6B83A20DFD@vcs0.savannah.gnu.org>
2021-02-01 19:47   ` master e38e7b7: Make syntax errors say the line/column they appear at Stefan Monnier
2021-02-02  8:34     ` Lars Ingebrigtsen

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