[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Feature request: A way to get a traceback to a buffer or a string
From: |
Lennart Borgman (gmail) |
Subject: |
Feature request: A way to get a traceback to a buffer or a string |
Date: |
Tue, 11 Dec 2007 01:56:19 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 |
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))))))
- Feature request: A way to get a traceback to a buffer or a string,
Lennart Borgman (gmail) <=