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 | |
| 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.
| -rw-r--r-- | lisp/ChangeLog.multi-tty | 13 | ||||
| -rw-r--r-- | lisp/env.el | 18 | ||||
| -rw-r--r-- | lisp/faces.el | 6 | ||||
| -rw-r--r-- | lisp/frame.el | 12 | ||||
| -rw-r--r-- | lisp/server.el | 13 | ||||
| -rw-r--r-- | lispref/ChangeLog.multi-tty | 30 | ||||
| -rw-r--r-- | lispref/frames.texi | 8 | ||||
| -rw-r--r-- | src/ChangeLog.multi-tty | 13 | ||||
| -rw-r--r-- | src/callproc.c | 113 | ||||
| -rw-r--r-- | src/frame.c | 9 | ||||
| -rw-r--r-- | src/frame.h | 2 |
11 files changed, 219 insertions, 18 deletions
diff --git a/lisp/ChangeLog.multi-tty b/lisp/ChangeLog.multi-tty index 6c04ee57077..cc115bb0278 100644 --- a/lisp/ChangeLog.multi-tty +++ b/lisp/ChangeLog.multi-tty | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2007-07-02 Dan Nicolaescu <dann@ics.uci.edu> | 1 | 2007-07-02 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 2 | ||
| 3 | * server.el (server-process-filter): Likewise. | ||
| 4 | (server-process-filter): Likewise. Also set COLORFGBG and | ||
| 5 | COLORTERM. | ||
| 6 | |||
| 7 | * frame.el (frame-initialize, make-frame): Likewise. | ||
| 8 | |||
| 9 | * faces.el (tty-set-up-initial-frame-faces): Likewise. | ||
| 10 | |||
| 11 | * env.el (read-envvar-name): Don't consider the environment frame | ||
| 12 | param. | ||
| 13 | (setenv): Set display-environment-variable and | ||
| 14 | term-environment-variable. | ||
| 15 | |||
| 3 | * term/x-win.el (x-menu-bar-open): Use accelerate-menu. | 16 | * term/x-win.el (x-menu-bar-open): Use accelerate-menu. |
| 4 | 17 | ||
| 5 | 2007-06-23 Dan Nicolaescu <dann@ics.uci.edu> | 18 | 2007-06-23 Dan Nicolaescu <dann@ics.uci.edu> |
diff --git a/lisp/env.el b/lisp/env.el index a6626dc08ff..f2609cc6784 100644 --- a/lisp/env.el +++ b/lisp/env.el | |||
| @@ -55,7 +55,8 @@ If it is also not t, RET does not exit if it does non-null completion." | |||
| 55 | (substring enventry 0 | 55 | (substring enventry 0 |
| 56 | (string-match "=" enventry))))) | 56 | (string-match "=" enventry))))) |
| 57 | (append process-environment | 57 | (append process-environment |
| 58 | (frame-parameter (frame-with-environment) 'environment))) | 58 | nil ;;(frame-parameter (frame-with-environment) 'environment) |
| 59 | )) | ||
| 59 | nil mustmatch nil 'read-envvar-name-history)) | 60 | nil mustmatch nil 'read-envvar-name-history)) |
| 60 | 61 | ||
| 61 | ;; History list for VALUE argument to setenv. | 62 | ;; History list for VALUE argument to setenv. |
| @@ -191,9 +192,14 @@ a side-effect." | |||
| 191 | (setq process-environment (setenv-internal process-environment | 192 | (setq process-environment (setenv-internal process-environment |
| 192 | variable value t)) | 193 | variable value t)) |
| 193 | (setq frame (frame-with-environment frame)) | 194 | (setq frame (frame-with-environment frame)) |
| 194 | (set-frame-parameter frame 'environment | 195 | (cond |
| 195 | (setenv-internal (frame-parameter frame 'environment) | 196 | ((string-equal "TERM" variable) |
| 196 | variable value nil))) | 197 | (set-frame-parameter frame 'term-environment-variable value)) |
| 198 | ((string-equal "DISPLAY" variable) | ||
| 199 | (set-frame-parameter frame 'display-environment-variable value)) | ||
| 200 | (t | ||
| 201 | (setq process-environment (setenv-internal process-environment | ||
| 202 | variable value nil))))) | ||
| 197 | value) | 203 | value) |
| 198 | 204 | ||
| 199 | (defun getenv (variable &optional frame) | 205 | (defun getenv (variable &optional frame) |
| @@ -238,8 +244,8 @@ Non-ASCII characters are encoded according to the initial value of | |||
| 238 | `locale-coding-system', i.e. the elements must normally be decoded for use. | 244 | `locale-coding-system', i.e. the elements must normally be decoded for use. |
| 239 | See `setenv' and `getenv'." | 245 | See `setenv' and `getenv'." |
| 240 | (let* ((env (append process-environment | 246 | (let* ((env (append process-environment |
| 241 | (frame-parameter (frame-with-environment frame) | 247 | ;; (frame-parameter (frame-with-environment frame) |
| 242 | 'environment) | 248 | ;; 'environment) |
| 243 | nil)) | 249 | nil)) |
| 244 | (scan env) | 250 | (scan env) |
| 245 | prev seen) | 251 | prev seen) |
diff --git a/lisp/faces.el b/lisp/faces.el index 32d0c0af068..e5796272b0c 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -1909,7 +1909,11 @@ terminal type to a different value." | |||
| 1909 | (defun tty-set-up-initial-frame-faces () | 1909 | (defun tty-set-up-initial-frame-faces () |
| 1910 | (let ((frame (selected-frame))) | 1910 | (let ((frame (selected-frame))) |
| 1911 | (frame-set-background-mode frame) | 1911 | (frame-set-background-mode frame) |
| 1912 | (face-set-after-frame-default frame))) | 1912 | (face-set-after-frame-default frame) |
| 1913 | (set-frame-parameter frame-initial-frame 'term-environment-variable | ||
| 1914 | (getenv "TERM")) | ||
| 1915 | (set-frame-parameter frame-initial-frame 'display-environment-variable | ||
| 1916 | (getenv "DISPLAY")))) | ||
| 1913 | 1917 | ||
| 1914 | 1918 | ||
| 1915 | 1919 | ||
diff --git a/lisp/frame.el b/lisp/frame.el index 5f32654fdb1..925b61ce754 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -241,6 +241,10 @@ Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args." | |||
| 241 | ;; Copy the environment of the Emacs process into the new frame. | 241 | ;; Copy the environment of the Emacs process into the new frame. |
| 242 | (set-frame-parameter frame-initial-frame 'environment | 242 | (set-frame-parameter frame-initial-frame 'environment |
| 243 | (frame-parameter terminal-frame 'environment)) | 243 | (frame-parameter terminal-frame 'environment)) |
| 244 | (set-frame-parameter frame-initial-frame 'term-environment-variable | ||
| 245 | (getenv "TERM")) | ||
| 246 | (set-frame-parameter frame-initial-frame 'display-environment-variable | ||
| 247 | (getenv "DISPLAY")) | ||
| 244 | ;; At this point, we know that we have a frame open, so we | 248 | ;; At this point, we know that we have a frame open, so we |
| 245 | ;; can delete the terminal frame. | 249 | ;; can delete the terminal frame. |
| 246 | (delete-frame terminal-frame) | 250 | (delete-frame terminal-frame) |
| @@ -700,11 +704,17 @@ setup is for focus to follow the pointer." | |||
| 700 | (normal-erase-is-backspace-setup-frame frame) | 704 | (normal-erase-is-backspace-setup-frame frame) |
| 701 | ;; Inherit the 'environment and 'client parameters. | 705 | ;; Inherit the 'environment and 'client parameters. |
| 702 | (let ((env (frame-parameter oldframe 'environment)) | 706 | (let ((env (frame-parameter oldframe 'environment)) |
| 703 | (client (frame-parameter oldframe 'client))) | 707 | (client (frame-parameter oldframe 'client)) |
| 708 | (termenv (frame-parameter oldframe 'term-environment-variable)) | ||
| 709 | (displayenv (frame-parameter oldframe 'display-environment-variable))) | ||
| 704 | (if (not (framep env)) | 710 | (if (not (framep env)) |
| 705 | (setq env oldframe)) | 711 | (setq env oldframe)) |
| 706 | (if (and env (not (assq 'environment parameters))) | 712 | (if (and env (not (assq 'environment parameters))) |
| 707 | (set-frame-parameter frame 'environment env)) | 713 | (set-frame-parameter frame 'environment env)) |
| 714 | (if (and termenv (not (assq 'term-environment-variable parameters))) | ||
| 715 | (set-frame-parameter frame 'term-environment-variable termenv)) | ||
| 716 | (if (and displayenv (not (assq 'display-environment-variable parameters))) | ||
| 717 | (set-frame-parameter frame 'display-environment-variable displayenv)) | ||
| 708 | (if (and client (not (assq 'client parameters))) | 718 | (if (and client (not (assq 'client parameters))) |
| 709 | (set-frame-parameter frame 'client client))) | 719 | (set-frame-parameter frame 'client client))) |
| 710 | (run-hook-with-args 'after-make-frame-functions frame) | 720 | (run-hook-with-args 'after-make-frame-functions frame) |
diff --git a/lisp/server.el b/lisp/server.el index 838aed96cf8..60ba66c88fe 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -763,6 +763,10 @@ The following commands are accepted by the client: | |||
| 763 | ;; initialization parameters for X frames at | 763 | ;; initialization parameters for X frames at |
| 764 | ;; the moment. | 764 | ;; the moment. |
| 765 | (modify-frame-parameters frame params) | 765 | (modify-frame-parameters frame params) |
| 766 | (set-frame-parameter frame 'display-environment-variable | ||
| 767 | (server-getenv-from env "DISPLAY")) | ||
| 768 | (set-frame-parameter frame 'term-environment-variable | ||
| 769 | (server-getenv-from env "TERM")) | ||
| 766 | (select-frame frame) | 770 | (select-frame frame) |
| 767 | (server-client-set client 'frame frame) | 771 | (server-client-set client 'frame frame) |
| 768 | (server-client-set client 'terminal (frame-terminal frame)) | 772 | (server-client-set client 'terminal (frame-terminal frame)) |
| @@ -812,12 +816,19 @@ The following commands are accepted by the client: | |||
| 812 | "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" | 816 | "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" |
| 813 | "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" | 817 | "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" |
| 814 | "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" | 818 | "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" |
| 815 | "TERMINFO_DIRS" "TERMPATH") | 819 | "TERMINFO_DIRS" "TERMPATH" |
| 820 | ;; rxvt wants these | ||
| 821 | "COLORFGBG" "COLORTERM") | ||
| 816 | (setq frame (make-frame-on-tty tty type | 822 | (setq frame (make-frame-on-tty tty type |
| 817 | ;; Ignore nowait here; we always need to clean | 823 | ;; Ignore nowait here; we always need to clean |
| 818 | ;; up opened ttys when the client dies. | 824 | ;; up opened ttys when the client dies. |
| 819 | `((client . ,proc) | 825 | `((client . ,proc) |
| 820 | (environment . ,env))))) | 826 | (environment . ,env))))) |
| 827 | |||
| 828 | (set-frame-parameter frame 'display-environment-variable | ||
| 829 | (server-getenv-from env "DISPLAY")) | ||
| 830 | (set-frame-parameter frame 'term-environment-variable | ||
| 831 | (server-getenv-from env "TERM")) | ||
| 821 | (select-frame frame) | 832 | (select-frame frame) |
| 822 | (server-client-set client 'frame frame) | 833 | (server-client-set client 'frame frame) |
| 823 | (server-client-set client 'tty (terminal-name frame)) | 834 | (server-client-set client 'tty (terminal-name frame)) |
diff --git a/lispref/ChangeLog.multi-tty b/lispref/ChangeLog.multi-tty new file mode 100644 index 00000000000..a36db6733d0 --- /dev/null +++ b/lispref/ChangeLog.multi-tty | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | 2007-07-02 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * frames.texi (Basic Parameters): Add display-environment-variable | ||
| 4 | and term-environment-variable. | ||
| 5 | |||
| 6 | ;; Local Variables: | ||
| 7 | ;; coding: iso-2022-7bit | ||
| 8 | ;; add-log-time-zone-rule: t | ||
| 9 | ;; End: | ||
| 10 | |||
| 11 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
| 12 | |||
| 13 | This file is part of GNU Emacs. | ||
| 14 | |||
| 15 | GNU Emacs is free software; you can redistribute it and/or modify | ||
| 16 | it under the terms of the GNU General Public License as published by | ||
| 17 | the Free Software Foundation; either version 2, or (at your option) | ||
| 18 | any later version. | ||
| 19 | |||
| 20 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 23 | GNU General Public License for more details. | ||
| 24 | |||
| 25 | You should have received a copy of the GNU General Public License | ||
| 26 | along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 27 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 28 | Boston, MA 02110-1301, USA. | ||
| 29 | |||
| 30 | |||
diff --git a/lispref/frames.texi b/lispref/frames.texi index b8a0d4749e2..7d2ea7cf70e 100644 --- a/lispref/frames.texi +++ b/lispref/frames.texi | |||
| @@ -378,6 +378,14 @@ you don't specify a name, Emacs sets the frame name automatically | |||
| 378 | If you specify the frame name explicitly when you create the frame, the | 378 | If you specify the frame name explicitly when you create the frame, the |
| 379 | name is also used (instead of the name of the Emacs executable) when | 379 | name is also used (instead of the name of the Emacs executable) when |
| 380 | looking up X resources for the frame. | 380 | looking up X resources for the frame. |
| 381 | |||
| 382 | @item display-environment-variable | ||
| 383 | The value of the @code{DISPLAY} environment variable for the frame. It | ||
| 384 | is passed to child processes. | ||
| 385 | |||
| 386 | @item term-environment-variable | ||
| 387 | The value of the @code{TERM} environment variable for the frame. It | ||
| 388 | is passed to child processes. | ||
| 381 | @end table | 389 | @end table |
| 382 | 390 | ||
| 383 | @node Position Parameters | 391 | @node Position Parameters |
diff --git a/src/ChangeLog.multi-tty b/src/ChangeLog.multi-tty index eb455157034..05a7ec48d06 100644 --- a/src/ChangeLog.multi-tty +++ b/src/ChangeLog.multi-tty | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2007-07-02 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * frame.c (Qterm_environment_variable, | ||
| 4 | Qdisplay_environment_variable): New variables. | ||
| 5 | (syms_of_frame): Intern and staticpro them. | ||
| 6 | |||
| 7 | * frame.h: Declare them here. | ||
| 8 | |||
| 9 | * callproc.c (child_setup): Use the display-environment-variable | ||
| 10 | and term-environment-variable frame params. | ||
| 11 | (getenv_internal): Likewise. | ||
| 12 | (set_initial_environment): Initialise Vprocess_environment. | ||
| 13 | |||
| 1 | 2007-06-03 Dan Nicolaescu <dann@ics.uci.edu> | 14 | 2007-06-03 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 15 | ||
| 3 | * xselect.c (x_handle_selection_clear): Only access | 16 | * xselect.c (x_handle_selection_clear): Only access |
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 | ||
diff --git a/src/frame.c b/src/frame.c index a1b4e6bd85f..d081fbf55a2 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -111,6 +111,8 @@ Lisp_Object Qtty_color_mode; | |||
| 111 | Lisp_Object Qtty, Qtty_type; | 111 | Lisp_Object Qtty, Qtty_type; |
| 112 | Lisp_Object Qwindow_system; | 112 | Lisp_Object Qwindow_system; |
| 113 | Lisp_Object Qenvironment; | 113 | Lisp_Object Qenvironment; |
| 114 | Lisp_Object Qterm_environment_variable; | ||
| 115 | Lisp_Object Qdisplay_environment_variable; | ||
| 114 | 116 | ||
| 115 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; | 117 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; |
| 116 | 118 | ||
| @@ -4353,7 +4355,12 @@ syms_of_frame () | |||
| 4353 | staticpro (&Qwindow_system); | 4355 | staticpro (&Qwindow_system); |
| 4354 | Qenvironment = intern ("environment"); | 4356 | Qenvironment = intern ("environment"); |
| 4355 | staticpro (&Qenvironment); | 4357 | staticpro (&Qenvironment); |
| 4356 | 4358 | ||
| 4359 | Qterm_environment_variable = intern ("term-environment-variable"); | ||
| 4360 | staticpro (&Qterm_environment_variable); | ||
| 4361 | Qdisplay_environment_variable = intern ("display-environment-variable"); | ||
| 4362 | staticpro (&Qdisplay_environment_variable); | ||
| 4363 | |||
| 4357 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); | 4364 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); |
| 4358 | staticpro (&Qface_set_after_frame_default); | 4365 | staticpro (&Qface_set_after_frame_default); |
| 4359 | 4366 | ||
diff --git a/src/frame.h b/src/frame.h index 5686662bb96..161404fdd75 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -780,6 +780,8 @@ extern Lisp_Object Qframep, Qframe_live_p; | |||
| 780 | extern Lisp_Object Qtty, Qtty_type; | 780 | extern Lisp_Object Qtty, Qtty_type; |
| 781 | extern Lisp_Object Qterminal, Qterminal_live_p; | 781 | extern Lisp_Object Qterminal, Qterminal_live_p; |
| 782 | extern Lisp_Object Qenvironment; | 782 | extern Lisp_Object Qenvironment; |
| 783 | extern Lisp_Object Qterm_environment_variable; | ||
| 784 | extern Lisp_Object Qdisplay_environment_variable; | ||
| 783 | 785 | ||
| 784 | extern struct frame *last_nonminibuf_frame; | 786 | extern struct frame *last_nonminibuf_frame; |
| 785 | 787 | ||