]> git.eshelyaron.com Git - emacs.git/commitdiff
* server.el (server-process-filter): Likewise.
authorDan Nicolaescu <dann@ics.uci.edu>
Tue, 3 Jul 2007 04:53:21 +0000 (04:53 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Tue, 3 Jul 2007 04:53:21 +0000 (04:53 +0000)
(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.

lisp/ChangeLog.multi-tty
lisp/env.el
lisp/faces.el
lisp/frame.el
lisp/server.el
lispref/ChangeLog.multi-tty [new file with mode: 0644]
lispref/frames.texi
src/ChangeLog.multi-tty
src/callproc.c
src/frame.c
src/frame.h

index 6c04ee57077d62f0edaf7f96be0d6166d62821c0..cc115bb0278c78865594b9585a43a76fbae2c0d9 100644 (file)
@@ -1,5 +1,18 @@
 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>
index a6626dc08ff2cf2feb02657689a590147fc6e1b7..f2609cc6784c567dbf85d3ef50a1bd4edef00422 100644 (file)
@@ -55,7 +55,8 @@ If it is also not t, RET does not exit if it does non-null completion."
                                     (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.
@@ -191,9 +192,14 @@ a side-effect."
       (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)
@@ -238,8 +244,8 @@ Non-ASCII characters are encoded according to the initial value of
 `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)
index 32d0c0af0681430c0c9d2813a16e0bf9e54e9bd4..e5796272b0c66eaeeac30cc958e13b275e0451e5 100644 (file)
@@ -1909,7 +1909,11 @@ terminal type to a different value."
 (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"))))
 
 
 
index 5f32654fdb144db3c30c2aecfca8ab52c96e224a..925b61ce754e33d9e488f37c5265b33db66ab6bb 100644 (file)
@@ -241,6 +241,10 @@ Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
        ;; 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)
@@ -700,11 +704,17 @@ setup is for focus to follow the pointer."
     (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)
index 838aed96cf891fa7f51624cd45ac1275e3e9d545..60ba66c88fef8b2945f882560b8e7bb7302e5bba 100644 (file)
@@ -763,6 +763,10 @@ The following commands are accepted by the client:
                          ;; 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))
@@ -812,12 +816,19 @@ The following commands are accepted by the client:
                            "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))
diff --git a/lispref/ChangeLog.multi-tty b/lispref/ChangeLog.multi-tty
new file mode 100644 (file)
index 0000000..a36db67
--- /dev/null
@@ -0,0 +1,30 @@
+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.
+
+
index b8a0d4749e2abd387f5f16920cf095f942abef33..7d2ea7cf70ed71c50f9f56ba9dbef676a5b7bdd3 100644 (file)
@@ -378,6 +378,14 @@ you don't specify a name, Emacs sets the frame name automatically
 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
index eb45515703405938b289a5fbf3e170f79ef35f0c..05a7ec48d06faebec065f1b7266b33a4a46dd3a4 100644 (file)
@@ -1,3 +1,16 @@
+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
index ce9eb73dd5417c3ed4dd281428688b2901cdf5fc..a2d517b1bea78773b36ad174ae216443cd1b512c 100644 (file)
@@ -1245,6 +1245,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
 {
   char **env;
   char *pwd_var;
+  char *term_var;
+  char *display_var;
 #ifdef WINDOWSNT
   int cpid;
   HANDLE handles[3];
@@ -1325,9 +1327,12 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
     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;
@@ -1335,10 +1340,21 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
          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 *));
@@ -1348,18 +1364,43 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
     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.  */
@@ -1373,6 +1414,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
           p++;
       }
   }
+
+  
 #ifdef WINDOWSNT
   prepare_standard_handles (in, out, err, handles);
   set_process_dir (SDATA (current_dir));
@@ -1494,6 +1537,9 @@ getenv_internal (var, varlen, value, valuelen, frame)
      Lisp_Object frame;
 {
   Lisp_Object scan;
+  Lisp_Object term;
+  Lisp_Object display;
+  
 
   if (NILP (frame))
     {
@@ -1528,6 +1574,56 @@ getenv_internal (var, varlen, value, valuelen, 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);
@@ -1555,7 +1651,7 @@ getenv_internal (var, varlen, value, valuelen, frame)
          return 1;
        }
     }
-
+#endif
   return 0;
 }
 
@@ -1737,14 +1833,15 @@ void
 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);
     }
 }
 
index a1b4e6bd85f0506ade975c2d798784a37e728126..d081fbf55a2fc0f5954345f50a93712ae15c36dd 100644 (file)
@@ -111,6 +111,8 @@ Lisp_Object Qtty_color_mode;
 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;
 
@@ -4353,7 +4355,12 @@ syms_of_frame ()
   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);
 
index 5686662bb9636b552691df188ea74da9ac6c5a7b..161404fdd75efe1e4dd21e3f4c0d38d0abcdac7d 100644 (file)
@@ -780,6 +780,8 @@ extern Lisp_Object Qframep, Qframe_live_p;
 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;