aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/callproc.c b/src/callproc.c
index ee702fef8c7..715178f8fb2 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -119,7 +119,6 @@ Lisp_Object Vprocess_environment;
119#ifdef DOS_NT 119#ifdef DOS_NT
120Lisp_Object Qbuffer_file_type; 120Lisp_Object Qbuffer_file_type;
121#endif /* DOS_NT */ 121#endif /* DOS_NT */
122Lisp_Object Qenvironment;
123 122
124/* True iff we are about to fork off a synchronous process or if we 123/* True iff we are about to fork off a synchronous process or if we
125 are waiting for it. */ 124 are waiting for it. */
@@ -1319,8 +1318,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
1319 1318
1320 if (!NILP (Vlocal_environment_variables)) 1319 if (!NILP (Vlocal_environment_variables))
1321 { 1320 {
1322 local = get_terminal_param (FRAME_DEVICE (XFRAME (selected_frame)), 1321 local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)),
1323 Qenvironment); 1322 Qenvironment);
1324 if (EQ (Vlocal_environment_variables, Qt) 1323 if (EQ (Vlocal_environment_variables, Qt)
1325 && !NILP (local)) 1324 && !NILP (local))
1326 environment = local; 1325 environment = local;
@@ -1356,7 +1355,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
1356 new_env = add_env (env, new_env, egetenv (SDATA (XCAR (tem)))); 1355 new_env = add_env (env, new_env, egetenv (SDATA (XCAR (tem))));
1357 1356
1358 /* The rest of the environment (either Vglobal_environment or the 1357 /* The rest of the environment (either Vglobal_environment or the
1359 'environment terminal parameter). */ 1358 'environment frame parameter). */
1360 for (tem = environment; 1359 for (tem = environment;
1361 CONSP (tem) && STRINGP (XCAR (tem)); 1360 CONSP (tem) && STRINGP (XCAR (tem));
1362 tem = XCDR (tem)) 1361 tem = XCDR (tem))
@@ -1488,12 +1487,12 @@ relocate_fd (fd, minfd)
1488} 1487}
1489 1488
1490static int 1489static int
1491getenv_internal (var, varlen, value, valuelen, terminal) 1490getenv_internal (var, varlen, value, valuelen, frame)
1492 char *var; 1491 char *var;
1493 int varlen; 1492 int varlen;
1494 char **value; 1493 char **value;
1495 int *valuelen; 1494 int *valuelen;
1496 Lisp_Object terminal; 1495 Lisp_Object frame;
1497{ 1496{
1498 Lisp_Object scan; 1497 Lisp_Object scan;
1499 Lisp_Object environment = Vglobal_environment; 1498 Lisp_Object environment = Vglobal_environment;
@@ -1528,17 +1527,19 @@ getenv_internal (var, varlen, value, valuelen, terminal)
1528 } 1527 }
1529 1528
1530 /* Find the environment in which to search the variable. */ 1529 /* Find the environment in which to search the variable. */
1531 if (!NILP (terminal)) 1530 if (!NILP (frame))
1532 { 1531 {
1533 Lisp_Object local = get_terminal_param (get_device (terminal, 1), Qenvironment); 1532 CHECK_FRAME (frame);
1533 frame = Fframe_with_environment (frame);
1534 Lisp_Object local = get_frame_param (XFRAME (frame), Qenvironment);
1534 /* Use Vglobal_environment if there is no local environment. */ 1535 /* Use Vglobal_environment if there is no local environment. */
1535 if (!NILP (local)) 1536 if (!NILP (local))
1536 environment = local; 1537 environment = local;
1537 } 1538 }
1538 else if (!NILP (Vlocal_environment_variables)) 1539 else if (!NILP (Vlocal_environment_variables))
1539 { 1540 {
1540 Lisp_Object local = get_terminal_param (FRAME_DEVICE (XFRAME (selected_frame)), 1541 Lisp_Object local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)),
1541 Qenvironment); 1542 Qenvironment);
1542 if (EQ (Vlocal_environment_variables, Qt) 1543 if (EQ (Vlocal_environment_variables, Qt)
1543 && !NILP (local)) 1544 && !NILP (local))
1544 environment = local; 1545 environment = local;
@@ -1594,25 +1595,23 @@ DEFUN ("getenv-internal", Fgetenv_internal, Sgetenv_internal, 1, 2, 0,
1594VARIABLE should be a string. Value is nil if VARIABLE is undefined in 1595VARIABLE should be a string. Value is nil if VARIABLE is undefined in
1595the environment. Otherwise, value is a string. 1596the environment. Otherwise, value is a string.
1596 1597
1597If optional parameter TERMINAL is non-nil, then it should be a 1598If optional parameter FRAME is non-nil, then it should be a frame. If
1598terminal id or a frame. If the specified terminal device has its own 1599that frame has its own set of environment variables, this function
1599set of environment variables, this function will look up VARIABLE in 1600will look up VARIABLE in there.
1600it.
1601 1601
1602Otherwise, this function searches `process-environment' for VARIABLE. 1602Otherwise, this function searches `process-environment' for VARIABLE.
1603If it was not found there, then it continues the search in either 1603If it was not found there, then it continues the search in either
1604`global-environment' or the local environment list of the current 1604`global-environment' or the local environment list of the current
1605terminal device, depending on the value of 1605frame, depending on the value of `local-environment-variables'. */)
1606`local-environment-variables'. */) 1606 (variable, frame)
1607 (variable, terminal) 1607 Lisp_Object variable, frame;
1608 Lisp_Object variable, terminal;
1609{ 1608{
1610 char *value; 1609 char *value;
1611 int valuelen; 1610 int valuelen;
1612 1611
1613 CHECK_STRING (variable); 1612 CHECK_STRING (variable);
1614 if (getenv_internal (SDATA (variable), SBYTES (variable), 1613 if (getenv_internal (SDATA (variable), SBYTES (variable),
1615 &value, &valuelen, terminal)) 1614 &value, &valuelen, frame))
1616 return make_string (value, valuelen); 1615 return make_string (value, valuelen);
1617 else 1616 else
1618 return Qnil; 1617 return Qnil;
@@ -1842,11 +1841,10 @@ Each element should be a string of the form ENVVARNAME=VALUE.
1842The environment which Emacs inherits is placed in this variable when 1841The environment which Emacs inherits is placed in this variable when
1843Emacs starts. 1842Emacs starts.
1844 1843
1845Some terminal devices may have their own local list of environment 1844Some frames may have their own local list of environment variables in
1846variables in their 'environment parameter, which may override this 1845their 'environment parameter, which may override this global list; see
1847global list; see `local-environment-variables'. See 1846`local-environment-variables'. See `process-environment' for a way to
1848`process-environment' for a way to modify an environment variable on 1847modify an environment variable on all frames.
1849all terminals.
1850 1848
1851If multiple entries define the same variable, the first one always 1849If multiple entries define the same variable, the first one always
1852takes precedence. 1850takes precedence.
@@ -1860,12 +1858,12 @@ See `setenv' and `getenv'. */);
1860Each element should be a string of the form ENVVARNAME=VALUE. 1858Each element should be a string of the form ENVVARNAME=VALUE.
1861 1859
1862Entries in this list take precedence to those in `global-environment' 1860Entries in this list take precedence to those in `global-environment'
1863or the terminal environment. (See `local-environment-variables' for 1861or the frame-local environment. (See `local-environment-variables'.)
1864an explanation of the terminal-local environment.) Therefore, 1862Therefore, let-binding `process-environment' is an easy way to
1865let-binding `process-environment' is an easy way to temporarily change 1863temporarily change the value of an environment variable, irrespective
1866the value of an environment variable, irrespective of where it comes 1864of where it comes from. To use `process-environment' to remove an
1867from. To use `process-environment' to remove an environment variable, 1865environment variable, include only its name in the list, without
1868include only its name in the list, without "=VALUE". 1866"=VALUE".
1869 1867
1870This variable is set to nil when Emacs starts. 1868This variable is set to nil when Emacs starts.
1871 1869
@@ -1886,21 +1884,18 @@ See `setenv' and `getenv'. */);
1886 defsubr (&Scall_process_region); 1884 defsubr (&Scall_process_region);
1887 1885
1888 DEFVAR_LISP ("local-environment-variables", &Vlocal_environment_variables, 1886 DEFVAR_LISP ("local-environment-variables", &Vlocal_environment_variables,
1889 doc: /* Enable or disable terminal-local environment variables. 1887 doc: /* Enable or disable frame-local environment variables.
1890If set to t, `getenv', `setenv' and subprocess creation functions use 1888If set to t, `getenv', `setenv' and subprocess creation functions use
1891the local environment of the terminal device of the selected frame, 1889the local environment of the selected frame, ignoring
1892ignoring `global-environment'. 1890`global-environment'.
1893 1891
1894If set to nil, Emacs uses `global-environment' and ignores the 1892If set to nil, Emacs uses `global-environment' and ignores the
1895terminal environment. 1893frame-local environment.
1896 1894
1897Otherwise, `local-environment-variables' should be a list of variable 1895Otherwise, `local-environment-variables' should be a list of variable
1898names (represented by Lisp strings) to look up in the terminal's 1896names (represented by Lisp strings) to look up in the frame's
1899environment. The rest will come from `global-environment'. */); 1897environment. The rest will come from `global-environment'. */);
1900 Vlocal_environment_variables = Qnil; 1898 Vlocal_environment_variables = Qnil;
1901
1902 Qenvironment = intern ("environment");
1903 staticpro (&Qenvironment);
1904} 1899}
1905 1900
1906/* arch-tag: 769b8045-1df7-4d2b-8968-e3fb49017f95 1901/* arch-tag: 769b8045-1df7-4d2b-8968-e3fb49017f95