unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: Feature request: A way to get a traceback to a buffer or a string
Date: Tue, 11 Dec 2007 01:56:19 +0100	[thread overview]
Message-ID: <475DE033.6060403@gmail.com> (raw)

In some situations you may know that a function call will cause an 
error. You may then want to get a traceback from this particular call, 
without user intervention. I have attached a macro that can give this. I 
would find it practical if this were included in Emacs.

(defmacro mumamo-get-backtrace (bodyform)
   "Evaluate BODYFORM, return backtrace as a string.
If there is an error in BODYFORM then return the backtrace as a
string, otherwise return nil."
   `(let ((debugger (lambda (&rest debugger-args)
                      (setq debugger-ret (with-output-to-string 
(backtrace)))))
          (debug-on-error t)
          (debug-on-signal t)
          (debugger-ret nil))
      (condition-case err
          (progn
            ,bodyform
            nil)
        (error
         (let* ((errmsg (error-message-string err))
                (debugger-lines (split-string debugger-ret "\n"))
                (dbg-ret (mapconcat 'identity (nthcdr 6 debugger-lines) 
"\n")))
           (concat errmsg "\n" dbg-ret))))))

             reply	other threads:[~2007-12-11  0:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-11  0:56 Lennart Borgman (gmail) [this message]
2007-12-11 10:12 ` Feature request: A way to get a traceback to a buffer or a string Lennart Borgman (gmail)
2007-12-11 19:01 ` Richard Stallman
2007-12-12  1:24   ` Lennart Borgman (gmail)
2007-12-12 12:53     ` Johan Bockgård
2007-12-12 15:21       ` Stefan Monnier
2007-12-12 16:52         ` Lennart Borgman (gmail)
2007-12-12 22:52     ` Richard Stallman

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=475DE033.6060403@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=emacs-devel@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.
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).