all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Feature request: A way to get a traceback to a buffer or a string
@ 2007-12-11  0:56 Lennart Borgman (gmail)
  2007-12-11 10:12 ` Lennart Borgman (gmail)
  2007-12-11 19:01 ` Richard Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-12-11  0:56 UTC (permalink / raw)
  To: Emacs Devel

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

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

end of thread, other threads:[~2007-12-12 22:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11  0:56 Feature request: A way to get a traceback to a buffer or a string Lennart Borgman (gmail)
2007-12-11 10:12 ` 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.