unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Vasilij Schneidermann <v.schneidermann@gmail.com>
To: "Clément Pit--Claudel" <clement.pit@gmail.com>, 24514@debbugs.gnu.org
Subject: bug#24514: 24.5; [WIP][PATCH] Lispy backtraces
Date: Fri, 23 Sep 2016 09:51:16 +0200	[thread overview]
Message-ID: <20160923075116.GA612@odonien.localdomain> (raw)
In-Reply-To: <98fbb582-3da4-bd83-a2e9-e341dd7f6140@gmail.com>

> This looks great! I love it.  And the patch looks very clean, too.

Thanks!  I've updated the patch after a bit more testing.  The extra
debug line happened because the search in debug.el did actually search
for a `debug' call, so `(search-forward "\  (debug")` would match a call
to `debug-foo` as well.  Assuming there will always be extra args, this
can be solved by appending a space to the search string.  In case this
is not true, I'll have to go for `re-search-forward` to handle a
`(debug)` as well.  The other problem was that there were extraneous
spaces at times, this can be handled by making the line that prepends an
argument with a space unconditional.

> But it scares me a bit.  Some tools do depend on e.g. trimming a
> backtrace after printing it.  Does edebug work with your patch, for
> example?

Yes, it does.  However, you're raising a good point here.  I would
expect such a change to neither break Emacs core nor any of the bundled
Emacs Lisp code.  Guarantees about popular external code are hard to
make, but communicating the change with the respective authors and
maintainers should do the trick.  What I've initially asked for is
whether there might be any good reason for *not* doing things this way.

I've grepped the 24.5 sources and most usage of `backtrace' appears to
be of diagnostic nature.  The only thing other than `debug.el`
manipulating them is `edebug-backtrace' which I've never heard of
before.  I'll take a better look at its sources for my next revision of
the patch.

> I'm not sure what the right way to transition is.  Maybe Emacs should
> let Lisp programs access the backtraces in a structured way, and then
> backtrace printing would only be a user-facing facility (programs
> wouldn't use the textual representation).

There is actually a way to do this, simply use `backtrace-frame' with an
increasing integer argument until it returns nil:

    (let ((frame t) ; dummy value to kick-start the loop
          (i 0))
      (while frame
        (setq frame (backtrace-frame i))
        (message "%S" frame)
        (setq i (1+ i))))

This feature is used in `ert.el` to save a backtrace and reconstruct it.
Perhaps all current users of `backtrace' that rely on its current
representation should be using `backtrace-frame' instead?





  reply	other threads:[~2016-09-23  7:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 23:14 bug#24514: 24.5; [WIP][PATCH] Lispy backtraces Vasilij Schneidermann
2016-09-23  2:22 ` Clément Pit--Claudel
2016-09-23  7:51   ` Vasilij Schneidermann [this message]
2016-09-23 13:22     ` Clément Pit--Claudel
2016-09-23  8:12   ` Vasilij Schneidermann
2016-09-23  9:44   ` Eli Zaretskii
2016-09-23  9:55     ` bug#24515: " Vasilij Schneidermann
2016-09-23 10:06       ` Eli Zaretskii
2016-09-23 13:25       ` Clément Pit--Claudel
2016-09-23 16:33         ` John Wiegley
     [not found] ` <mailman.2864.1474586229.22741.bug-gnu-emacs@gnu.org>
2016-09-23 18:47   ` Alan Mackenzie
2016-09-23 20:43 ` Richard Stallman
2016-09-27 19:16 ` Vasilij Schneidermann
2016-09-28 15:28   ` Eli Zaretskii
2016-09-30 10:29     ` Vasilij Schneidermann
2016-09-30 13:26       ` Eli Zaretskii
2016-10-12 15:34   ` Vasilij Schneidermann

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=20160923075116.GA612@odonien.localdomain \
    --to=v.schneidermann@gmail.com \
    --cc=24514@debbugs.gnu.org \
    --cc=clement.pit@gmail.com \
    /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).