Mercurial > emacs
changeset 83074:34a7a8f40548
Fix background-mode on terminal frames (Dan Nicolaescu).
lisp/faces.el (frame-set-background-mode): Guess the background mode
on terminal frames from the termcap type string.
(tty-create-frame-with-faces): Switch to the new frame during its setup.
Load the customization library corresponding to the terminal type of the
newly created frame. (Reported by Dan Nicolaescu <dann at ics dot uci dot edu>.)
lisp/startup.el (normal-top-level): Moved background-mode heuristic to
frame-set-background-mode.
src/dispnew.c (init_display): Update the tty-type frame parameter of
the initial terminal frame.
src/frame.h (Qtty, Qtty_type): New externs.
src/term.c (term_init): Update comments.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-114
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 11 Mar 2004 01:11:38 +0000 |
parents | ced0b1beba09 |
children | 1281a5c8fb39 |
files | README.multi-tty lisp/faces.el lisp/startup.el src/dispnew.c src/frame.c src/frame.h src/term.c |
diffstat | 7 files changed, 64 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/README.multi-tty Mon Mar 08 13:39:35 2004 +0000 +++ b/README.multi-tty Thu Mar 11 01:11:38 2004 +0000 @@ -186,6 +186,14 @@ multi-locale setup. (E.g., while logging in from a remote client with a different locale.) +** Change Lisp code not to (getenv "TERM"); use the `tty-type' frame + parameter or the frame-tty-type function instead. + (M-x tags-search "TERM" helps with this.) + +** The terminal customization files in term/*.el tend to change global + parameters, which may confuse Emacs with multiple displays. Change + them to tweak only frame-local settings, if possible. + ** Dan Nicolaescu suggests that -nw should be added as an alias for -t in emacsclient. Good idea. (Alas, implementing this is not trivial, getopt_long does not seem to support two-letter ``short''
--- a/lisp/faces.el Mon Mar 08 13:39:35 2004 +0000 +++ b/lisp/faces.el Thu Mar 11 01:11:38 2004 +0000 @@ -1542,19 +1542,29 @@ (and (window-system frame) (x-get-resource "backgroundMode" "BackgroundMode"))) (bg-color (frame-parameter frame 'background-color)) + (tty-type (frame-parameter frame 'tty-type)) (bg-mode (cond (frame-background-mode) (bg-resource (intern (downcase bg-resource))) - ((and (null (window-system frame)) (null bg-color)) - ;; No way to determine this automatically (?). - 'dark) - ;; Unspecified frame background color can only happen - ;; on tty's. - ((member bg-color '(unspecified "unspecified-bg")) - 'dark) + ((and (null (window-system frame)) + ;; Unspecified frame background color can only + ;; happen on tty's. + (member bg-color '(nil unspecified "unspecified-bg"))) + ;; There is no way to determine the background mode + ;; automatically, so we make a guess based on the + ;; terminal type. + (if (and tty-type + (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" + tty-type)) + 'light + 'dark)) ((equal bg-color "unspecified-fg") ; inverted colors - 'light) + (if (and tty-type + (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" + tty-type)) + 'dark + 'light)) ((>= (apply '+ (x-color-values bg-color frame)) ;; Just looking at the screen, colors whose ;; values add up to .6 of the white total @@ -1746,15 +1756,30 @@ `default-frame-alist'. If either PARAMETERS or `default-frame-alist' contains a `reverse' parameter, handle that. Value is the new frame created." - (let ((frame (make-terminal-frame parameters)) + (let ((old-frame (selected-frame)) + (frame (make-terminal-frame parameters)) success) (unwind-protect (progn + (select-frame frame) (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) + (while (and 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 success t)) (unless success + (select-frame old-frame) (delete-frame frame))) frame))
--- a/lisp/startup.el Mon Mar 08 13:39:35 2004 +0000 +++ b/lisp/startup.el Thu Mar 11 01:11:38 2004 +0000 @@ -434,30 +434,12 @@ ;; ...-frame-alist. (if (fboundp 'frame-notice-user-settings) (frame-notice-user-settings)) + ;; Set the faces for the initial background mode even if + ;; frame-notice-user-settings didn't (such as on a tty). + ;; frame-set-background-mode is idempotent, so it won't + ;; cause any harm if it's already been done. (if (fboundp 'frame-set-background-mode) - ;; Set the faces for the initial background mode even if - ;; frame-notice-user-settings didn't (such as on a tty). - ;; frame-set-background-mode is idempotent, so it won't - ;; cause any harm if it's already been done. - (let ((frame-background-mode frame-background-mode) - (frame (selected-frame)) - term) - (when (and (null initial-window-system) - ;; Don't override a possibly customized value. - (null frame-background-mode) - ;; Don't override user specifications. - (null (frame-parameter frame 'reverse)) - (let ((bg (frame-parameter frame 'background-color))) - (or (null bg) - (member bg '(unspecified "unspecified-bg"))))) - (setq term (getenv "TERM")) - ;; Some files in lisp/term do a better job with the - ;; background mode, but we leave this here anyway, in - ;; case they remove those files. - (if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" - term) - (setq frame-background-mode 'light))) - (frame-set-background-mode (selected-frame))))) + (frame-set-background-mode (selected-frame)))) ;; Now we know the user's default font, so add it to the menu. (if (fboundp 'font-menu-add-default) @@ -629,13 +611,12 @@ (setq eol-mnemonic-dos "(DOS)" eol-mnemonic-mac "(Mac)"))) - ;; Read window system's init file if using a window system. + ;; Make sure window system's init file was loaded in loadup.el if using a window system. (condition-case error (unless noninteractive (if (and initial-window-system (not (featurep - (intern (concat (symbol-name initial-window-system) - "-win"))))) + (intern (concat (symbol-name initial-window-system) "-win"))))) (error "Unsupported window system `%s'" initial-window-system)) ;; Process window-system specific command line parameters. (setq command-line-args
--- a/src/dispnew.c Mon Mar 08 13:39:35 2004 +0000 +++ b/src/dispnew.c Thu Mar 11 01:11:38 2004 +0000 @@ -6731,6 +6731,11 @@ if (--initial_display->reference_count == 0 && initial_display->delete_display_hook) (*initial_display->delete_display_hook) (initial_display); + + /* Update frame parameters to reflect the new type. */ + Fmodify_frame_parameters + (selected_frame, Fcons (Fcons (Qtty_type, + Fframe_tty_type (selected_frame)), Qnil)); } {
--- a/src/frame.c Mon Mar 08 13:39:35 2004 +0000 +++ b/src/frame.c Thu Mar 11 01:11:38 2004 +0000 @@ -697,7 +697,6 @@ Lisp_Object tty, tty_type; char *name = 0, *type = 0; - /* XXX Ugh, there must be a better way to do this. */ tty = Fassq (Qtty, parms); if (EQ (tty, Qnil)) tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
--- a/src/frame.h Mon Mar 08 13:39:35 2004 +0000 +++ b/src/frame.h Thu Mar 11 01:11:38 2004 +0000 @@ -774,6 +774,7 @@ extern Lisp_Object Qframep, Qframe_live_p; +extern Lisp_Object Qtty, Qtty_type; extern struct frame *last_nonminibuf_frame;
--- a/src/term.c Mon Mar 08 13:39:35 2004 +0000 +++ b/src/term.c Thu Mar 11 01:11:38 2004 +0000 @@ -2253,6 +2253,10 @@ display = get_named_tty_display (name); if (display) { + /* XXX We would be able to support multiple emacsclients from + the same terminal if display devices were Lisp objects. + (Lisp code must know the difference between two separate + displays on the same terminal device.) -- lorentey */ if (! display->display_info.tty->input) error ("%s already has a suspended frame on it, can't open it twice", name); return display; @@ -2320,11 +2324,11 @@ if we don't have one at the moment. */ fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); #else - /* Alas, O_IGNORE_CTTY is a GNU extension that is only defined - on Hurd. On other systems, we need to dissociate ourselves - from the controlling tty when we want to open a frame on the - same terminal. The function setsid should be used for this, - but it didn't work for me. */ + /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only + defined on Hurd. On other systems, we need to dissociate + ourselves from the controlling tty when we want to open a + frame on the same terminal. The function setsid should be + used for this, but it didn't work for me. */ fd = emacs_open (name, O_RDWR | O_NOCTTY, 0);