diff options
| author | Karoly Lorentey | 2005-12-29 04:31:04 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2005-12-29 04:31:04 +0000 |
| commit | da8e8fc14f3166ec596e34f43fbfea866d1176df (patch) | |
| tree | 9c31affcb4b837cac4793f10acbafc562bfd08e4 /src/callproc.c | |
| parent | 86f5ca04d94ad551d3aa726e15281e75ef0189ed (diff) | |
| download | emacs-da8e8fc14f3166ec596e34f43fbfea866d1176df.tar.gz emacs-da8e8fc14f3166ec596e34f43fbfea866d1176df.zip | |
Store local environment in frame (not terminal) parameters.
* src/callproc.c (child_setup, getenv_internal, Fgetenv_internal):
Store the local environment in a frame (not terminal) parameter.
Update doc strings.
(syms_of_callproc): Update doc strings.
(Qenvironment): Moved to frame.c.
* lisp/env.el (read-envvar-name, setenv, getenv, environment): Use frame
parameters to store the local environment, not terminal parameters.
* server.el (server-process-filter): Store the local environment in a
frame (not terminal) parameter. Do not try to decode environment
strings.
* lisp/frame.el (make-frame): Set up the 'environment frame parameter,
when needed.
* src/frame.c (Qenvironment): Move here from callproc.c.
(Fdelete_frame): Don't allow other frames to refer to a deleted frame
in their 'environment parameter.
(Fframe_with_environment): New function.
(syms_of_frame): Defsubr it. Initialize and staticpro Qenvironment.
* frame.h (Qenvironment): Declare.
* lisp.h (Fframe_with_environment): EXFUN it.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-467
Diffstat (limited to 'src/callproc.c')
| -rw-r--r-- | src/callproc.c | 71 |
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 |
| 120 | Lisp_Object Qbuffer_file_type; | 120 | Lisp_Object Qbuffer_file_type; |
| 121 | #endif /* DOS_NT */ | 121 | #endif /* DOS_NT */ |
| 122 | Lisp_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 | ||
| 1490 | static int | 1489 | static int |
| 1491 | getenv_internal (var, varlen, value, valuelen, terminal) | 1490 | getenv_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, | |||
| 1594 | VARIABLE should be a string. Value is nil if VARIABLE is undefined in | 1595 | VARIABLE should be a string. Value is nil if VARIABLE is undefined in |
| 1595 | the environment. Otherwise, value is a string. | 1596 | the environment. Otherwise, value is a string. |
| 1596 | 1597 | ||
| 1597 | If optional parameter TERMINAL is non-nil, then it should be a | 1598 | If optional parameter FRAME is non-nil, then it should be a frame. If |
| 1598 | terminal id or a frame. If the specified terminal device has its own | 1599 | that frame has its own set of environment variables, this function |
| 1599 | set of environment variables, this function will look up VARIABLE in | 1600 | will look up VARIABLE in there. |
| 1600 | it. | ||
| 1601 | 1601 | ||
| 1602 | Otherwise, this function searches `process-environment' for VARIABLE. | 1602 | Otherwise, this function searches `process-environment' for VARIABLE. |
| 1603 | If it was not found there, then it continues the search in either | 1603 | If 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 |
| 1605 | terminal device, depending on the value of | 1605 | frame, 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. | |||
| 1842 | The environment which Emacs inherits is placed in this variable when | 1841 | The environment which Emacs inherits is placed in this variable when |
| 1843 | Emacs starts. | 1842 | Emacs starts. |
| 1844 | 1843 | ||
| 1845 | Some terminal devices may have their own local list of environment | 1844 | Some frames may have their own local list of environment variables in |
| 1846 | variables in their 'environment parameter, which may override this | 1845 | their 'environment parameter, which may override this global list; see |
| 1847 | global 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 | 1847 | modify an environment variable on all frames. |
| 1849 | all terminals. | ||
| 1850 | 1848 | ||
| 1851 | If multiple entries define the same variable, the first one always | 1849 | If multiple entries define the same variable, the first one always |
| 1852 | takes precedence. | 1850 | takes precedence. |
| @@ -1860,12 +1858,12 @@ See `setenv' and `getenv'. */); | |||
| 1860 | Each element should be a string of the form ENVVARNAME=VALUE. | 1858 | Each element should be a string of the form ENVVARNAME=VALUE. |
| 1861 | 1859 | ||
| 1862 | Entries in this list take precedence to those in `global-environment' | 1860 | Entries in this list take precedence to those in `global-environment' |
| 1863 | or the terminal environment. (See `local-environment-variables' for | 1861 | or the frame-local environment. (See `local-environment-variables'.) |
| 1864 | an explanation of the terminal-local environment.) Therefore, | 1862 | Therefore, let-binding `process-environment' is an easy way to |
| 1865 | let-binding `process-environment' is an easy way to temporarily change | 1863 | temporarily change the value of an environment variable, irrespective |
| 1866 | the value of an environment variable, irrespective of where it comes | 1864 | of where it comes from. To use `process-environment' to remove an |
| 1867 | from. To use `process-environment' to remove an environment variable, | 1865 | environment variable, include only its name in the list, without |
| 1868 | include only its name in the list, without "=VALUE". | 1866 | "=VALUE". |
| 1869 | 1867 | ||
| 1870 | This variable is set to nil when Emacs starts. | 1868 | This 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. |
| 1890 | If set to t, `getenv', `setenv' and subprocess creation functions use | 1888 | If set to t, `getenv', `setenv' and subprocess creation functions use |
| 1891 | the local environment of the terminal device of the selected frame, | 1889 | the local environment of the selected frame, ignoring |
| 1892 | ignoring `global-environment'. | 1890 | `global-environment'. |
| 1893 | 1891 | ||
| 1894 | If set to nil, Emacs uses `global-environment' and ignores the | 1892 | If set to nil, Emacs uses `global-environment' and ignores the |
| 1895 | terminal environment. | 1893 | frame-local environment. |
| 1896 | 1894 | ||
| 1897 | Otherwise, `local-environment-variables' should be a list of variable | 1895 | Otherwise, `local-environment-variables' should be a list of variable |
| 1898 | names (represented by Lisp strings) to look up in the terminal's | 1896 | names (represented by Lisp strings) to look up in the frame's |
| 1899 | environment. The rest will come from `global-environment'. */); | 1897 | environment. 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 |