diff lisp/cmdloop.el @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents 023b83f4e54b
children 37bdd24225ef
line wrap: on
line diff
--- a/lisp/cmdloop.el	Fri Mar 08 13:33:14 2002 +0000
+++ b/lisp/cmdloop.el	Wed Mar 13 08:54:06 2002 +0000
@@ -1,6 +1,7 @@
 ;;; cmdloop.el --- support functions for the top-level command loop.
 
 ;; Copyright (C) 1992-4, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 2001 Ben Wing.
  
 ;; Author: Richard Mlynarik
 ;; Date: 8-Jul-92
@@ -129,9 +130,23 @@
   :type 'boolean
   :group 'editing-basics)
 
+(defvar breakpoint-on-error nil
+  "Break into the C debugger when an unhandled error occurs noninteractively.
+This happens by calling `force-debugging-signal'.  This can be very
+useful when debugging noninteractive errors in tricky situations,
+e.g. makefiles, since you can set this variable using an environment
+variable, like this:
+
+\(using csh)      setenv XEMACSDEBUG '(setq breakpoint-on-error t)'
+\(using bash)     export XEMACSDEBUG='(setq breakpoint-on-error t)'
+
+XEMACSDEBUG is also useful for setting `stack-trace-on-error'. which will
+display a Lisp backtrace when exiting noninteractively due to an unhandled
+error.")
+
 (defun command-error (error-object)
-  (let* ((old-debug-on-error debug-on-error)
-	 (inhibit-quit t)
+  ;; if you want a backtrace before exiting, set stack-trace-on-error.
+  (let* ((inhibit-quit t)
 	 (debug-on-error nil)
 	 (etype (car-safe error-object)))
     (setq quit-flag nil)
@@ -162,11 +177,8 @@
 
     (if (noninteractive)
         (progn
-	  (if old-debug-on-error
-	      (progn
-		(message "Backtrace:\n\n")
-		(backtrace)
-		(message "\n")))
+	  (when breakpoint-on-error
+	    (force-debugging-signal))
           (message "%s exiting\n." emacs-program-name)
           (kill-emacs -1)))
     t))