diff src/emacs.c @ 2279:012b04efa234

* emacs.c (Finvocation_name): New function. (Vinvocation_name): New variable. (init_cmdargs): Set it. (syms_of_emacs): defsubr Finvocation_name, staticpro and initialize Vinvocation_name. * lisp.h (Vinvocation_name): New extern declaration. * xterm.c (invocation_name): Variable deleted; use Vinvocation_name now. (x_text_icon, x_term_init): Use Vinvocation_name now instead of invocation_name. (x_term_init): Don't initialize invocation_name. (syms_of_xterm): Don't initialize or staticpro invocation_name. * xfns.c (invocation_name): Remove extern declaration for this. [HAVE_X11] (Fx_get_resource): Use Vinvocation_name now instead of invocation_name. [not HAVE_X11] (Fx_get_default): Same.
author Jim Blandy <jimb@redhat.com>
date Sat, 20 Mar 1993 19:30:58 +0000
parents 454228f1c526
children ddab91a375d8
line wrap: on
line diff
--- a/src/emacs.c	Sat Mar 20 18:12:07 1993 +0000
+++ b/src/emacs.c	Sat Mar 20 19:30:58 1993 +0000
@@ -61,6 +61,10 @@
 /* Command line args from shell, as list of strings */
 Lisp_Object Vcommand_line_args;
 
+/* The name under which Emacs was invoked, with any leading directory
+   names discarded.  */
+Lisp_Object Vinvocation_name;
+
 /* Hook run by `kill-emacs' before it does really anything.  */
 Lisp_Object Vkill_emacs_hook;
 
@@ -155,6 +159,8 @@
 {
   register int i;
 
+  Vinvocation_name = Ffile_name_nondirectory (argv[0]);
+
   Vcommand_line_args = Qnil;
 
   for (i = argc - 1; i >= 0; i--)
@@ -164,6 +170,15 @@
 	  = Fcons (build_string (argv[i]), Vcommand_line_args);
     }
 }
+
+DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
+  "Return the program name that was used to run Emacs.\n\
+Any directory names are omitted.")
+  ()
+{
+  return Fcopy_sequence (Vinvocation_name);
+}
+
 
 #ifdef VMS
 #ifdef LINK_CRTL_SHARE
@@ -826,6 +841,8 @@
 
   defsubr (&Skill_emacs);
 
+  defsubr (&Sinvocation_name);
+
   DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
     "Args passed by shell to Emacs, as a list of strings.");
 
@@ -849,4 +866,7 @@
 and only if the Emacs executable is installed with setuid to permit\n\
 it to change priority.  (Emacs sets its uid back to the real uid.)");
   emacs_priority = 0;
+
+  staticpro (&Vinvocation_name);
+  Vinvocation_name = Qnil;
 }