Mercurial > hg > xemacs-beta
comparison src/emacs.c @ 20:859a2309aef8 r19-15b93
Import from CVS: tag r19-15b93
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:50:05 +0200 |
parents | 0293115a14e9 |
children | e04119814345 |
comparison
equal
deleted
inserted
replaced
19:ac1f612d5250 | 20:859a2309aef8 |
---|---|
61 #include <default_acl.h> | 61 #include <default_acl.h> |
62 #endif | 62 #endif |
63 #endif | 63 #endif |
64 | 64 |
65 extern void memory_warnings (void *, void (*warnfun) (CONST char *)); | 65 extern void memory_warnings (void *, void (*warnfun) (CONST char *)); |
66 | |
67 #ifndef SYSTEM_MALLOC | |
68 extern void *(*__malloc_hook)(size_t); | |
69 extern void *(*__realloc_hook)(void *, size_t); | |
70 extern void (*__free_hook)(void *); | |
71 #endif /* not SYSTEM_MALLOC */ | |
66 | 72 |
67 /* Command line args from shell, as list of strings */ | 73 /* Command line args from shell, as list of strings */ |
68 Lisp_Object Vcommand_line_args; | 74 Lisp_Object Vcommand_line_args; |
69 | 75 |
70 /* Set nonzero after XEmacs has started up the first time. | 76 /* Set nonzero after XEmacs has started up the first time. |
334 initial_argc = argc; | 340 initial_argc = argc; |
335 | 341 |
336 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args); | 342 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args); |
337 } | 343 } |
338 | 344 |
339 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0 /* | 345 DEFUN ("invocation-name", Finvocation_name, 0, 0, 0, /* |
340 Return the program name that was used to run XEmacs. | 346 Return the program name that was used to run XEmacs. |
341 Any directory names are omitted. | 347 Any directory names are omitted. |
342 */ ) | 348 */ |
343 () | 349 ()) |
344 { | 350 { |
345 return Fcopy_sequence (Vinvocation_name); | 351 return Fcopy_sequence (Vinvocation_name); |
346 } | 352 } |
347 | 353 |
348 DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory, 0, 0, 0 /* | 354 DEFUN ("invocation-directory", Finvocation_directory, 0, 0, 0, /* |
349 Return the directory name in which the Emacs executable was located. | 355 Return the directory name in which the Emacs executable was located. |
350 */ ) | 356 */ |
351 () | 357 ()) |
352 { | 358 { |
353 return Fcopy_sequence (Vinvocation_directory); | 359 return Fcopy_sequence (Vinvocation_directory); |
354 } | 360 } |
355 | 361 |
356 | 362 |
429 { | 435 { |
430 char stack_bottom_variable; | 436 char stack_bottom_variable; |
431 int skip_args = 0; | 437 int skip_args = 0; |
432 Lisp_Object load_me; | 438 Lisp_Object load_me; |
433 int inhibit_window_system; | 439 int inhibit_window_system; |
434 | |
435 noninteractive = 0; | |
436 | |
437 #ifdef NeXT | 440 #ifdef NeXT |
438 extern int malloc_cookie; | 441 extern int malloc_cookie; |
439 | 442 #endif |
443 | |
444 #ifndef SYSTEM_MALLOC | |
445 /* Make sure that any libraries we link against haven't installed a | |
446 hook for a gmalloc of a potentially incompatible version. */ | |
447 __malloc_hook = NULL; | |
448 __realloc_hook = NULL; | |
449 __free_hook = NULL; | |
450 #endif /* not SYSTEM_MALLOC */ | |
451 | |
452 noninteractive = 0; | |
453 | |
454 #ifdef NeXT | |
440 /* 19-Jun-1995 -baw | 455 /* 19-Jun-1995 -baw |
441 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman | 456 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman |
442 * <cedman@princeton.edu>. Note that even Carl doesn't know what this | 457 * <cedman@princeton.edu>. Note that even Carl doesn't know what this |
443 * does; it was provided by NeXT, and it presumable makes NS's mallocator | 458 * does; it was provided by NeXT, and it presumable makes NS's mallocator |
444 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in | 459 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in |
658 /* If there is a non-empty environment var DISPLAY, set | 673 /* If there is a non-empty environment var DISPLAY, set |
659 `display_use', but not `display_arg', which is only to be set | 674 `display_use', but not `display_arg', which is only to be set |
660 if the display was specified on the command line. */ | 675 if the display was specified on the command line. */ |
661 if ((dpy = getenv ("DISPLAY")) && dpy[0]) | 676 if ((dpy = getenv ("DISPLAY")) && dpy[0]) |
662 display_use = "x"; | 677 display_use = "x"; |
663 | 678 |
664 #endif /* HAVE_X_WINDOWS */ | 679 #endif /* HAVE_X_WINDOWS */ |
665 | 680 |
666 #ifdef HAVE_NEXTSTEP | 681 #ifdef HAVE_NEXTSTEP |
667 if (argmatch (argv, argc, "-NXHost", 0, 6, 0, &skip_args) || | 682 if (argmatch (argv, argc, "-NXHost", 0, 6, 0, &skip_args) || |
668 argmatch (argv, argc, "-MachLaunch", 0, 9, 0, &skip_args)) | 683 argmatch (argv, argc, "-MachLaunch", 0, 9, 0, &skip_args)) |
1390 /* This never returns. */ | 1405 /* This never returns. */ |
1391 initial_command_loop (load_me); | 1406 initial_command_loop (load_me); |
1392 /* NOTREACHED */ | 1407 /* NOTREACHED */ |
1393 } | 1408 } |
1394 | 1409 |
1395 | 1410 |
1396 /* Sort the args so we can find the most important ones | 1411 /* Sort the args so we can find the most important ones |
1397 at the beginning of argv. */ | 1412 at the beginning of argv. */ |
1398 | 1413 |
1399 /* First, here's a table of all the standard options. */ | 1414 /* First, here's a table of all the standard options. */ |
1400 | 1415 |
1460 { "-r", "--reverse-video", 5, 0 }, | 1475 { "-r", "--reverse-video", 5, 0 }, |
1461 { "-rv", 0, 5, 0 }, | 1476 { "-rv", 0, 5, 0 }, |
1462 { "-reverse", 0, 5, 0 }, | 1477 { "-reverse", 0, 5, 0 }, |
1463 { "-hb", "--horizontal-scroll-bars", 5, 0 }, | 1478 { "-hb", "--horizontal-scroll-bars", 5, 0 }, |
1464 { "-vb", "--vertical-scroll-bars", 5, 0 }, | 1479 { "-vb", "--vertical-scroll-bars", 5, 0 }, |
1465 | 1480 |
1466 /* These have the same priority as ordinary file name args, | 1481 /* These have the same priority as ordinary file name args, |
1467 so they are not reordered with respect to those. */ | 1482 so they are not reordered with respect to those. */ |
1468 { "-L", "--directory", 0, 1 }, | 1483 { "-L", "--directory", 0, 1 }, |
1469 { "-directory", 0, 0, 1 }, | 1484 { "-directory", 0, 0, 1 }, |
1470 { "-l", "--load", 0, 1 }, | 1485 { "-l", "--load", 0, 1 }, |
1583 } | 1598 } |
1584 /* Skip option arguments--they are tied to the options. */ | 1599 /* Skip option arguments--they are tied to the options. */ |
1585 if (options[from] > 0) | 1600 if (options[from] > 0) |
1586 from += options[from]; | 1601 from += options[from]; |
1587 } | 1602 } |
1588 | 1603 |
1589 if (best < 0) | 1604 if (best < 0) |
1590 abort (); | 1605 abort (); |
1591 | 1606 |
1592 /* Copy the highest priority remaining option, with its args, to NEW. */ | 1607 /* Copy the highest priority remaining option, with its args, to NEW. */ |
1593 new[to++] = argv[best]; | 1608 new[to++] = argv[best]; |
1611 static int run_temacs_argv_size; | 1626 static int run_temacs_argv_size; |
1612 static int run_temacs_args_size; | 1627 static int run_temacs_args_size; |
1613 | 1628 |
1614 extern int gc_in_progress; | 1629 extern int gc_in_progress; |
1615 | 1630 |
1616 DEFUN ("running-temacs-p", | 1631 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /* |
1617 Frunning_temacs_p, Srunning_temacs_p, 0, 0, 0 /* | |
1618 True if running temacs. This means we are in the dumping stage. | 1632 True if running temacs. This means we are in the dumping stage. |
1619 This is false during normal execution of the `xemacs' program, and | 1633 This is false during normal execution of the `xemacs' program, and |
1620 becomes false once `run-emacs-from-temacs' is run. | 1634 becomes false once `run-emacs-from-temacs' is run. |
1621 */ ) | 1635 */ |
1622 () | 1636 ()) |
1623 { | 1637 { |
1624 return run_temacs_argc >= 0 ? Qt : Qnil; | 1638 return run_temacs_argc >= 0 ? Qt : Qnil; |
1625 } | 1639 } |
1626 | 1640 |
1627 DEFUN ("run-emacs-from-temacs", | 1641 DEFUN ("run-emacs-from-temacs", Frun_emacs_from_temacs, 0, MANY, 0, /* |
1628 Frun_emacs_from_temacs, Srun_emacs_from_temacs, 0, MANY, 0 /* | |
1629 Do not call this. It will reinitialize your XEmacs. You'll be sorry. | 1642 Do not call this. It will reinitialize your XEmacs. You'll be sorry. |
1630 */ ) | 1643 */ |
1631 /* If this function is called from startup.el, it will be possible to run | 1644 /* If this function is called from startup.el, it will be possible to run |
1632 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead | 1645 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead |
1633 of having to dump an emacs and then run that (when debugging emacs itself, | 1646 of having to dump an emacs and then run that (when debugging emacs itself, |
1634 this can be much faster). [Actually, the speed difference isn't that | 1647 this can be much faster)). [Actually, the speed difference isn't that |
1635 much as long as your filesystem is local, and you don't end up with | 1648 much as long as your filesystem is local, and you don't end up with |
1636 a dumped version in case you want to rerun it. This function is most | 1649 a dumped version in case you want to rerun it. This function is most |
1637 useful when used as part of the `make all-elc' command. --ben] | 1650 useful when used as part of the `make all-elc' command. --ben] |
1638 This will \"restart\" emacs with the specified command-line arguments. | 1651 This will \"restart\" emacs with the specified command-line arguments. |
1639 */ | 1652 */ |
1640 (nargs, args) | 1653 (int nargs, Lisp_Object *args)) |
1641 int nargs; | |
1642 Lisp_Object *args; | |
1643 { | 1654 { |
1644 int ac; | 1655 int ac; |
1645 Extbyte *wampum; | 1656 Extbyte *wampum; |
1646 int namesize; | 1657 int namesize; |
1647 int total_len; | 1658 int total_len; |
1724 several people using this stuff. We've compared versions on | 1735 several people using this stuff. We've compared versions on |
1725 everything we can think of. We can find no difference. | 1736 everything we can think of. We can find no difference. |
1726 However, on both my systems environ is a plain old global | 1737 However, on both my systems environ is a plain old global |
1727 variable initialized to zero. _environ is the one that | 1738 variable initialized to zero. _environ is the one that |
1728 contains pointers to the actual environment. | 1739 contains pointers to the actual environment. |
1729 | 1740 |
1730 Since we can't figure out the difference (and we're hours | 1741 Since we can't figure out the difference (and we're hours |
1731 away from a release), this takes a very cowardly approach and | 1742 away from a release), this takes a very cowardly approach and |
1732 is bracketed with both a system specific preprocessor test | 1743 is bracketed with both a system specific preprocessor test |
1733 and a runtime "do you have this problem" test | 1744 and a runtime "do you have this problem" test |
1734 | 1745 |
1735 06/20/96 robertl@dgii.com */ | 1746 06/20/96 robertl@dgii.com */ |
1736 { | 1747 { |
1737 extern char *_environ; | 1748 extern char *_environ; |
1738 if ((unsigned) environ == 0) | 1749 if ((unsigned) environ == 0) |
1739 environ=_environ; | 1750 environ=_environ; |
1745 | 1756 |
1746 main_1 (vol_argc, vol_argv, vol_envp); | 1757 main_1 (vol_argc, vol_argv, vol_envp); |
1747 } | 1758 } |
1748 | 1759 |
1749 | 1760 |
1750 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P" /* | 1761 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /* |
1751 Exit the XEmacs job and kill it. Ask for confirmation, without argument. | 1762 Exit the XEmacs job and kill it. Ask for confirmation, without argument. |
1752 If ARG is an integer, return ARG as the exit program code. | 1763 If ARG is an integer, return ARG as the exit program code. |
1753 If ARG is a string, stuff it as keyboard input. | 1764 If ARG is a string, stuff it as keyboard input. |
1754 | 1765 |
1755 The value of `kill-emacs-hook', if not void, | 1766 The value of `kill-emacs-hook', if not void, |
1756 is a list of functions (of no args), | 1767 is a list of functions (of no args), |
1757 all of which are called before XEmacs is actually killed. | 1768 all of which are called before XEmacs is actually killed. |
1758 */ ) | 1769 */ |
1759 (arg) | 1770 (arg)) |
1760 Lisp_Object arg; | |
1761 { | 1771 { |
1762 /* This function can GC */ | 1772 /* This function can GC */ |
1763 struct gcpro gcpro1; | 1773 struct gcpro gcpro1; |
1764 | 1774 |
1765 GCPRO1 (arg); | 1775 GCPRO1 (arg); |
1918 | 1928 |
1919 extern char my_edata[]; | 1929 extern char my_edata[]; |
1920 | 1930 |
1921 #ifdef HAVE_SHM | 1931 #ifdef HAVE_SHM |
1922 | 1932 |
1923 DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0 /* | 1933 DEFUN ("dump-emacs-data", Fdump_emacs_data, 1, 1, 0, /* |
1924 Dump current state of XEmacs into data file FILENAME. | 1934 Dump current state of XEmacs into data file FILENAME. |
1925 This function exists on systems that use HAVE_SHM. | 1935 This function exists on systems that use HAVE_SHM. |
1926 */ ) | 1936 */ |
1927 (intoname) | 1937 (intoname)) |
1928 Lisp_Object intoname; | |
1929 { | 1938 { |
1930 /* This function can GC */ | 1939 /* This function can GC */ |
1931 int opurify; | 1940 int opurify; |
1932 struct gcpro gcpro1; | 1941 struct gcpro gcpro1; |
1933 GCPRO1 (intoname); | 1942 GCPRO1 (intoname); |
1957 return Qnil; | 1966 return Qnil; |
1958 } | 1967 } |
1959 | 1968 |
1960 #else /* not HAVE_SHM */ | 1969 #else /* not HAVE_SHM */ |
1961 | 1970 |
1962 DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0 /* | 1971 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /* |
1963 Dump current state of XEmacs into executable file FILENAME. | 1972 Dump current state of XEmacs into executable file FILENAME. |
1964 Take symbols from SYMFILE (presumably the file you executed to run XEmacs). | 1973 Take symbols from SYMFILE (presumably the file you executed to run XEmacs). |
1965 This is used in the file `loadup.el' when building XEmacs. | 1974 This is used in the file `loadup.el' when building XEmacs. |
1966 | 1975 |
1967 Remember to set `command-line-processed' to nil before dumping | 1976 Remember to set `command-line-processed' to nil before dumping |
1968 if you want the dumped XEmacs to process its command line | 1977 if you want the dumped XEmacs to process its command line |
1969 and announce itself normally when it is run. | 1978 and announce itself normally when it is run. |
1970 */ ) | 1979 */ |
1971 (intoname, symname) | 1980 (intoname, symname)) |
1972 Lisp_Object intoname, symname; | |
1973 { | 1981 { |
1974 /* This function can GC */ | 1982 /* This function can GC */ |
1975 struct gcpro gcpro1, gcpro2; | 1983 struct gcpro gcpro1, gcpro2; |
1976 int opurify; | 1984 int opurify; |
1977 | 1985 |
2097 break; | 2105 break; |
2098 } | 2106 } |
2099 return Fnreverse (lpath); | 2107 return Fnreverse (lpath); |
2100 } | 2108 } |
2101 | 2109 |
2102 DEFUN ("noninteractive", Fnoninteractive, Snoninteractive, 0, 0, 0 /* | 2110 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /* |
2103 Non-nil return value means XEmacs is running without interactive terminal. | 2111 Non-nil return value means XEmacs is running without interactive terminal. |
2104 */ ) | 2112 */ |
2105 () | 2113 ()) |
2106 { | 2114 { |
2107 return ((noninteractive) ? Qt : Qnil); | 2115 return ((noninteractive) ? Qt : Qnil); |
2108 } | 2116 } |
2109 | 2117 |
2110 /* This flag is useful to define if you're under a debugger; this way, you | 2118 /* This flag is useful to define if you're under a debugger; this way, you |
2126 #endif | 2134 #endif |
2127 } | 2135 } |
2128 #endif /* USE_ASSERTIONS */ | 2136 #endif /* USE_ASSERTIONS */ |
2129 | 2137 |
2130 #ifdef QUANTIFY | 2138 #ifdef QUANTIFY |
2131 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data, | 2139 DEFUN ("quantify-start-recording-data", |
2132 Squantify_start_recording_data, 0, 0, 0 /* | 2140 Fquantify_start_recording_data, 0, 0, 0, /* |
2133 Start recording Quantify data. | 2141 Start recording Quantify data. |
2134 */) | 2142 */ |
2135 () | 2143 ()) |
2136 { | 2144 { |
2137 quantify_start_recording_data (); | 2145 quantify_start_recording_data (); |
2138 return Qnil; | 2146 return Qnil; |
2139 } | 2147 } |
2140 | 2148 |
2141 DEFUN ("quantify-stop-recording-data", Fquantify_stop_recording_data, | 2149 DEFUN ("quantify-stop-recording-data", |
2142 Squantify_stop_recording_data, 0, 0, 0 /* | 2150 Fquantify_stop_recording_data, 0, 0, 0, /* |
2143 Stop recording Quantify data. | 2151 Stop recording Quantify data. |
2144 */) | 2152 */ |
2145 () | 2153 ()) |
2146 { | 2154 { |
2147 quantify_stop_recording_data (); | 2155 quantify_stop_recording_data (); |
2148 return Qnil; | 2156 return Qnil; |
2149 } | 2157 } |
2150 | 2158 |
2151 DEFUN ("quantify-clear-data", Fquantify_clear_data, | 2159 DEFUN ("quantify-clear-data", Fquantify_clear_data, 0, 0, 0, /* |
2152 Squantify_clear_data, 0, 0, 0 /* | |
2153 Clear all Quantify data. | 2160 Clear all Quantify data. |
2154 */) | 2161 */ |
2155 () | 2162 ()) |
2156 { | 2163 { |
2157 quantify_clear_data (); | 2164 quantify_clear_data (); |
2158 return Qnil; | 2165 return Qnil; |
2159 } | 2166 } |
2160 #endif /* QUANTIFY */ | 2167 #endif /* QUANTIFY */ |
2162 void | 2169 void |
2163 syms_of_emacs (void) | 2170 syms_of_emacs (void) |
2164 { | 2171 { |
2165 #ifndef CANNOT_DUMP | 2172 #ifndef CANNOT_DUMP |
2166 #ifdef HAVE_SHM | 2173 #ifdef HAVE_SHM |
2167 defsubr (&Sdump_emacs_data); | 2174 DEFSUBR (Fdump_emacs_data); |
2168 #else | 2175 #else |
2169 defsubr (&Sdump_emacs); | 2176 DEFSUBR (Fdump_emacs); |
2170 #endif | 2177 #endif |
2171 #endif /* !CANNOT_DUMP */ | 2178 #endif /* !CANNOT_DUMP */ |
2172 | 2179 |
2173 defsubr (&Srun_emacs_from_temacs); | 2180 DEFSUBR (Frun_emacs_from_temacs); |
2174 defsubr (&Srunning_temacs_p); | 2181 DEFSUBR (Frunning_temacs_p); |
2175 defsubr (&Sinvocation_name); | 2182 DEFSUBR (Finvocation_name); |
2176 defsubr (&Sinvocation_directory); | 2183 DEFSUBR (Finvocation_directory); |
2177 defsubr (&Skill_emacs); | 2184 DEFSUBR (Fkill_emacs); |
2178 defsubr (&Snoninteractive); | 2185 DEFSUBR (Fnoninteractive); |
2179 | 2186 |
2180 #ifdef QUANTIFY | 2187 #ifdef QUANTIFY |
2181 defsubr (&Squantify_start_recording_data); | 2188 DEFSUBR (Fquantify_start_recording_data); |
2182 defsubr (&Squantify_stop_recording_data); | 2189 DEFSUBR (Fquantify_stop_recording_data); |
2183 defsubr (&Squantify_clear_data); | 2190 DEFSUBR (Fquantify_clear_data); |
2184 #endif /* QUANTIFY */ | 2191 #endif /* QUANTIFY */ |
2185 | 2192 |
2186 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook"); | 2193 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook"); |
2187 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs"); | 2194 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs"); |
2188 } | 2195 } |