changeset 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 990694465b0f
children bd56d208ed22
files src/emacs.c src/lisp.h src/xfns.c src/xterm.c
diffstat 4 files changed, 30 insertions(+), 16 deletions(-) [+]
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;
 }
--- a/src/lisp.h	Sat Mar 20 18:12:07 1993 +0000
+++ b/src/lisp.h	Sat Mar 20 19:30:58 1993 +0000
@@ -1203,6 +1203,7 @@
 
 /* defined in emacs.c */
 extern Lisp_Object decode_env_path ();
+extern Lisp_Object Vinvocation_name;
 void shut_down_emacs ( /* int signal */ );
 /* Nonzero means don't do interactive redisplay and don't change tty modes */
 extern int noninteractive;
--- a/src/xfns.c	Sat Mar 20 18:12:07 1993 +0000
+++ b/src/xfns.c	Sat Mar 20 19:30:58 1993 +0000
@@ -51,7 +51,6 @@
 
 /* Title name and application name for X stuff. */
 extern char *x_id_name;
-extern Lisp_Object invocation_name;
 
 /* The background and shape of the mouse pointer, and shape when not
    over text or in the modeline. */
@@ -1296,7 +1295,7 @@
     {
       /* Allocate space for the components, the dots which separate them,
 	 and the final '\0'.  */
-      name_key = (char *) alloca (XSTRING (invocation_name)->size
+      name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
 				  + XSTRING (attribute)->size
 				  + 2);
       class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
@@ -1304,7 +1303,7 @@
 				   + 2);
 
       sprintf (name_key, "%s.%s",
-	       XSTRING (invocation_name)->data,
+	       XSTRING (Vinvocation_name)->data,
 	       XSTRING (attribute)->data);
       sprintf (class_key, "%s.%s",
 	       EMACS_CLASS,
@@ -1312,7 +1311,7 @@
     }
   else
     {
-      name_key = (char *) alloca (XSTRING (invocation_name)->size
+      name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
 				  + XSTRING (component)->size
 				  + XSTRING (attribute)->size
 				  + 3);
@@ -1323,7 +1322,7 @@
 				   + 3);
 
       sprintf (name_key, "%s.%s.%s",
-	       XSTRING (invocation_name)->data,
+	       XSTRING (Vinvocation_name)->data,
 	       XSTRING (component)->data,
 	       XSTRING (attribute)->data);
       sprintf (class_key, "%s.%s",
@@ -1354,13 +1353,13 @@
   CHECK_STRING (arg, 1);
 
   value = (unsigned char *) XGetDefault (XDISPLAY 
-					 XSTRING (invocation_name)->data,
+					 XSTRING (Vinvocation_name)->data,
 					 XSTRING (arg)->data);
   if (value == 0)
     /* Try reversing last two args, in case this is the buggy version of X.  */
     value = (unsigned char *) XGetDefault (XDISPLAY
 					   XSTRING (arg)->data,
-					   XSTRING (invocation_name)->data);
+					   XSTRING (Vinvocation_name)->data);
   if (value != 0)
     return build_string (value);
   else
--- a/src/xterm.c	Sat Mar 20 18:12:07 1993 +0000
+++ b/src/xterm.c	Sat Mar 20 19:30:58 1993 +0000
@@ -158,7 +158,6 @@
 
 extern Lisp_Object Vcommand_line_args;
 char *hostname, *x_id_name;
-Lisp_Object invocation_name;
 
 /* This is the X connection that we are using.  */
 
@@ -3613,7 +3612,7 @@
   if (icon_font_info == 0)
     icon_font_info
       = XGetFont (XGetDefault (XDISPLAY
-			       (char *) XSTRING (invocation_name)->data,
+			       (char *) XSTRING (Vinvocation_name)->data,
 			       "BodyFont"));
 
   if (f->display.x->icon_desc)
@@ -4523,8 +4522,6 @@
     XSetAfterFunction (x_current_display, x_trace_wire);
 #endif /* ! 0 */
 
-    invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args));
-
     /* Try to get the host name; if the buffer is too short, try
        again.  Apparently, the only indication gethostname gives of
        whether the buffer was large enough is the presence or absence
@@ -4541,10 +4538,10 @@
 	hostname_size <<= 1;
 	hostname = (char *) xrealloc (hostname, hostname_size);
       }
-    x_id_name = (char *) xmalloc (XSTRING (invocation_name)->size
+    x_id_name = (char *) xmalloc (XSTRING (Vinvocation_name)->size
 				+ strlen (hostname)
 				+ 2);
-    sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname);
+    sprintf (x_id_name, "%s@%s", XSTRING (Vinvocation_name)->data, hostname);
   }
 
   /* Figure out which modifier bits mean what.  */
@@ -4642,9 +4639,6 @@
 void
 syms_of_xterm ()
 {
-  staticpro (&invocation_name);
-  invocation_name = Qnil;
-
   staticpro (&last_mouse_scroll_bar);
 }
 #endif /* ! defined (HAVE_X11) */