comparison 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
comparison
equal deleted inserted replaced
2278:990694465b0f 2279:012b04efa234
58 58
59 #define PRIO_PROCESS 0 59 #define PRIO_PROCESS 0
60 60
61 /* Command line args from shell, as list of strings */ 61 /* Command line args from shell, as list of strings */
62 Lisp_Object Vcommand_line_args; 62 Lisp_Object Vcommand_line_args;
63
64 /* The name under which Emacs was invoked, with any leading directory
65 names discarded. */
66 Lisp_Object Vinvocation_name;
63 67
64 /* Hook run by `kill-emacs' before it does really anything. */ 68 /* Hook run by `kill-emacs' before it does really anything. */
65 Lisp_Object Vkill_emacs_hook; 69 Lisp_Object Vkill_emacs_hook;
66 70
67 /* Set nonzero after Emacs has started up the first time. 71 /* Set nonzero after Emacs has started up the first time.
153 char **argv; 157 char **argv;
154 int skip_args; 158 int skip_args;
155 { 159 {
156 register int i; 160 register int i;
157 161
162 Vinvocation_name = Ffile_name_nondirectory (argv[0]);
163
158 Vcommand_line_args = Qnil; 164 Vcommand_line_args = Qnil;
159 165
160 for (i = argc - 1; i >= 0; i--) 166 for (i = argc - 1; i >= 0; i--)
161 { 167 {
162 if (i == 0 || i > skip_args) 168 if (i == 0 || i > skip_args)
163 Vcommand_line_args 169 Vcommand_line_args
164 = Fcons (build_string (argv[i]), Vcommand_line_args); 170 = Fcons (build_string (argv[i]), Vcommand_line_args);
165 } 171 }
166 } 172 }
173
174 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
175 "Return the program name that was used to run Emacs.\n\
176 Any directory names are omitted.")
177 ()
178 {
179 return Fcopy_sequence (Vinvocation_name);
180 }
181
167 182
168 #ifdef VMS 183 #ifdef VMS
169 #ifdef LINK_CRTL_SHARE 184 #ifdef LINK_CRTL_SHARE
170 #ifdef SHAREABLE_LIB_BUG 185 #ifdef SHAREABLE_LIB_BUG
171 extern noshare char **environ; 186 extern noshare char **environ;
824 defsubr (&Sdump_emacs); 839 defsubr (&Sdump_emacs);
825 #endif 840 #endif
826 841
827 defsubr (&Skill_emacs); 842 defsubr (&Skill_emacs);
828 843
844 defsubr (&Sinvocation_name);
845
829 DEFVAR_LISP ("command-line-args", &Vcommand_line_args, 846 DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
830 "Args passed by shell to Emacs, as a list of strings."); 847 "Args passed by shell to Emacs, as a list of strings.");
831 848
832 DEFVAR_LISP ("system-type", &Vsystem_type, 849 DEFVAR_LISP ("system-type", &Vsystem_type,
833 "Value is symbol indicating type of operating system you are using."); 850 "Value is symbol indicating type of operating system you are using.");
847 "Priority for Emacs to run at.\n\ 864 "Priority for Emacs to run at.\n\
848 This value is effective only if set before Emacs is dumped,\n\ 865 This value is effective only if set before Emacs is dumped,\n\
849 and only if the Emacs executable is installed with setuid to permit\n\ 866 and only if the Emacs executable is installed with setuid to permit\n\
850 it to change priority. (Emacs sets its uid back to the real uid.)"); 867 it to change priority. (Emacs sets its uid back to the real uid.)");
851 emacs_priority = 0; 868 emacs_priority = 0;
852 } 869
870 staticpro (&Vinvocation_name);
871 Vinvocation_name = Qnil;
872 }