2007-07-02 Dan Nicolaescu <dann@ics.uci.edu>
+ * 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.
+
* term/x-win.el (x-menu-bar-open): Use accelerate-menu.
2007-06-23 Dan Nicolaescu <dann@ics.uci.edu>
(substring enventry 0
(string-match "=" enventry)))))
(append process-environment
- (frame-parameter (frame-with-environment) 'environment)))
+ nil ;;(frame-parameter (frame-with-environment) 'environment)
+ ))
nil mustmatch nil 'read-envvar-name-history))
;; History list for VALUE argument to setenv.
(setq process-environment (setenv-internal process-environment
variable value t))
(setq frame (frame-with-environment frame))
- (set-frame-parameter frame 'environment
- (setenv-internal (frame-parameter frame 'environment)
- variable value nil)))
+ (cond
+ ((string-equal "TERM" variable)
+ (set-frame-parameter frame 'term-environment-variable value))
+ ((string-equal "DISPLAY" variable)
+ (set-frame-parameter frame 'display-environment-variable value))
+ (t
+ (setq process-environment (setenv-internal process-environment
+ variable value nil)))))
value)
(defun getenv (variable &optional frame)
`locale-coding-system', i.e. the elements must normally be decoded for use.
See `setenv' and `getenv'."
(let* ((env (append process-environment
- (frame-parameter (frame-with-environment frame)
- 'environment)
+;; (frame-parameter (frame-with-environment frame)
+;; 'environment)
nil))
(scan env)
prev seen)
(defun tty-set-up-initial-frame-faces ()
(let ((frame (selected-frame)))
(frame-set-background-mode frame)
- (face-set-after-frame-default frame)))
+ (face-set-after-frame-default frame)
+ (set-frame-parameter frame-initial-frame 'term-environment-variable
+ (getenv "TERM"))
+ (set-frame-parameter frame-initial-frame 'display-environment-variable
+ (getenv "DISPLAY"))))
;; Copy the environment of the Emacs process into the new frame.
(set-frame-parameter frame-initial-frame 'environment
(frame-parameter terminal-frame 'environment))
+ (set-frame-parameter frame-initial-frame 'term-environment-variable
+ (getenv "TERM"))
+ (set-frame-parameter frame-initial-frame 'display-environment-variable
+ (getenv "DISPLAY"))
;; At this point, we know that we have a frame open, so we
;; can delete the terminal frame.
(delete-frame terminal-frame)
(normal-erase-is-backspace-setup-frame frame)
;; Inherit the 'environment and 'client parameters.
(let ((env (frame-parameter oldframe 'environment))
- (client (frame-parameter oldframe 'client)))
+ (client (frame-parameter oldframe 'client))
+ (termenv (frame-parameter oldframe 'term-environment-variable))
+ (displayenv (frame-parameter oldframe 'display-environment-variable)))
(if (not (framep env))
(setq env oldframe))
(if (and env (not (assq 'environment parameters)))
(set-frame-parameter frame 'environment env))
+ (if (and termenv (not (assq 'term-environment-variable parameters)))
+ (set-frame-parameter frame 'term-environment-variable termenv))
+ (if (and displayenv (not (assq 'display-environment-variable parameters)))
+ (set-frame-parameter frame 'display-environment-variable displayenv))
(if (and client (not (assq 'client parameters)))
(set-frame-parameter frame 'client client)))
(run-hook-with-args 'after-make-frame-functions frame)
;; initialization parameters for X frames at
;; the moment.
(modify-frame-parameters frame params)
+ (set-frame-parameter frame 'display-environment-variable
+ (server-getenv-from env "DISPLAY"))
+ (set-frame-parameter frame 'term-environment-variable
+ (server-getenv-from env "TERM"))
(select-frame frame)
(server-client-set client 'frame frame)
(server-client-set client 'terminal (frame-terminal frame))
"BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES"
"NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING"
"NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO"
- "TERMINFO_DIRS" "TERMPATH")
+ "TERMINFO_DIRS" "TERMPATH"
+ ;; rxvt wants these
+ "COLORFGBG" "COLORTERM")
(setq frame (make-frame-on-tty tty type
;; Ignore nowait here; we always need to clean
;; up opened ttys when the client dies.
`((client . ,proc)
(environment . ,env)))))
+
+ (set-frame-parameter frame 'display-environment-variable
+ (server-getenv-from env "DISPLAY"))
+ (set-frame-parameter frame 'term-environment-variable
+ (server-getenv-from env "TERM"))
(select-frame frame)
(server-client-set client 'frame frame)
(server-client-set client 'tty (terminal-name frame))
--- /dev/null
+2007-07-02 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * frames.texi (Basic Parameters): Add display-environment-variable
+ and term-environment-variable.
+
+;; Local Variables:
+;; coding: iso-2022-7bit
+;; add-log-time-zone-rule: t
+;; End:
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Emacs.
+
+ GNU Emacs is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Emacs; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+
If you specify the frame name explicitly when you create the frame, the
name is also used (instead of the name of the Emacs executable) when
looking up X resources for the frame.
+
+@item display-environment-variable
+The value of the @code{DISPLAY} environment variable for the frame. It
+is passed to child processes.
+
+@item term-environment-variable
+The value of the @code{TERM} environment variable for the frame. It
+is passed to child processes.
@end table
@node Position Parameters
+2007-07-02 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * 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.
+
2007-06-03 Dan Nicolaescu <dann@ics.uci.edu>
* xselect.c (x_handle_selection_clear): Only access
{
char **env;
char *pwd_var;
+ char *term_var;
+ char *display_var;
#ifdef WINDOWSNT
int cpid;
HANDLE handles[3];
register char **new_env;
char **p, **q;
register int new_length;
- Lisp_Object local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)),
- Qenvironment);
+ Lisp_Object local = selected_frame; /* get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), */
+/* Qenvironment); */
+ Lisp_Object term;
+ Lisp_Object display;
+
new_length = 0;
for (tem = Vprocess_environment;
tem = XCDR (tem))
new_length++;
+#if 0
for (tem = local;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
new_length++;
+#endif
+
+ /* Add TERM and DISPLAY from the frame local values. */
+ term = get_frame_param (XFRAME (local), Qterm_environment_variable);
+ if (! NILP (term))
+ new_length++;
+
+ display = get_frame_param (XFRAME (local), Qdisplay_environment_variable);
+ if (! NILP (display))
+ new_length++;
/* new_length + 2 to include PWD and terminating 0. */
env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *));
if (egetenv ("PWD"))
*new_env++ = pwd_var;
+ if (! NILP (term))
+ {
+ int vlen = strlen ("TERM=") + strlen (SDATA (term)) + 1;
+ char *vdata = (char *) alloca (vlen);
+ strcpy (vdata, "TERM=");
+ strcat (vdata, SDATA (term));
+ new_env = add_env (env, new_env, vdata);
+ }
+
+ if (! NILP (display))
+ {
+ int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1;
+ char *vdata = (char *) alloca (vlen);
+ strcpy (vdata, "DISPLAY=");
+ strcat (vdata, SDATA (display));
+ new_env = add_env (env, new_env, vdata);
+ }
+
/* Overrides. */
for (tem = Vprocess_environment;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
- new_env = add_env (env, new_env, SDATA (XCAR (tem)));
+ {
+ if ((strcmp (SDATA (XCAR (tem)), "TERM") != 0)
+ && (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0))
+ new_env = add_env (env, new_env, SDATA (XCAR (tem)));
+ }
+
+#if 0
/* Local part of environment. */
for (tem = local;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
new_env = add_env (env, new_env, SDATA (XCAR (tem)));
-
+#endif
+
*new_env = 0;
/* Remove variable names without values. */
p++;
}
}
+
+
#ifdef WINDOWSNT
prepare_standard_handles (in, out, err, handles);
set_process_dir (SDATA (current_dir));
Lisp_Object frame;
{
Lisp_Object scan;
+ Lisp_Object term;
+ Lisp_Object display;
+
if (NILP (frame))
{
frame = selected_frame;
}
+ /* For TERM and DISPLAY first try to get the values from the frame. */
+ term = get_frame_param (XFRAME (frame), Qterm_environment_variable);
+ if (strcmp (var, "TERM") == 0)
+ if (! NILP (term))
+ {
+ *value = (char *) SDATA (term);
+ *valuelen = SBYTES (term);
+ return 1;
+ }
+ display = get_frame_param (XFRAME (frame), Qdisplay_environment_variable);
+ if (strcmp (var, "DISPLAY") == 0)
+ if (! NILP (display))
+ {
+ *value = (char *) SDATA (display);
+ *valuelen = SBYTES (display);
+ return 1;
+ }
+
+ {
+ /* Try to find VAR in Vprocess_environment. */
+ for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
+ {
+ Lisp_Object entry = XCAR (scan);
+ if (STRINGP (entry)
+ && SBYTES (entry) >= varlen
+#ifdef WINDOWSNT
+ /* NT environment variables are case insensitive. */
+ && ! strnicmp (SDATA (entry), var, varlen)
+#else /* not WINDOWSNT */
+ && ! bcmp (SDATA (entry), var, varlen)
+#endif /* not WINDOWSNT */
+ )
+ {
+ if (SBYTES (entry) > varlen && SREF (entry, varlen) == '=')
+ {
+ *value = (char *) SDATA (entry) + (varlen + 1);
+ *valuelen = SBYTES (entry) - (varlen + 1);
+ return 1;
+ }
+ else if (SBYTES (entry) == varlen)
+ {
+ /* Lone variable names in Vprocess_environment mean that
+ variable should be removed from the environment. */
+ return 0;
+ }
+ }
+ }
+ }
+
+#if 0
/* Find the environment in which to search the variable. */
CHECK_FRAME (frame);
frame = Fframe_with_environment (frame);
return 1;
}
}
-
+#endif
return 0;
}
set_initial_environment ()
{
register char **envp;
- Lisp_Object env = Qnil;
+ Lisp_Object env = Vprocess_environment;
#ifndef CANNOT_DUMP
if (initialized)
#endif
{
for (envp = environ; *envp; envp++)
- env = Fcons (build_string (*envp), env);
- store_frame_param (SELECTED_FRAME(), Qenvironment, env);
+ Vprocess_environment = Fcons (build_string (*envp),
+ Vprocess_environment);
+ store_frame_param (SELECTED_FRAME(), Qenvironment, Vprocess_environment);
}
}
Lisp_Object Qtty, Qtty_type;
Lisp_Object Qwindow_system;
Lisp_Object Qenvironment;
+Lisp_Object Qterm_environment_variable;
+Lisp_Object Qdisplay_environment_variable;
Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
staticpro (&Qwindow_system);
Qenvironment = intern ("environment");
staticpro (&Qenvironment);
-
+
+ Qterm_environment_variable = intern ("term-environment-variable");
+ staticpro (&Qterm_environment_variable);
+ Qdisplay_environment_variable = intern ("display-environment-variable");
+ staticpro (&Qdisplay_environment_variable);
+
Qface_set_after_frame_default = intern ("face-set-after-frame-default");
staticpro (&Qface_set_after_frame_default);
extern Lisp_Object Qtty, Qtty_type;
extern Lisp_Object Qterminal, Qterminal_live_p;
extern Lisp_Object Qenvironment;
+extern Lisp_Object Qterm_environment_variable;
+extern Lisp_Object Qdisplay_environment_variable;
extern struct frame *last_nonminibuf_frame;