diff options
| author | Miles Bader | 2007-07-15 02:05:20 +0000 |
|---|---|---|
| committer | Miles Bader | 2007-07-15 02:05:20 +0000 |
| commit | 7eb1e4534e88a32fe5e549e630fdabf3e062be2b (patch) | |
| tree | 34fc72789f1cfbfeb067cf507f8871c322df300a /src/eval.c | |
| parent | 76d11d2cf9623e9f4c38e8239c4444ffc1fae485 (diff) | |
| parent | 6f8a87c027ebd6f9cfdac5c0df97d651227bec62 (diff) | |
| download | emacs-7eb1e4534e88a32fe5e549e630fdabf3e062be2b.tar.gz emacs-7eb1e4534e88a32fe5e549e630fdabf3e062be2b.zip | |
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 803-813)
- Update from CVS
- Merge from emacs--rel--22
* emacs--rel--22 (patch 51-58)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 233-236)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-25
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 123 |
1 files changed, 71 insertions, 52 deletions
diff --git a/src/eval.c b/src/eval.c index b1bd3daef7a..6de9a5acc99 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -97,6 +97,7 @@ Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag; | |||
| 97 | Lisp_Object Qand_rest, Qand_optional; | 97 | Lisp_Object Qand_rest, Qand_optional; |
| 98 | Lisp_Object Qdebug_on_error; | 98 | Lisp_Object Qdebug_on_error; |
| 99 | Lisp_Object Qdeclare; | 99 | Lisp_Object Qdeclare; |
| 100 | Lisp_Object Qdebug; | ||
| 100 | 101 | ||
| 101 | /* This holds either the symbol `run-hooks' or nil. | 102 | /* This holds either the symbol `run-hooks' or nil. |
| 102 | It is nil at an early stage of startup, and when Emacs | 103 | It is nil at an early stage of startup, and when Emacs |
| @@ -220,7 +221,7 @@ init_eval_once () | |||
| 220 | specpdl_ptr = specpdl; | 221 | specpdl_ptr = specpdl; |
| 221 | /* Don't forget to update docs (lispref node "Local Variables"). */ | 222 | /* Don't forget to update docs (lispref node "Local Variables"). */ |
| 222 | max_specpdl_size = 1000; | 223 | max_specpdl_size = 1000; |
| 223 | max_lisp_eval_depth = 300; | 224 | max_lisp_eval_depth = 400; |
| 224 | 225 | ||
| 225 | Vrun_hooks = Qnil; | 226 | Vrun_hooks = Qnil; |
| 226 | } | 227 | } |
| @@ -433,7 +434,7 @@ usage: (cond CLAUSES...) */) | |||
| 433 | 434 | ||
| 434 | DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, | 435 | DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, |
| 435 | doc: /* Eval BODY forms sequentially and return value of last one. | 436 | doc: /* Eval BODY forms sequentially and return value of last one. |
| 436 | usage: (progn BODY ...) */) | 437 | usage: (progn BODY...) */) |
| 437 | (args) | 438 | (args) |
| 438 | Lisp_Object args; | 439 | Lisp_Object args; |
| 439 | { | 440 | { |
| @@ -1595,8 +1596,7 @@ internal_condition_case_2 (bfun, nargs, args, handlers, hfun) | |||
| 1595 | 1596 | ||
| 1596 | 1597 | ||
| 1597 | static Lisp_Object find_handler_clause P_ ((Lisp_Object, Lisp_Object, | 1598 | static Lisp_Object find_handler_clause P_ ((Lisp_Object, Lisp_Object, |
| 1598 | Lisp_Object, Lisp_Object, | 1599 | Lisp_Object, Lisp_Object)); |
| 1599 | Lisp_Object *)); | ||
| 1600 | 1600 | ||
| 1601 | DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, | 1601 | DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, |
| 1602 | doc: /* Signal an error. Args are ERROR-SYMBOL and associated DATA. | 1602 | doc: /* Signal an error. Args are ERROR-SYMBOL and associated DATA. |
| @@ -1622,7 +1622,6 @@ See also the function `condition-case'. */) | |||
| 1622 | Lisp_Object conditions; | 1622 | Lisp_Object conditions; |
| 1623 | extern int gc_in_progress; | 1623 | extern int gc_in_progress; |
| 1624 | extern int waiting_for_input; | 1624 | extern int waiting_for_input; |
| 1625 | Lisp_Object debugger_value; | ||
| 1626 | Lisp_Object string; | 1625 | Lisp_Object string; |
| 1627 | Lisp_Object real_error_symbol; | 1626 | Lisp_Object real_error_symbol; |
| 1628 | struct backtrace *bp; | 1627 | struct backtrace *bp; |
| @@ -1680,7 +1679,7 @@ See also the function `condition-case'. */) | |||
| 1680 | register Lisp_Object clause; | 1679 | register Lisp_Object clause; |
| 1681 | 1680 | ||
| 1682 | clause = find_handler_clause (handlerlist->handler, conditions, | 1681 | clause = find_handler_clause (handlerlist->handler, conditions, |
| 1683 | error_symbol, data, &debugger_value); | 1682 | error_symbol, data); |
| 1684 | 1683 | ||
| 1685 | if (EQ (clause, Qlambda)) | 1684 | if (EQ (clause, Qlambda)) |
| 1686 | { | 1685 | { |
| @@ -1711,7 +1710,7 @@ See also the function `condition-case'. */) | |||
| 1711 | handlerlist = allhandlers; | 1710 | handlerlist = allhandlers; |
| 1712 | /* If no handler is present now, try to run the debugger, | 1711 | /* If no handler is present now, try to run the debugger, |
| 1713 | and if that fails, throw to top level. */ | 1712 | and if that fails, throw to top level. */ |
| 1714 | find_handler_clause (Qerror, conditions, error_symbol, data, &debugger_value); | 1713 | find_handler_clause (Qerror, conditions, error_symbol, data); |
| 1715 | if (catchlist != 0) | 1714 | if (catchlist != 0) |
| 1716 | Fthrow (Qtop_level, Qt); | 1715 | Fthrow (Qtop_level, Qt); |
| 1717 | 1716 | ||
| @@ -1863,75 +1862,54 @@ skip_debugger (conditions, data) | |||
| 1863 | = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). | 1862 | = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). |
| 1864 | This is for memory-full errors only. | 1863 | This is for memory-full errors only. |
| 1865 | 1864 | ||
| 1866 | Store value returned from debugger into *DEBUGGER_VALUE_PTR. | ||
| 1867 | |||
| 1868 | We need to increase max_specpdl_size temporarily around | 1865 | We need to increase max_specpdl_size temporarily around |
| 1869 | anything we do that can push on the specpdl, so as not to get | 1866 | anything we do that can push on the specpdl, so as not to get |
| 1870 | a second error here in case we're handling specpdl overflow. */ | 1867 | a second error here in case we're handling specpdl overflow. */ |
| 1871 | 1868 | ||
| 1872 | static Lisp_Object | 1869 | static Lisp_Object |
| 1873 | find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr) | 1870 | find_handler_clause (handlers, conditions, sig, data) |
| 1874 | Lisp_Object handlers, conditions, sig, data; | 1871 | Lisp_Object handlers, conditions, sig, data; |
| 1875 | Lisp_Object *debugger_value_ptr; | ||
| 1876 | { | 1872 | { |
| 1877 | register Lisp_Object h; | 1873 | register Lisp_Object h; |
| 1878 | register Lisp_Object tem; | 1874 | register Lisp_Object tem; |
| 1875 | int debugger_called = 0; | ||
| 1876 | int debugger_considered = 0; | ||
| 1879 | 1877 | ||
| 1880 | if (EQ (handlers, Qt)) /* t is used by handlers for all conditions, set up by C code. */ | 1878 | /* t is used by handlers for all conditions, set up by C code. */ |
| 1879 | if (EQ (handlers, Qt)) | ||
| 1881 | return Qt; | 1880 | return Qt; |
| 1881 | |||
| 1882 | /* Don't run the debugger for a memory-full error. | ||
| 1883 | (There is no room in memory to do that!) */ | ||
| 1884 | if (NILP (sig)) | ||
| 1885 | debugger_considered = 1; | ||
| 1886 | |||
| 1882 | /* error is used similarly, but means print an error message | 1887 | /* error is used similarly, but means print an error message |
| 1883 | and run the debugger if that is enabled. */ | 1888 | and run the debugger if that is enabled. */ |
| 1884 | if (EQ (handlers, Qerror) | 1889 | if (EQ (handlers, Qerror) |
| 1885 | || !NILP (Vdebug_on_signal)) /* This says call debugger even if | 1890 | || !NILP (Vdebug_on_signal)) /* This says call debugger even if |
| 1886 | there is a handler. */ | 1891 | there is a handler. */ |
| 1887 | { | 1892 | { |
| 1888 | int debugger_called = 0; | 1893 | if (!NILP (sig) && wants_debugger (Vstack_trace_on_error, conditions)) |
| 1889 | Lisp_Object sig_symbol, combined_data; | ||
| 1890 | /* This is set to 1 if we are handling a memory-full error, | ||
| 1891 | because these must not run the debugger. | ||
| 1892 | (There is no room in memory to do that!) */ | ||
| 1893 | int no_debugger = 0; | ||
| 1894 | |||
| 1895 | if (NILP (sig)) | ||
| 1896 | { | ||
| 1897 | combined_data = data; | ||
| 1898 | sig_symbol = Fcar (data); | ||
| 1899 | no_debugger = 1; | ||
| 1900 | } | ||
| 1901 | else | ||
| 1902 | { | ||
| 1903 | combined_data = Fcons (sig, data); | ||
| 1904 | sig_symbol = sig; | ||
| 1905 | } | ||
| 1906 | |||
| 1907 | if (wants_debugger (Vstack_trace_on_error, conditions)) | ||
| 1908 | { | 1894 | { |
| 1909 | max_specpdl_size++; | 1895 | max_specpdl_size++; |
| 1910 | #ifdef PROTOTYPES | 1896 | #ifdef PROTOTYPES |
| 1911 | internal_with_output_to_temp_buffer ("*Backtrace*", | 1897 | internal_with_output_to_temp_buffer ("*Backtrace*", |
| 1912 | (Lisp_Object (*) (Lisp_Object)) Fbacktrace, | 1898 | (Lisp_Object (*) (Lisp_Object)) Fbacktrace, |
| 1913 | Qnil); | 1899 | Qnil); |
| 1914 | #else | 1900 | #else |
| 1915 | internal_with_output_to_temp_buffer ("*Backtrace*", | 1901 | internal_with_output_to_temp_buffer ("*Backtrace*", |
| 1916 | Fbacktrace, Qnil); | 1902 | Fbacktrace, Qnil); |
| 1917 | #endif | 1903 | #endif |
| 1918 | max_specpdl_size--; | 1904 | max_specpdl_size--; |
| 1919 | } | 1905 | } |
| 1920 | if (! no_debugger | 1906 | |
| 1921 | /* Don't try to run the debugger with interrupts blocked. | 1907 | if (!debugger_considered) |
| 1922 | The editing loop would return anyway. */ | ||
| 1923 | && ! INPUT_BLOCKED_P | ||
| 1924 | && (EQ (sig_symbol, Qquit) | ||
| 1925 | ? debug_on_quit | ||
| 1926 | : wants_debugger (Vdebug_on_error, conditions)) | ||
| 1927 | && ! skip_debugger (conditions, combined_data) | ||
| 1928 | && when_entered_debugger < num_nonmacro_input_events) | ||
| 1929 | { | 1908 | { |
| 1930 | *debugger_value_ptr | 1909 | debugger_considered = 1; |
| 1931 | = call_debugger (Fcons (Qerror, | 1910 | debugger_called = maybe_call_debugger (conditions, sig, data); |
| 1932 | Fcons (combined_data, Qnil))); | ||
| 1933 | debugger_called = 1; | ||
| 1934 | } | 1911 | } |
| 1912 | |||
| 1935 | /* If there is no handler, return saying whether we ran the debugger. */ | 1913 | /* If there is no handler, return saying whether we ran the debugger. */ |
| 1936 | if (EQ (handlers, Qerror)) | 1914 | if (EQ (handlers, Qerror)) |
| 1937 | { | 1915 | { |
| @@ -1940,6 +1918,7 @@ find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr) | |||
| 1940 | return Qt; | 1918 | return Qt; |
| 1941 | } | 1919 | } |
| 1942 | } | 1920 | } |
| 1921 | |||
| 1943 | for (h = handlers; CONSP (h); h = Fcdr (h)) | 1922 | for (h = handlers; CONSP (h); h = Fcdr (h)) |
| 1944 | { | 1923 | { |
| 1945 | Lisp_Object handler, condit; | 1924 | Lisp_Object handler, condit; |
| @@ -1958,18 +1937,55 @@ find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr) | |||
| 1958 | /* Handle a list of condition names in handler HANDLER. */ | 1937 | /* Handle a list of condition names in handler HANDLER. */ |
| 1959 | else if (CONSP (condit)) | 1938 | else if (CONSP (condit)) |
| 1960 | { | 1939 | { |
| 1961 | while (CONSP (condit)) | 1940 | Lisp_Object tail; |
| 1941 | for (tail = condit; CONSP (tail); tail = XCDR (tail)) | ||
| 1962 | { | 1942 | { |
| 1963 | tem = Fmemq (Fcar (condit), conditions); | 1943 | tem = Fmemq (Fcar (tail), conditions); |
| 1964 | if (!NILP (tem)) | 1944 | if (!NILP (tem)) |
| 1965 | return handler; | 1945 | { |
| 1966 | condit = XCDR (condit); | 1946 | /* This handler is going to apply. |
| 1947 | Does it allow the debugger to run first? */ | ||
| 1948 | if (! debugger_considered && !NILP (Fmemq (Qdebug, condit))) | ||
| 1949 | maybe_call_debugger (conditions, sig, data); | ||
| 1950 | return handler; | ||
| 1951 | } | ||
| 1967 | } | 1952 | } |
| 1968 | } | 1953 | } |
| 1969 | } | 1954 | } |
| 1955 | |||
| 1970 | return Qnil; | 1956 | return Qnil; |
| 1971 | } | 1957 | } |
| 1972 | 1958 | ||
| 1959 | /* Call the debugger if calling it is currently enabled for CONDITIONS. | ||
| 1960 | SIG and DATA describe the signal, as in find_handler_clause. */ | ||
| 1961 | |||
| 1962 | int | ||
| 1963 | maybe_call_debugger (conditions, sig, data) | ||
| 1964 | Lisp_Object conditions, sig, data; | ||
| 1965 | { | ||
| 1966 | Lisp_Object combined_data; | ||
| 1967 | |||
| 1968 | combined_data = Fcons (sig, data); | ||
| 1969 | |||
| 1970 | if ( | ||
| 1971 | /* Don't try to run the debugger with interrupts blocked. | ||
| 1972 | The editing loop would return anyway. */ | ||
| 1973 | ! INPUT_BLOCKED_P | ||
| 1974 | /* Does user wants to enter debugger for this kind of error? */ | ||
| 1975 | && (EQ (sig, Qquit) | ||
| 1976 | ? debug_on_quit | ||
| 1977 | : wants_debugger (Vdebug_on_error, conditions)) | ||
| 1978 | && ! skip_debugger (conditions, combined_data) | ||
| 1979 | /* rms: what's this for? */ | ||
| 1980 | && when_entered_debugger < num_nonmacro_input_events) | ||
| 1981 | { | ||
| 1982 | call_debugger (Fcons (Qerror, Fcons (combined_data, Qnil))); | ||
| 1983 | return 1; | ||
| 1984 | } | ||
| 1985 | |||
| 1986 | return 0; | ||
| 1987 | } | ||
| 1988 | |||
| 1973 | /* dump an error message; called like printf */ | 1989 | /* dump an error message; called like printf */ |
| 1974 | 1990 | ||
| 1975 | /* VARARGS 1 */ | 1991 | /* VARARGS 1 */ |
| @@ -3610,6 +3626,9 @@ before making `inhibit-quit' nil. */); | |||
| 3610 | Qand_optional = intern ("&optional"); | 3626 | Qand_optional = intern ("&optional"); |
| 3611 | staticpro (&Qand_optional); | 3627 | staticpro (&Qand_optional); |
| 3612 | 3628 | ||
| 3629 | Qdebug = intern ("debug"); | ||
| 3630 | staticpro (&Qdebug); | ||
| 3631 | |||
| 3613 | DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error, | 3632 | DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error, |
| 3614 | doc: /* *Non-nil means errors display a backtrace buffer. | 3633 | doc: /* *Non-nil means errors display a backtrace buffer. |
| 3615 | More precisely, this happens for any error that is handled | 3634 | More precisely, this happens for any error that is handled |