aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-08-08 06:23:21 +0000
committerRichard M. Stallman1993-08-08 06:23:21 +0000
commitace40a69188907f699ef66e2298a989f118aa309 (patch)
tree366208474742d74543e56ca6dbdc2fc4dcb1cf25
parentddc61f4653039b1103f4eb2a5ce8f5ed3eb2a511 (diff)
downloademacs-ace40a69188907f699ef66e2298a989f118aa309.tar.gz
emacs-ace40a69188907f699ef66e2298a989f118aa309.zip
(Vinvocation_directory): New var.
(init_cmdargs): Set up its value. (Finvocation_directory): New function. (main): Call init_buffer, init_callproc and init_cmdargs before init_lread. (syms_of_emacs): Install the function, and protect the variable.
-rw-r--r--src/emacs.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/emacs.c b/src/emacs.c
index a0a2a9b0186..f0bb6eaf4df 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -59,6 +59,9 @@ Lisp_Object Vcommand_line_args;
59 names discarded. */ 59 names discarded. */
60Lisp_Object Vinvocation_name; 60Lisp_Object Vinvocation_name;
61 61
62/* The directory name from which Emacs was invoked. */
63Lisp_Object Vinvocation_directory;
64
62/* Hook run by `kill-emacs' before it does really anything. */ 65/* Hook run by `kill-emacs' before it does really anything. */
63Lisp_Object Vkill_emacs_hook; 66Lisp_Object Vkill_emacs_hook;
64 67
@@ -159,6 +162,17 @@ init_cmdargs (argc, argv, skip_args)
159 register int i; 162 register int i;
160 163
161 Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0])); 164 Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0]));
165 Vinvocation_directory = Ffile_name_directory (build_string (argv[0]));
166 /* If we got no directory in argv[0], search PATH to find where
167 Emacs actually came from. */
168 if (NILP (Vinvocation_directory))
169 {
170 Lisp_Object found;
171 int yes = openp (Vexec_path, Vinvocation_name,
172 "", &found, 1);
173 if (yes)
174 Vinvocation_directory = Ffile_name_directory (found);
175 }
162 176
163 Vcommand_line_args = Qnil; 177 Vcommand_line_args = Qnil;
164 178
@@ -178,6 +192,14 @@ Any directory names are omitted.")
178 return Fcopy_sequence (Vinvocation_name); 192 return Fcopy_sequence (Vinvocation_name);
179} 193}
180 194
195DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
196 0, 0, 0,
197 "Return the directory name in which the Emacs executable was located")
198 ()
199{
200 return Fcopy_sequence (Vinvocation_directory);
201}
202
181 203
182#ifdef VMS 204#ifdef VMS
183#ifdef LINK_CRTL_SHARE 205#ifdef LINK_CRTL_SHARE
@@ -469,10 +491,12 @@ main (argc, argv, envp)
469 until calling init_callproc. */ 491 until calling init_callproc. */
470 set_process_environment (); 492 set_process_environment ();
471 493
494 init_buffer (); /* Init default directory of main buffer */
495
496 init_callproc (); /* Must precede init_cmdargs and init_sys_modes. */
497 init_cmdargs (argc, argv, skip_args); /* Must precede init_lread. */
472 init_lread (); 498 init_lread ();
473 499
474 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
475 init_buffer (); /* Init default directory of main buffer */
476 if (!noninteractive) 500 if (!noninteractive)
477 { 501 {
478#ifdef VMS 502#ifdef VMS
@@ -481,7 +505,6 @@ main (argc, argv, envp)
481 init_display (); /* Determine terminal type. init_sys_modes uses results */ 505 init_display (); /* Determine terminal type. init_sys_modes uses results */
482 } 506 }
483 init_keyboard (); /* This too must precede init_sys_modes */ 507 init_keyboard (); /* This too must precede init_sys_modes */
484 init_callproc (); /* And this too. */
485#ifdef VMS 508#ifdef VMS
486 init_vmsproc (); /* And this too. */ 509 init_vmsproc (); /* And this too. */
487#endif /* VMS */ 510#endif /* VMS */
@@ -863,6 +886,7 @@ syms_of_emacs ()
863 defsubr (&Skill_emacs); 886 defsubr (&Skill_emacs);
864 887
865 defsubr (&Sinvocation_name); 888 defsubr (&Sinvocation_name);
889 defsubr (&Sinvocation_directory);
866 890
867 DEFVAR_LISP ("command-line-args", &Vcommand_line_args, 891 DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
868 "Args passed by shell to Emacs, as a list of strings."); 892 "Args passed by shell to Emacs, as a list of strings.");
@@ -890,4 +914,6 @@ it to change priority. (Emacs sets its uid back to the real uid.)");
890 914
891 staticpro (&Vinvocation_name); 915 staticpro (&Vinvocation_name);
892 Vinvocation_name = Qnil; 916 Vinvocation_name = Qnil;
917 staticpro (&Vinvocation_directory);
918 Vinvocation_directory = Qnil;
893} 919}