diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 71 | ||||
| -rw-r--r-- | src/frame.c | 59 | ||||
| -rw-r--r-- | src/frame.h | 1 | ||||
| -rw-r--r-- | src/lisp.h | 1 |
4 files changed, 94 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 |
diff --git a/src/frame.c b/src/frame.c index c3140628cec..f0657975402 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -111,6 +111,7 @@ Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list; | |||
| 111 | Lisp_Object Qtty_color_mode; | 111 | Lisp_Object Qtty_color_mode; |
| 112 | Lisp_Object Qtty, Qtty_type; | 112 | Lisp_Object Qtty, Qtty_type; |
| 113 | Lisp_Object Qwindow_system; | 113 | Lisp_Object Qwindow_system; |
| 114 | Lisp_Object Qenvironment; | ||
| 114 | 115 | ||
| 115 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; | 116 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; |
| 116 | 117 | ||
| @@ -1473,6 +1474,24 @@ The functions are run with one arg, the frame to be deleted. */) | |||
| 1473 | if (EQ (f->minibuffer_window, echo_area_window)) | 1474 | if (EQ (f->minibuffer_window, echo_area_window)) |
| 1474 | echo_area_window = sf->minibuffer_window; | 1475 | echo_area_window = sf->minibuffer_window; |
| 1475 | 1476 | ||
| 1477 | /* Don't allow other frames to refer to a deleted frame in their | ||
| 1478 | 'environment parameter. */ | ||
| 1479 | { | ||
| 1480 | Lisp_Object tail, frame1; | ||
| 1481 | Lisp_Object env = get_frame_param (XFRAME (frame), Qenvironment); | ||
| 1482 | FOR_EACH_FRAME (tail, frame1) | ||
| 1483 | { | ||
| 1484 | if (EQ (frame, frame1) || !FRAME_LIVE_P (XFRAME (frame1))) | ||
| 1485 | continue; | ||
| 1486 | if (EQ (frame, get_frame_param (XFRAME (frame1), Qenvironment))) | ||
| 1487 | { | ||
| 1488 | store_frame_param (XFRAME (frame1), Qenvironment, env); | ||
| 1489 | if (!FRAMEP (env)) | ||
| 1490 | env = frame1; | ||
| 1491 | } | ||
| 1492 | } | ||
| 1493 | } | ||
| 1494 | |||
| 1476 | /* Clear any X selections for this frame. */ | 1495 | /* Clear any X selections for this frame. */ |
| 1477 | #ifdef HAVE_X_WINDOWS | 1496 | #ifdef HAVE_X_WINDOWS |
| 1478 | if (FRAME_X_P (f)) | 1497 | if (FRAME_X_P (f)) |
| @@ -2577,6 +2596,43 @@ enabled such bindings for that variable with `make-variable-frame-local'. */) | |||
| 2577 | 2596 | ||
| 2578 | return unbind_to (count, Qnil); | 2597 | return unbind_to (count, Qnil); |
| 2579 | } | 2598 | } |
| 2599 | |||
| 2600 | DEFUN ("frame-with-environment", Fframe_with_environment, Sframe_with_environment, 0, 1, 0, | ||
| 2601 | doc: /* Return the frame that has the environment variable list for FRAME. | ||
| 2602 | |||
| 2603 | The frame-local environment variable list is normally shared between | ||
| 2604 | frames that were created in the same Emacsclient session. The | ||
| 2605 | environment list is stored in a single frame's 'environment parameter; | ||
| 2606 | the other frames' 'environment parameter is set to this frame. This | ||
| 2607 | function follows to chain of 'environment references to reach the | ||
| 2608 | frame that stores the actual local environment list, and returns that | ||
| 2609 | frame. */) | ||
| 2610 | (frame) | ||
| 2611 | Lisp_Object frame; | ||
| 2612 | { | ||
| 2613 | Lisp_Object hare, tortoise; | ||
| 2614 | |||
| 2615 | if (NILP (frame)) | ||
| 2616 | frame = selected_frame; | ||
| 2617 | CHECK_FRAME (frame); | ||
| 2618 | |||
| 2619 | hare = tortoise = get_frame_param (XFRAME (frame), Qenvironment); | ||
| 2620 | while (!NILP (hare) && FRAMEP (hare)) | ||
| 2621 | { | ||
| 2622 | frame = hare; | ||
| 2623 | hare = get_frame_param (XFRAME (hare), Qenvironment); | ||
| 2624 | if (NILP (hare) || !FRAMEP (hare)) | ||
| 2625 | break; | ||
| 2626 | frame = hare; | ||
| 2627 | hare = get_frame_param (XFRAME (hare), Qenvironment); | ||
| 2628 | tortoise = get_frame_param (XFRAME (tortoise), Qenvironment); | ||
| 2629 | if (EQ (hare, tortoise)) | ||
| 2630 | error ("Cyclic frame-local environment indirection"); | ||
| 2631 | } | ||
| 2632 | |||
| 2633 | return frame; | ||
| 2634 | } | ||
| 2635 | |||
| 2580 | 2636 | ||
| 2581 | DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, | 2637 | DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, |
| 2582 | 0, 1, 0, | 2638 | 0, 1, 0, |
| @@ -4232,6 +4288,8 @@ syms_of_frame () | |||
| 4232 | staticpro (&Qtty_type); | 4288 | staticpro (&Qtty_type); |
| 4233 | Qwindow_system = intern ("window-system"); | 4289 | Qwindow_system = intern ("window-system"); |
| 4234 | staticpro (&Qwindow_system); | 4290 | staticpro (&Qwindow_system); |
| 4291 | Qenvironment = intern ("environment"); | ||
| 4292 | staticpro (&Qenvironment); | ||
| 4235 | 4293 | ||
| 4236 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); | 4294 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); |
| 4237 | staticpro (&Qface_set_after_frame_default); | 4295 | staticpro (&Qface_set_after_frame_default); |
| @@ -4416,6 +4474,7 @@ This variable is local to the current terminal and cannot be buffer-local. */); | |||
| 4416 | defsubr (&Sframe_parameters); | 4474 | defsubr (&Sframe_parameters); |
| 4417 | defsubr (&Sframe_parameter); | 4475 | defsubr (&Sframe_parameter); |
| 4418 | defsubr (&Smodify_frame_parameters); | 4476 | defsubr (&Smodify_frame_parameters); |
| 4477 | defsubr (&Sframe_with_environment); | ||
| 4419 | defsubr (&Sframe_char_height); | 4478 | defsubr (&Sframe_char_height); |
| 4420 | defsubr (&Sframe_char_width); | 4479 | defsubr (&Sframe_char_width); |
| 4421 | defsubr (&Sframe_pixel_height); | 4480 | defsubr (&Sframe_pixel_height); |
diff --git a/src/frame.h b/src/frame.h index c63b0bec464..6c54c328923 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -781,6 +781,7 @@ typedef struct frame *FRAME_PTR; | |||
| 781 | extern Lisp_Object Qframep, Qframe_live_p; | 781 | extern Lisp_Object Qframep, Qframe_live_p; |
| 782 | extern Lisp_Object Qtty, Qtty_type; | 782 | extern Lisp_Object Qtty, Qtty_type; |
| 783 | extern Lisp_Object Qdevice, Qdisplay_live_p; | 783 | extern Lisp_Object Qdevice, Qdisplay_live_p; |
| 784 | extern Lisp_Object Qenvironment; | ||
| 784 | 785 | ||
| 785 | extern struct frame *last_nonminibuf_frame; | 786 | extern struct frame *last_nonminibuf_frame; |
| 786 | 787 | ||
diff --git a/src/lisp.h b/src/lisp.h index 4b71cd67e98..0aa2d7cb510 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2998,6 +2998,7 @@ EXFUN (Fvisible_frame_list, 0); | |||
| 2998 | EXFUN (Fframe_parameter, 2); | 2998 | EXFUN (Fframe_parameter, 2); |
| 2999 | EXFUN (Fframe_parameters, 1); | 2999 | EXFUN (Fframe_parameters, 1); |
| 3000 | EXFUN (Fmodify_frame_parameters, 2); | 3000 | EXFUN (Fmodify_frame_parameters, 2); |
| 3001 | EXFUN (Fframe_with_environment, 1); | ||
| 3001 | EXFUN (Fset_frame_height, 3); | 3002 | EXFUN (Fset_frame_height, 3); |
| 3002 | EXFUN (Fset_frame_width, 3); | 3003 | EXFUN (Fset_frame_width, 3); |
| 3003 | EXFUN (Fset_frame_size, 3); | 3004 | EXFUN (Fset_frame_size, 3); |