emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Emacs only provides a dumb TERM


From: Stefan Monnier
Subject: Emacs only provides a dumb TERM
Date: 01 Jun 2004 19:07:23 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

It has happened several times that processes run by Emacs use funny control
sequences thinking they are run in an xterm or some such.  This has been
fixed in some packages such as compile.el by explicitly setting TERM to
"dumb" before running the underlying process.

A while back I had suggested to do that globally since it never makes any
sense for a subprocess to use the TERM setting that Emacs received (since
subprocesses never have direct access to the terminal in which Emacs is
running, if any).
At that time I'd been told that it was probably a good idea but that we
should wait for a better time to make the change.
I think now is a good time for that.

So I suggest the patch below.


        Stefan


PS: The patch actually includes a few other changes, which are just
code simplifications.  The most drastic simplification is the load-path
loop where I remove the unused `new' var, then remove the redundant (car
tail) arg of expand-file-name, and remove the stranegly empty
condition-cases, and finally use dolist.


--- orig/lisp/startup.el
+++ mod/lisp/startup.el
@@ -293,8 +293,8 @@
       (let* ((this-dir (car dirs))
             (contents (directory-files this-dir))
             (default-directory this-dir)
-            (canonicalized (and (eq system-type 'windows-nt)
-                                (untranslated-canonical-name this-dir))))
+            (canonicalized (if (fboundp 'untranslated-canonical-name)
+                               (untranslated-canonical-name this-dir))))
        ;; The Windows version doesn't report meaningful inode
        ;; numbers, so use the canonicalized absolute file name of the
        ;; directory instead.
@@ -343,12 +343,14 @@
     ;; Give *Messages* the same default-directory as *scratch*,
     ;; just to keep things predictable.
     (let ((dir default-directory))
-      (save-excursion
-       (set-buffer (get-buffer "*Messages*"))
+      (with-current-buffer "*Messages*"
        (setq default-directory dir)))
     ;; `user-full-name' is now known; reset its standard-value here.
     (put 'user-full-name 'standard-value
         (list (default-value 'user-full-name)))
+    ;; Subprocesses of Emacs do not have direct access to the terminal,
+    ;; so unless told otherwise they should only assume a dumb terminal.
+    (setenv "TERM" "dumb")
     ;; For root, preserve owner and group when editing files.
     (if (equal (user-uid) 0)
        (setq backup-by-copying-when-mismatch t))
@@ -357,19 +357,12 @@
     ;; of that dir into load-path,
     ;; Look for a leim-list.el file too.  Loading it will register
     ;; available input methods.
-    (let ((tail load-path)
-         new)
-      (while tail
-       (push (car tail) new)
-       (condition-case nil
-           (let ((default-directory (car tail)))
-             (load (expand-file-name "subdirs.el" (car tail)) t t t)))
-       (condition-case nil
-           (let ((default-directory (car tail)))
-             (load (expand-file-name "leim-list.el" (car tail)) t t t)))
-       (setq tail (cdr tail))))
+    (dolist (dir load-path)
+      (let ((default-directory dir))
+       (load (expand-file-name "subdirs.el") t t t))
+      (let ((default-directory dir))
+       (load (expand-file-name "leim-list.el") t t t)))
-    (if (not (eq system-type 'vax-vms))
-       (progn
+    (unless (eq system-type 'vax-vms)
          ;; If the PWD environment variable isn't accurate, delete it.
          (let ((pwd (getenv "PWD")))
            (and (stringp pwd)
@@ -382,7 +375,7 @@
                                     ".")))
                     (setq process-environment
                           (delete (concat "PWD=" pwd)
-                                  process-environment)))))))
+                              process-environment))))))
     (setq default-directory (abbreviate-file-name default-directory))
     (let ((menubar-bindings-done nil))
       (unwind-protect





reply via email to

[Prev in Thread] Current Thread [Next in Thread]