changeset 83359:8f0c7632f259

Slightly refactor the terminal initialization code for simplicity. * lisp/faces.el (tty-run-terminal-initialization): New function. (tty-create-frame-with-faces): Use it. * lisp/startup.el (command-line): Replace duplicated code with a call to tty-run-terminal-initialization. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-399
author Karoly Lorentey <lorentey@elte.hu>
date Wed, 07 Sep 2005 02:29:18 +0000
parents 07db5d4dfae1
children 0036e612aaef
files README.multi-tty lisp/faces.el lisp/startup.el
diffstat 3 files changed, 34 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/README.multi-tty	Wed Sep 07 02:22:52 2005 +0000
+++ b/README.multi-tty	Wed Sep 07 02:29:18 2005 +0000
@@ -386,6 +386,14 @@
 THINGS TO DO
 ------------
 
+** Dan Nicolaescu writes:
+   > The terminal initialization code still has some issues. 
+   > This can be seen when using emacsclient -t on a 256 color xterm. The
+   > terminal frame is only created with 8 color. 
+   > The reason is that terminal-init-xterm calls
+   > xterm-register-default-colors which calls (display-color-cells (selected-frame))
+   > and probably `selected-frame' is not completely setup at that time. 
+   
 ** emacsclient --no-wait and --eval is currently broken.
 
 ** xt-mouse.el needs to be adapted for multi-tty.  It currently
--- a/lisp/faces.el	Wed Sep 07 02:22:52 2005 +0000
+++ b/lisp/faces.el	Wed Sep 07 02:29:18 2005 +0000
@@ -1816,38 +1816,39 @@
 	  (tty-handle-reverse-video frame (frame-parameters frame))
 	  (frame-set-background-mode frame)
 	  (face-set-after-frame-default frame)
-	  ;; Load library for our terminal type.
-	  ;; User init file can set term-file-prefix to nil to prevent this.
-	  (unless (null term-file-prefix)
-	    (let ((term (cdr (assq 'tty-type parameters)))
-		  hyphend
-		  term-init-func)
-	      (while (and term
-			  (not (fboundp 
-				(setq term-init-func (intern (concat "terminal-init-" term)))))
-			  (not (load (concat term-file-prefix term) t t)))
-		;; Strip off last hyphen and what follows, then try again
-		(setq term
-		      (if (setq hyphend (string-match "[-_][^-_]+$" term))
-			  (substring term 0 hyphend)
-			nil))
-		(setq term-init-func nil))
-	      (when term
-		;; The terminal file has been loaded, now call the terminal
-		;; specific initialization function.
-		(unless term-init-func 
-		  (setq term-init-func (intern (concat "terminal-init-" term)))
-		  (when (fboundp term-init-func)
-		    (funcall term-init-func))))))
+
 	  ;; Make sure the kill and yank functions do not touch the X clipboard.
 	  (modify-frame-parameters frame '((interprogram-cut-function . nil)))
 	  (modify-frame-parameters frame '((interprogram-paste-function . nil)))
+
 	  (set-locale-environment nil frame)
+	  (tty-run-terminal-initialization frame)
 	  (setq success t))
       (unless success
 	(delete-frame frame)))
     frame))
 
+(defun tty-run-terminal-initialization (frame)
+  "Run the special initialization code for the terminal type of FRAME."
+  ;; Load library for our terminal type.
+  ;; User init file can set term-file-prefix to nil to prevent this.
+  (with-selected-frame frame
+    (unless (null term-file-prefix)
+      (let ((term (frame-parameter frame 'tty-type))
+	    hyphend term-init-func)
+	(while (and term
+		    (not (fboundp
+			  (setq term-init-func (intern (concat "terminal-init-" term)))))
+		    (not (load (concat term-file-prefix term) t t)))
+	  ;; Strip off last hyphen and what follows, then try again
+	  (setq term
+		(if (setq hyphend (string-match "[-_][^-_]+$" term))
+		    (substring term 0 hyphend)
+		  nil)))
+	(when (and term (fboundp term-init-func))
+	  ;; The terminal file has been loaded, now call the terminal
+	  ;; specific initialization function.
+	  (funcall term-init-func))))))
 
 ;; Called from C function init_display to initialize faces of the
 ;; dumped terminal frame on startup.
--- a/lisp/startup.el	Wed Sep 07 02:22:52 2005 +0000
+++ b/lisp/startup.el	Wed Sep 07 02:29:18 2005 +0000
@@ -979,28 +979,8 @@
   ;; Load library for our terminal type.
   ;; User init file can set term-file-prefix to nil to prevent this.
   (unless (or noninteractive
-              initial-window-system
-              (null term-file-prefix))
-    (let ((term (getenv "TERM"))
-          hyphend
-	  term-init-func)
-      (while (and term
-		  (not (fboundp 
-			(setq term-init-func (intern (concat "terminal-init-" term)))))
-                  (not (load (concat term-file-prefix term) t t)))
-        ;; Strip off last hyphen and what follows, then try again
-        (setq term
-              (if (setq hyphend (string-match "[-_][^-_]+$" term))
-                  (substring term 0 hyphend)
-                nil))
-	(setq term-init-func nil))
-      (when term
-	;; The terminal file has been loaded, now call the terminal
-	;; specific initialization function.
-	(unless term-init-func 
-	  (setq term-init-func (intern (concat "terminal-init-" term)))
-	  (when (fboundp term-init-func)
-	    (funcall term-init-func))))))
+              initial-window-system)
+    (tty-run-terminal-initialization (selected-frame)))
 
   ;; Update the out-of-memory error message based on user's key bindings
   ;; for save-some-buffers.