all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Emacs only provides a dumb TERM
Date: 01 Jun 2004 19:07:23 -0400	[thread overview]
Message-ID: <m1zn7m996g.fsf-monnier+emacs@gnu.org> (raw)


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	other threads:[~2004-06-01 23:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-01 23:07 Stefan Monnier [this message]
2004-06-01 23:23 ` Emacs only provides a dumb TERM Kim F. Storm
2004-06-02 17:37 ` Richard Stallman
2004-08-20 22:40 ` Stefan Monnier
2004-08-27 21:08   ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1zn7m996g.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.