unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54550: Debugging elisp files
@ 2022-03-24 18:19 goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-25  8:30 ` Robert Pluim
  2022-03-25 16:22 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 6+ messages in thread
From: goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-24 18:19 UTC (permalink / raw)
  To: 54550

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

I am debugging a large file because of the following error,

Warning (initialization): An error occurred while loading ‘/home/goncho/.emacs’:
Invalid read syntax: )

This means that I have a trailing parenthesis. To ensure normal operation, I have to investigate and remove the cause of the error in my initialization file. But I am finding
the task problematic, because using the `--debug-init` option to view a complete error backtrace, has not properly located the problem. It is unfortunate that with just one mark makes the file impossible to parse from start to end. Can emacs be made to handle these things better rather than reject all the file?

The best way to find the problem is to use a binary space partitioning scheme. This means to divide the file in half (comment out one part) or put half in another file. Then check if the error occurs in the code that has not been commented out or resides in the other file. If it does, one has to divide again that part in half and repeat the process until one narrows down to the source of the problem. The process is very tedious.

In texinfo, there exists the "@ignore" and "@end ignore" tags that comment out sections of texinfo code. This makes it much easier to debug texinfo files, because one does not have to constantly comment every line, and with the advantage that one can leave the file almost intact.

I would be grateful if emacs could improve on the user debugging part, so debugging can be made more convenient for users in order to reduce downtime. Am not sure if the manual can describe the procedures to debug in a quicker and easier manner, both for new users of elisp programming and experienced ones who would benefit from fixing problem quite rapidly.

[-- Attachment #2: Type: text/html, Size: 2919 bytes --]

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

* bug#54550: Debugging elisp files
  2022-03-24 18:19 bug#54550: Debugging elisp files goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-25  8:30 ` Robert Pluim
  2022-03-25  8:38   ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-25 16:22 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2022-03-25  8:30 UTC (permalink / raw)
  To: goncholden; +Cc: 54550

>>>>> On Thu, 24 Mar 2022 18:19:13 +0000, goncholden via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:

    >> I am debugging a large file because of the following error,
    >> Warning (initialization): An error occurred while loading ‘/home/goncho/.emacs’:
    >> Invalid read syntax: )

One way to work with this is to put point at the beginning of .emacs
and eval

(while t (forward-sexp))

That will error and tell you at what character position itʼs failing.

    >> In texinfo, there exists the "@ignore" and "@end ignore" tags that
    >> comment out sections of texinfo code. This makes it much easier to
    >> debug texinfo files, because one does not have to constantly comment
    >> every line, and with the advantage that one can leave the file almost
    >> intact.

You can wrap blocks of code in (when nil) to achieve the same.

Robert
-- 





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

* bug#54550: Debugging elisp files
  2022-03-25  8:30 ` Robert Pluim
@ 2022-03-25  8:38   ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-25  8:51     ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-25  8:38 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 54550



Sent with ProtonMail secure email.

------- Original Message -------

On Friday, March 25th, 2022 at 8:30 PM, Robert Pluim <rpluim@gmail.com> wrote:

> > > > > > On Thu, 24 Mar 2022 18:19:13 +0000, goncholden via "Bug reports for GNU Emacs, the Swiss army knife of text editors" bug-gnu-emacs@gnu.org said:
>
> >> I am debugging a large file because of the following error,
>
> >> Warning (initialization): An error occurred while loading ‘/home/goncho/.emacs’:
> >> Invalid read syntax: )
>
> One way to work with this is to put point at the beginning of .emacs
> and eval
>
> (while t (forward-sexp))
>
> That will error and tell you at what character position itʼs failing.

> >> In texinfo, there exists the "@ignore" and "@end ignore" tags that
> >> comment out sections of texinfo code. This makes it much easier to
> >> debug texinfo files, because one does not have to constantly comment
> >> every line, and with the advantage that one can leave the file almost
> >> intact.

> You can wrap blocks of code in (when nil) to achieve the same.
> Robert

I cannot say that the "(when nil)" can include a chunk of defuns though,
only sections within a function.






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

* bug#54550: Debugging elisp files
  2022-03-25  8:38   ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-25  8:51     ` Robert Pluim
  2022-03-25 11:47       ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2022-03-25  8:51 UTC (permalink / raw)
  To: goncholden; +Cc: 54550

>>>>> On Fri, 25 Mar 2022 08:38:31 +0000, goncholden <goncholden@protonmail.com> said:
    >> You can wrap blocks of code in (when nil) to achieve the same.
    >> Robert

    goncholden> I cannot say that the "(when nil)" can include a chunk of defuns though,
    goncholden> only sections within a function.

Have you tried it? `defun' forms are no different from any other lisp
form in that respect.

Robert
-- 





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

* bug#54550: Debugging elisp files
  2022-03-25  8:51     ` Robert Pluim
@ 2022-03-25 11:47       ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 6+ messages in thread
From: goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-25 11:47 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 54550

------- Original Message -------

On Friday, March 25th, 2022 at 8:51 PM, Robert Pluim <rpluim@gmail.com> wrote:

> > > > > > On Fri, 25 Mar 2022 08:38:31 +0000, goncholden goncholden@protonmail.com said:
>
> >> You can wrap blocks of code in (when nil) to achieve the same.
>
> >> Robert
>
> goncholden> I cannot say that the "(when nil)" can include a chunk of defuns though,
>
> goncholden> only sections within a function.
>
> Have you tried it? `defun' forms are no different from any other lisp
> form in that respect.
>
> Robert

That sounds good.





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

* bug#54550: Debugging elisp files
  2022-03-24 18:19 bug#54550: Debugging elisp files goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-25  8:30 ` Robert Pluim
@ 2022-03-25 16:22 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-25 16:22 UTC (permalink / raw)
  To: goncholden; +Cc: 54550

goncholden <goncholden@protonmail.com> writes:

> The best way to find the problem is to use a binary space partitioning
> scheme.

As Robert has already noted, the easiest way to find these errors is to
just go to the start of the file and hold the `C-M-f' key combination
down until Emacs beeps.

However, the error message here is supposed to say what line the error
is on, and it didn't, so I've now fixed that in Emacs 29.

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





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

end of thread, other threads:[~2022-03-25 16:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 18:19 bug#54550: Debugging elisp files goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-25  8:30 ` Robert Pluim
2022-03-25  8:38   ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-25  8:51     ` Robert Pluim
2022-03-25 11:47       ` goncholden via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-25 16:22 ` 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).