diff options
| author | Dan Nicolaescu | 2007-07-03 04:53:21 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-07-03 04:53:21 +0000 |
| commit | de87fb5978903768aff3c71857ebca173461bea3 (patch) | |
| tree | a730da52bd15d248d83d5a897c462bc2c2b3a65b /src/callproc.c | |
| parent | 5f06b6081389843ba2d2d817683eb4e610f7a24e (diff) | |
| download | emacs-de87fb5978903768aff3c71857ebca173461bea3.tar.gz emacs-de87fb5978903768aff3c71857ebca173461bea3.zip | |
* server.el (server-process-filter): Likewise.
(server-process-filter): Likewise. Also set COLORFGBG and
COLORTERM.
* frame.el (frame-initialize, make-frame): Likewise.
* faces.el (tty-set-up-initial-frame-faces): Likewise.
* env.el (read-envvar-name): Don't consider the environment frame
param.
(setenv): Set display-environment-variable and
term-environment-variable.
* frame.c (Qterm_environment_variable,
Qdisplay_environment_variable): New variables.
(syms_of_frame): Intern and staticpro them.
* frame.h: Declare them here.
* callproc.c (child_setup): Use the display-environment-variable
and term-environment-variable frame params.
(getenv_internal): Likewise.
(set_initial_environment): Initialise Vprocess_environment.
* frames.texi (Basic Parameters): Add display-environment-variable
and term-environment-variable.
Diffstat (limited to 'src/callproc.c')
| -rw-r--r-- | src/callproc.c | 113 |
1 files changed, 105 insertions, 8 deletions
diff --git a/src/callproc.c b/src/callproc.c index ce9eb73dd54..a2d517b1bea 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1245,6 +1245,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1245 | { | 1245 | { |
| 1246 | char **env; | 1246 | char **env; |
| 1247 | char *pwd_var; | 1247 | char *pwd_var; |
| 1248 | char *term_var; | ||
| 1249 | char *display_var; | ||
| 1248 | #ifdef WINDOWSNT | 1250 | #ifdef WINDOWSNT |
| 1249 | int cpid; | 1251 | int cpid; |
| 1250 | HANDLE handles[3]; | 1252 | HANDLE handles[3]; |
| @@ -1325,9 +1327,12 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1325 | register char **new_env; | 1327 | register char **new_env; |
| 1326 | char **p, **q; | 1328 | char **p, **q; |
| 1327 | register int new_length; | 1329 | register int new_length; |
| 1328 | Lisp_Object local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), | 1330 | Lisp_Object local = selected_frame; /* get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), */ |
| 1329 | Qenvironment); | 1331 | /* Qenvironment); */ |
| 1330 | 1332 | ||
| 1333 | Lisp_Object term; | ||
| 1334 | Lisp_Object display; | ||
| 1335 | |||
| 1331 | new_length = 0; | 1336 | new_length = 0; |
| 1332 | 1337 | ||
| 1333 | for (tem = Vprocess_environment; | 1338 | for (tem = Vprocess_environment; |
| @@ -1335,10 +1340,21 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1335 | tem = XCDR (tem)) | 1340 | tem = XCDR (tem)) |
| 1336 | new_length++; | 1341 | new_length++; |
| 1337 | 1342 | ||
| 1343 | #if 0 | ||
| 1338 | for (tem = local; | 1344 | for (tem = local; |
| 1339 | CONSP (tem) && STRINGP (XCAR (tem)); | 1345 | CONSP (tem) && STRINGP (XCAR (tem)); |
| 1340 | tem = XCDR (tem)) | 1346 | tem = XCDR (tem)) |
| 1341 | new_length++; | 1347 | new_length++; |
| 1348 | #endif | ||
| 1349 | |||
| 1350 | /* Add TERM and DISPLAY from the frame local values. */ | ||
| 1351 | term = get_frame_param (XFRAME (local), Qterm_environment_variable); | ||
| 1352 | if (! NILP (term)) | ||
| 1353 | new_length++; | ||
| 1354 | |||
| 1355 | display = get_frame_param (XFRAME (local), Qdisplay_environment_variable); | ||
| 1356 | if (! NILP (display)) | ||
| 1357 | new_length++; | ||
| 1342 | 1358 | ||
| 1343 | /* new_length + 2 to include PWD and terminating 0. */ | 1359 | /* new_length + 2 to include PWD and terminating 0. */ |
| 1344 | env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); | 1360 | env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); |
| @@ -1348,18 +1364,43 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1348 | if (egetenv ("PWD")) | 1364 | if (egetenv ("PWD")) |
| 1349 | *new_env++ = pwd_var; | 1365 | *new_env++ = pwd_var; |
| 1350 | 1366 | ||
| 1367 | if (! NILP (term)) | ||
| 1368 | { | ||
| 1369 | int vlen = strlen ("TERM=") + strlen (SDATA (term)) + 1; | ||
| 1370 | char *vdata = (char *) alloca (vlen); | ||
| 1371 | strcpy (vdata, "TERM="); | ||
| 1372 | strcat (vdata, SDATA (term)); | ||
| 1373 | new_env = add_env (env, new_env, vdata); | ||
| 1374 | } | ||
| 1375 | |||
| 1376 | if (! NILP (display)) | ||
| 1377 | { | ||
| 1378 | int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1; | ||
| 1379 | char *vdata = (char *) alloca (vlen); | ||
| 1380 | strcpy (vdata, "DISPLAY="); | ||
| 1381 | strcat (vdata, SDATA (display)); | ||
| 1382 | new_env = add_env (env, new_env, vdata); | ||
| 1383 | } | ||
| 1384 | |||
| 1351 | /* Overrides. */ | 1385 | /* Overrides. */ |
| 1352 | for (tem = Vprocess_environment; | 1386 | for (tem = Vprocess_environment; |
| 1353 | CONSP (tem) && STRINGP (XCAR (tem)); | 1387 | CONSP (tem) && STRINGP (XCAR (tem)); |
| 1354 | tem = XCDR (tem)) | 1388 | tem = XCDR (tem)) |
| 1355 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); | 1389 | { |
| 1390 | if ((strcmp (SDATA (XCAR (tem)), "TERM") != 0) | ||
| 1391 | && (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0)) | ||
| 1392 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); | ||
| 1393 | } | ||
| 1356 | 1394 | ||
| 1395 | |||
| 1396 | #if 0 | ||
| 1357 | /* Local part of environment. */ | 1397 | /* Local part of environment. */ |
| 1358 | for (tem = local; | 1398 | for (tem = local; |
| 1359 | CONSP (tem) && STRINGP (XCAR (tem)); | 1399 | CONSP (tem) && STRINGP (XCAR (tem)); |
| 1360 | tem = XCDR (tem)) | 1400 | tem = XCDR (tem)) |
| 1361 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); | 1401 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); |
| 1362 | 1402 | #endif | |
| 1403 | |||
| 1363 | *new_env = 0; | 1404 | *new_env = 0; |
| 1364 | 1405 | ||
| 1365 | /* Remove variable names without values. */ | 1406 | /* Remove variable names without values. */ |
| @@ -1373,6 +1414,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1373 | p++; | 1414 | p++; |
| 1374 | } | 1415 | } |
| 1375 | } | 1416 | } |
| 1417 | |||
| 1418 | |||
| 1376 | #ifdef WINDOWSNT | 1419 | #ifdef WINDOWSNT |
| 1377 | prepare_standard_handles (in, out, err, handles); | 1420 | prepare_standard_handles (in, out, err, handles); |
| 1378 | set_process_dir (SDATA (current_dir)); | 1421 | set_process_dir (SDATA (current_dir)); |
| @@ -1494,6 +1537,9 @@ getenv_internal (var, varlen, value, valuelen, frame) | |||
| 1494 | Lisp_Object frame; | 1537 | Lisp_Object frame; |
| 1495 | { | 1538 | { |
| 1496 | Lisp_Object scan; | 1539 | Lisp_Object scan; |
| 1540 | Lisp_Object term; | ||
| 1541 | Lisp_Object display; | ||
| 1542 | |||
| 1497 | 1543 | ||
| 1498 | if (NILP (frame)) | 1544 | if (NILP (frame)) |
| 1499 | { | 1545 | { |
| @@ -1528,6 +1574,56 @@ getenv_internal (var, varlen, value, valuelen, frame) | |||
| 1528 | frame = selected_frame; | 1574 | frame = selected_frame; |
| 1529 | } | 1575 | } |
| 1530 | 1576 | ||
| 1577 | /* For TERM and DISPLAY first try to get the values from the frame. */ | ||
| 1578 | term = get_frame_param (XFRAME (frame), Qterm_environment_variable); | ||
| 1579 | if (strcmp (var, "TERM") == 0) | ||
| 1580 | if (! NILP (term)) | ||
| 1581 | { | ||
| 1582 | *value = (char *) SDATA (term); | ||
| 1583 | *valuelen = SBYTES (term); | ||
| 1584 | return 1; | ||
| 1585 | } | ||
| 1586 | display = get_frame_param (XFRAME (frame), Qdisplay_environment_variable); | ||
| 1587 | if (strcmp (var, "DISPLAY") == 0) | ||
| 1588 | if (! NILP (display)) | ||
| 1589 | { | ||
| 1590 | *value = (char *) SDATA (display); | ||
| 1591 | *valuelen = SBYTES (display); | ||
| 1592 | return 1; | ||
| 1593 | } | ||
| 1594 | |||
| 1595 | { | ||
| 1596 | /* Try to find VAR in Vprocess_environment. */ | ||
| 1597 | for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan)) | ||
| 1598 | { | ||
| 1599 | Lisp_Object entry = XCAR (scan); | ||
| 1600 | if (STRINGP (entry) | ||
| 1601 | && SBYTES (entry) >= varlen | ||
| 1602 | #ifdef WINDOWSNT | ||
| 1603 | /* NT environment variables are case insensitive. */ | ||
| 1604 | && ! strnicmp (SDATA (entry), var, varlen) | ||
| 1605 | #else /* not WINDOWSNT */ | ||
| 1606 | && ! bcmp (SDATA (entry), var, varlen) | ||
| 1607 | #endif /* not WINDOWSNT */ | ||
| 1608 | ) | ||
| 1609 | { | ||
| 1610 | if (SBYTES (entry) > varlen && SREF (entry, varlen) == '=') | ||
| 1611 | { | ||
| 1612 | *value = (char *) SDATA (entry) + (varlen + 1); | ||
| 1613 | *valuelen = SBYTES (entry) - (varlen + 1); | ||
| 1614 | return 1; | ||
| 1615 | } | ||
| 1616 | else if (SBYTES (entry) == varlen) | ||
| 1617 | { | ||
| 1618 | /* Lone variable names in Vprocess_environment mean that | ||
| 1619 | variable should be removed from the environment. */ | ||
| 1620 | return 0; | ||
| 1621 | } | ||
| 1622 | } | ||
| 1623 | } | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | #if 0 | ||
| 1531 | /* Find the environment in which to search the variable. */ | 1627 | /* Find the environment in which to search the variable. */ |
| 1532 | CHECK_FRAME (frame); | 1628 | CHECK_FRAME (frame); |
| 1533 | frame = Fframe_with_environment (frame); | 1629 | frame = Fframe_with_environment (frame); |
| @@ -1555,7 +1651,7 @@ getenv_internal (var, varlen, value, valuelen, frame) | |||
| 1555 | return 1; | 1651 | return 1; |
| 1556 | } | 1652 | } |
| 1557 | } | 1653 | } |
| 1558 | 1654 | #endif | |
| 1559 | return 0; | 1655 | return 0; |
| 1560 | } | 1656 | } |
| 1561 | 1657 | ||
| @@ -1737,14 +1833,15 @@ void | |||
| 1737 | set_initial_environment () | 1833 | set_initial_environment () |
| 1738 | { | 1834 | { |
| 1739 | register char **envp; | 1835 | register char **envp; |
| 1740 | Lisp_Object env = Qnil; | 1836 | Lisp_Object env = Vprocess_environment; |
| 1741 | #ifndef CANNOT_DUMP | 1837 | #ifndef CANNOT_DUMP |
| 1742 | if (initialized) | 1838 | if (initialized) |
| 1743 | #endif | 1839 | #endif |
| 1744 | { | 1840 | { |
| 1745 | for (envp = environ; *envp; envp++) | 1841 | for (envp = environ; *envp; envp++) |
| 1746 | env = Fcons (build_string (*envp), env); | 1842 | Vprocess_environment = Fcons (build_string (*envp), |
| 1747 | store_frame_param (SELECTED_FRAME(), Qenvironment, env); | 1843 | Vprocess_environment); |
| 1844 | store_frame_param (SELECTED_FRAME(), Qenvironment, Vprocess_environment); | ||
| 1748 | } | 1845 | } |
| 1749 | } | 1846 | } |
| 1750 | 1847 | ||