diff options
| author | Jim Blandy | 1993-03-20 19:30:58 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-03-20 19:30:58 +0000 |
| commit | 59653951e72a6043d1349da762ed601d53c9cee0 (patch) | |
| tree | 4bb113a169f8ccd3353dc43b097323522909fac2 /src | |
| parent | 17d68aa05a40a45758fefa2c47d655fcdb5c9bf6 (diff) | |
| download | emacs-59653951e72a6043d1349da762ed601d53c9cee0.tar.gz emacs-59653951e72a6043d1349da762ed601d53c9cee0.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 20 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/xfns.c | 13 | ||||
| -rw-r--r-- | src/xterm.c | 12 |
4 files changed, 30 insertions, 16 deletions
diff --git a/src/emacs.c b/src/emacs.c index 25edb3fc659..c5b6953acfb 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -61,6 +61,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 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 | 63 | ||
| 64 | /* The name under which Emacs was invoked, with any leading directory | ||
| 65 | names discarded. */ | ||
| 66 | Lisp_Object Vinvocation_name; | ||
| 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 | ||
| @@ -155,6 +159,8 @@ init_cmdargs (argc, argv, 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--) |
| @@ -164,6 +170,15 @@ init_cmdargs (argc, argv, skip_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 |
| @@ -826,6 +841,8 @@ syms_of_emacs () | |||
| 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 | ||
| @@ -849,4 +866,7 @@ 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; |
| 869 | |||
| 870 | staticpro (&Vinvocation_name); | ||
| 871 | Vinvocation_name = Qnil; | ||
| 852 | } | 872 | } |
diff --git a/src/lisp.h b/src/lisp.h index a770636c074..cac35d1c00e 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1203,6 +1203,7 @@ extern Lisp_Object Frubber_band_rectangle (); | |||
| 1203 | 1203 | ||
| 1204 | /* defined in emacs.c */ | 1204 | /* defined in emacs.c */ |
| 1205 | extern Lisp_Object decode_env_path (); | 1205 | extern Lisp_Object decode_env_path (); |
| 1206 | extern Lisp_Object Vinvocation_name; | ||
| 1206 | void shut_down_emacs ( /* int signal */ ); | 1207 | void shut_down_emacs ( /* int signal */ ); |
| 1207 | /* Nonzero means don't do interactive redisplay and don't change tty modes */ | 1208 | /* Nonzero means don't do interactive redisplay and don't change tty modes */ |
| 1208 | extern int noninteractive; | 1209 | extern int noninteractive; |
diff --git a/src/xfns.c b/src/xfns.c index 1f4d5751d30..cf55cc6c3e1 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -51,7 +51,6 @@ static XrmDatabase xrdb; | |||
| 51 | 51 | ||
| 52 | /* Title name and application name for X stuff. */ | 52 | /* Title name and application name for X stuff. */ |
| 53 | extern char *x_id_name; | 53 | extern char *x_id_name; |
| 54 | extern Lisp_Object invocation_name; | ||
| 55 | 54 | ||
| 56 | /* The background and shape of the mouse pointer, and shape when not | 55 | /* The background and shape of the mouse pointer, and shape when not |
| 57 | over text or in the modeline. */ | 56 | over text or in the modeline. */ |
| @@ -1296,7 +1295,7 @@ and the class is `Emacs.CLASS.SUBCLASS'.") | |||
| 1296 | { | 1295 | { |
| 1297 | /* Allocate space for the components, the dots which separate them, | 1296 | /* Allocate space for the components, the dots which separate them, |
| 1298 | and the final '\0'. */ | 1297 | and the final '\0'. */ |
| 1299 | name_key = (char *) alloca (XSTRING (invocation_name)->size | 1298 | name_key = (char *) alloca (XSTRING (Vinvocation_name)->size |
| 1300 | + XSTRING (attribute)->size | 1299 | + XSTRING (attribute)->size |
| 1301 | + 2); | 1300 | + 2); |
| 1302 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 1301 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) |
| @@ -1304,7 +1303,7 @@ and the class is `Emacs.CLASS.SUBCLASS'.") | |||
| 1304 | + 2); | 1303 | + 2); |
| 1305 | 1304 | ||
| 1306 | sprintf (name_key, "%s.%s", | 1305 | sprintf (name_key, "%s.%s", |
| 1307 | XSTRING (invocation_name)->data, | 1306 | XSTRING (Vinvocation_name)->data, |
| 1308 | XSTRING (attribute)->data); | 1307 | XSTRING (attribute)->data); |
| 1309 | sprintf (class_key, "%s.%s", | 1308 | sprintf (class_key, "%s.%s", |
| 1310 | EMACS_CLASS, | 1309 | EMACS_CLASS, |
| @@ -1312,7 +1311,7 @@ and the class is `Emacs.CLASS.SUBCLASS'.") | |||
| 1312 | } | 1311 | } |
| 1313 | else | 1312 | else |
| 1314 | { | 1313 | { |
| 1315 | name_key = (char *) alloca (XSTRING (invocation_name)->size | 1314 | name_key = (char *) alloca (XSTRING (Vinvocation_name)->size |
| 1316 | + XSTRING (component)->size | 1315 | + XSTRING (component)->size |
| 1317 | + XSTRING (attribute)->size | 1316 | + XSTRING (attribute)->size |
| 1318 | + 3); | 1317 | + 3); |
| @@ -1323,7 +1322,7 @@ and the class is `Emacs.CLASS.SUBCLASS'.") | |||
| 1323 | + 3); | 1322 | + 3); |
| 1324 | 1323 | ||
| 1325 | sprintf (name_key, "%s.%s.%s", | 1324 | sprintf (name_key, "%s.%s.%s", |
| 1326 | XSTRING (invocation_name)->data, | 1325 | XSTRING (Vinvocation_name)->data, |
| 1327 | XSTRING (component)->data, | 1326 | XSTRING (component)->data, |
| 1328 | XSTRING (attribute)->data); | 1327 | XSTRING (attribute)->data); |
| 1329 | sprintf (class_key, "%s.%s", | 1328 | sprintf (class_key, "%s.%s", |
| @@ -1354,13 +1353,13 @@ The defaults are specified in the file `~/.Xdefaults'.") | |||
| 1354 | CHECK_STRING (arg, 1); | 1353 | CHECK_STRING (arg, 1); |
| 1355 | 1354 | ||
| 1356 | value = (unsigned char *) XGetDefault (XDISPLAY | 1355 | value = (unsigned char *) XGetDefault (XDISPLAY |
| 1357 | XSTRING (invocation_name)->data, | 1356 | XSTRING (Vinvocation_name)->data, |
| 1358 | XSTRING (arg)->data); | 1357 | XSTRING (arg)->data); |
| 1359 | if (value == 0) | 1358 | if (value == 0) |
| 1360 | /* Try reversing last two args, in case this is the buggy version of X. */ | 1359 | /* Try reversing last two args, in case this is the buggy version of X. */ |
| 1361 | value = (unsigned char *) XGetDefault (XDISPLAY | 1360 | value = (unsigned char *) XGetDefault (XDISPLAY |
| 1362 | XSTRING (arg)->data, | 1361 | XSTRING (arg)->data, |
| 1363 | XSTRING (invocation_name)->data); | 1362 | XSTRING (Vinvocation_name)->data); |
| 1364 | if (value != 0) | 1363 | if (value != 0) |
| 1365 | return build_string (value); | 1364 | return build_string (value); |
| 1366 | else | 1365 | else |
diff --git a/src/xterm.c b/src/xterm.c index c6f61668e1a..35bacb748cd 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -158,7 +158,6 @@ static FONT_TYPE *icon_font_info; | |||
| 158 | 158 | ||
| 159 | extern Lisp_Object Vcommand_line_args; | 159 | extern Lisp_Object Vcommand_line_args; |
| 160 | char *hostname, *x_id_name; | 160 | char *hostname, *x_id_name; |
| 161 | Lisp_Object invocation_name; | ||
| 162 | 161 | ||
| 163 | /* This is the X connection that we are using. */ | 162 | /* This is the X connection that we are using. */ |
| 164 | 163 | ||
| @@ -3613,7 +3612,7 @@ x_text_icon (f, icon_name) | |||
| 3613 | if (icon_font_info == 0) | 3612 | if (icon_font_info == 0) |
| 3614 | icon_font_info | 3613 | icon_font_info |
| 3615 | = XGetFont (XGetDefault (XDISPLAY | 3614 | = XGetFont (XGetDefault (XDISPLAY |
| 3616 | (char *) XSTRING (invocation_name)->data, | 3615 | (char *) XSTRING (Vinvocation_name)->data, |
| 3617 | "BodyFont")); | 3616 | "BodyFont")); |
| 3618 | 3617 | ||
| 3619 | if (f->display.x->icon_desc) | 3618 | if (f->display.x->icon_desc) |
| @@ -4523,8 +4522,6 @@ x_term_init (display_name) | |||
| 4523 | XSetAfterFunction (x_current_display, x_trace_wire); | 4522 | XSetAfterFunction (x_current_display, x_trace_wire); |
| 4524 | #endif /* ! 0 */ | 4523 | #endif /* ! 0 */ |
| 4525 | 4524 | ||
| 4526 | invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args)); | ||
| 4527 | |||
| 4528 | /* Try to get the host name; if the buffer is too short, try | 4525 | /* Try to get the host name; if the buffer is too short, try |
| 4529 | again. Apparently, the only indication gethostname gives of | 4526 | again. Apparently, the only indication gethostname gives of |
| 4530 | whether the buffer was large enough is the presence or absence | 4527 | whether the buffer was large enough is the presence or absence |
| @@ -4541,10 +4538,10 @@ x_term_init (display_name) | |||
| 4541 | hostname_size <<= 1; | 4538 | hostname_size <<= 1; |
| 4542 | hostname = (char *) xrealloc (hostname, hostname_size); | 4539 | hostname = (char *) xrealloc (hostname, hostname_size); |
| 4543 | } | 4540 | } |
| 4544 | x_id_name = (char *) xmalloc (XSTRING (invocation_name)->size | 4541 | x_id_name = (char *) xmalloc (XSTRING (Vinvocation_name)->size |
| 4545 | + strlen (hostname) | 4542 | + strlen (hostname) |
| 4546 | + 2); | 4543 | + 2); |
| 4547 | sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname); | 4544 | sprintf (x_id_name, "%s@%s", XSTRING (Vinvocation_name)->data, hostname); |
| 4548 | } | 4545 | } |
| 4549 | 4546 | ||
| 4550 | /* Figure out which modifier bits mean what. */ | 4547 | /* Figure out which modifier bits mean what. */ |
| @@ -4642,9 +4639,6 @@ x_term_init (display_name) | |||
| 4642 | void | 4639 | void |
| 4643 | syms_of_xterm () | 4640 | syms_of_xterm () |
| 4644 | { | 4641 | { |
| 4645 | staticpro (&invocation_name); | ||
| 4646 | invocation_name = Qnil; | ||
| 4647 | |||
| 4648 | staticpro (&last_mouse_scroll_bar); | 4642 | staticpro (&last_mouse_scroll_bar); |
| 4649 | } | 4643 | } |
| 4650 | #endif /* ! defined (HAVE_X11) */ | 4644 | #endif /* ! defined (HAVE_X11) */ |