diff options
| author | Glenn Morris | 2011-06-12 12:58:32 -0700 |
|---|---|---|
| committer | Glenn Morris | 2011-06-12 12:58:32 -0700 |
| commit | 7cb363eba045bddc743a0b9ea8113a844fe11cf2 (patch) | |
| tree | 0513b8e08d4e69d52e5b2d5fb4f1f7bf788f13cd | |
| parent | 9db51acaf1991e638e07fc6a624265d4d64b74ae (diff) | |
| download | emacs-7cb363eba045bddc743a0b9ea8113a844fe11cf2.tar.gz emacs-7cb363eba045bddc743a0b9ea8113a844fe11cf2.zip | |
* term/xterm.el (terminal-init-xterm): Misc simplifications.
| -rw-r--r-- | lisp/ChangeLog | 1 | ||||
| -rw-r--r-- | lisp/term/xterm.el | 138 |
2 files changed, 68 insertions, 71 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 23d6b097504..6f7afeb2af3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | 2011-06-12 Glenn Morris <rgm@gnu.org> | 1 | 2011-06-12 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * term/xterm.el (terminal-init-xterm): `version' may be nil. (Bug#8838) | 3 | * term/xterm.el (terminal-init-xterm): `version' may be nil. (Bug#8838) |
| 4 | Misc simplifications. | ||
| 4 | 5 | ||
| 5 | 2011-06-12 Martin Rudalics <rudalics@gmx.at> | 6 | 2011-06-12 Martin Rudalics <rudalics@gmx.at> |
| 6 | 7 | ||
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index e345b4dda8f..b0fe443ca59 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el | |||
| @@ -484,7 +484,7 @@ features. Set to nil to skip the checks." | |||
| 484 | ;; When it is turned on many more key bindings work: things like | 484 | ;; When it is turned on many more key bindings work: things like |
| 485 | ;; C-. C-, etc. | 485 | ;; C-. C-, etc. |
| 486 | ;; To do that we need to find out if the current terminal supports | 486 | ;; To do that we need to find out if the current terminal supports |
| 487 | ;; modifyOtherKeys. At this time only xterm does. | 487 | ;; modifyOtherKeys. At this time only xterm does. |
| 488 | (when xterm-extra-capabilities | 488 | (when xterm-extra-capabilities |
| 489 | (let ((coding-system-for-read 'binary) | 489 | (let ((coding-system-for-read 'binary) |
| 490 | (chr nil) | 490 | (chr nil) |
| @@ -498,80 +498,76 @@ features. Set to nil to skip the checks." | |||
| 498 | ;; we don't need to check for any capabilities because | 498 | ;; we don't need to check for any capabilities because |
| 499 | ;; they are given by setting `xterm-extra-capabilities' to | 499 | ;; they are given by setting `xterm-extra-capabilities' to |
| 500 | ;; a list (which could be empty). | 500 | ;; a list (which could be empty). |
| 501 | (tocheck-capabilities (when (eq 'check xterm-extra-capabilities) | 501 | (tocheck-capabilities (if (eq 'check xterm-extra-capabilities) |
| 502 | '(modifyOtherKeys reportBackground))) | 502 | '(modifyOtherKeys reportBackground))) |
| 503 | ;; The given capabilities are either the contents of | 503 | ;; The given capabilities are either the contents of |
| 504 | ;; `xterm-extra-capabilities', if it's a list, or an empty | 504 | ;; `xterm-extra-capabilities', if it's a list, or an empty list. |
| 505 | ;; list. | 505 | (given-capabilities (if (consp xterm-extra-capabilities) |
| 506 | (given-capabilities (when (consp xterm-extra-capabilities) | 506 | xterm-extra-capabilities)) |
| 507 | xterm-extra-capabilities)) | ||
| 508 | version) | 507 | version) |
| 509 | 508 | ;; 1. Set `version' | |
| 510 | ;; Do the following if `xterm-extra-capabilities' is anything but nil. | 509 | |
| 511 | (when xterm-extra-capabilities | 510 | ;; Pending input can be mistakenly returned by the calls to |
| 512 | ;; 1. Set `version' | 511 | ;; read-event below. Discard it. |
| 513 | 512 | (discard-input) | |
| 514 | ;; Pending input can be mistakenly returned by the calls to | 513 | ;; Try to find out the type of terminal by sending a "Secondary |
| 515 | ;; read-event below. Discard it. | 514 | ;; Device Attributes (DA)" query. |
| 516 | (discard-input) | 515 | (send-string-to-terminal "\e[>0c") |
| 517 | ;; Try to find out the type of terminal by sending a "Secondary | 516 | |
| 518 | ;; Device Attributes (DA)" query. | 517 | ;; The reply should be: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c |
| 519 | (send-string-to-terminal "\e[>0c") | 518 | ;; If the timeout is completely removed for read-event, this |
| 520 | 519 | ;; might hang for terminals that pretend to be xterm, but don't | |
| 521 | ;; The reply should be: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c | 520 | ;; respond to this escape sequence. RMS' opinion was to remove |
| 522 | ;; If the timeout is completely removed for read-event, this | 521 | ;; it completely. That might be right, but let's first try to |
| 523 | ;; might hang for terminals that pretend to be xterm, but don't | 522 | ;; see if by using a longer timeout we get rid of most issues. |
| 524 | ;; respond to this escape sequence. RMS' opinion was to remove | 523 | (when (and (equal (read-event nil nil 2) ?\e) |
| 525 | ;; it completely. That might be right, but let's first try to | 524 | (equal (read-event nil nil 2) ?\[)) |
| 526 | ;; see if by using a longer timeout we get rid of most issues. | 525 | (while (not (equal (setq chr (read-event nil nil 2)) ?c)) |
| 527 | (when (equal (read-event nil nil 2) ?\e) | 526 | (setq str (concat str (string chr)))) |
| 528 | (when (equal (read-event nil nil 2) ?\[) | 527 | (if (string-match ">0;\\([0-9]+\\);0" str) |
| 529 | (while (not (equal (setq chr (read-event nil nil 2)) ?c)) | 528 | (setq version |
| 530 | (setq str (concat str (string chr)))) | 529 | (string-to-number |
| 531 | (when (string-match ">0;\\([0-9]+\\);0" str) | 530 | (substring str (match-beginning 1) (match-end 1)))))) |
| 532 | (setq version | 531 | |
| 533 | (string-to-number | 532 | ;; 2. If reportBackground is known to be supported, or the |
| 534 | (substring str (match-beginning 1) (match-end 1))))))) | 533 | ;; version is 242 or higher, assume the xterm supports |
| 535 | 534 | ;; reporting the background color (TODO: maybe earlier | |
| 536 | ;; 2. If reportBackground is known to be supported, or the | 535 | ;; versions do too...) |
| 537 | ;; version is 242 or higher, assume the xterm supports | 536 | (when (or (memq 'reportBackground given-capabilities) |
| 538 | ;; reporting the background color (TODO: maybe earlier | 537 | (and (memq 'reportBackground tocheck-capabilities) |
| 539 | ;; versions do too...) | 538 | version |
| 540 | (when (or (memq 'reportBackground given-capabilities) | 539 | (>= version 242))) |
| 541 | (and (memq 'reportBackground tocheck-capabilities) | 540 | (send-string-to-terminal "\e]11;?\e\\") |
| 542 | version | 541 | (when (and (equal (read-event nil nil 2) ?\e) |
| 543 | (>= version 242))) | 542 | (equal (read-event nil nil 2) ?\])) |
| 544 | (send-string-to-terminal "\e]11;?\e\\") | 543 | (setq str "") |
| 545 | (when (equal (read-event nil nil 2) ?\e) | 544 | (while (not (equal (setq chr (read-event nil nil 2)) ?\\)) |
| 546 | (when (equal (read-event nil nil 2) ?\]) | 545 | (setq str (concat str (string chr)))) |
| 547 | (setq str "") | 546 | (if (string-match background-regex str) |
| 548 | (while (not (equal (setq chr (read-event nil nil 2)) ?\\)) | 547 | (setq recompute-faces |
| 549 | (setq str (concat str (string chr)))) | 548 | (xterm-maybe-set-dark-background-mode |
| 550 | (when (string-match background-regex str) | 549 | (string-to-number (match-string 1 str) 16) |
| 551 | (setq recompute-faces | 550 | (string-to-number (match-string 2 str) 16) |
| 552 | (xterm-maybe-set-dark-background-mode | 551 | (string-to-number (match-string 3 str) 16)))))) |
| 553 | (string-to-number (match-string 1 str) 16) | 552 | |
| 554 | (string-to-number (match-string 2 str) 16) | 553 | ;; 3. If modifyOtherKeys is known to be supported or the |
| 555 | (string-to-number (match-string 3 str) 16))))))) | 554 | ;; version is 216 (the version when modifyOtherKeys was |
| 556 | 555 | ;; introduced) or higher, initialize the modifyOtherKeys | |
| 557 | ;; 3. If modifyOtherKeys is known to be supported or the | 556 | ;; support. |
| 558 | ;; version is 216 (the version when modifyOtherKeys was | 557 | (if (or (memq 'modifyOtherKeys given-capabilities) |
| 559 | ;; introduced) or higher, initialize the modifyOtherKeys | 558 | (and (memq 'modifyOtherKeys tocheck-capabilities) |
| 560 | ;; support. | 559 | version |
| 561 | (when (or (memq 'modifyOtherKeys given-capabilities) | 560 | (>= version 216))) |
| 562 | (and (memq 'modifyOtherKeys tocheck-capabilities) | ||
| 563 | version | ||
| 564 | (>= version 216))) | ||
| 565 | (terminal-init-xterm-modify-other-keys)) | 561 | (terminal-init-xterm-modify-other-keys)) |
| 566 | 562 | ||
| 567 | ;; Recompute faces here in case the background mode was | 563 | ;; Recompute faces here in case the background mode was |
| 568 | ;; set to dark. We used to call | 564 | ;; set to dark. We used to call |
| 569 | ;; `tty-set-up-initial-frame-faces' only once, but that | 565 | ;; `tty-set-up-initial-frame-faces' only once, but that |
| 570 | ;; caused the light background faces to be computed | 566 | ;; caused the light background faces to be computed |
| 571 | ;; incorrectly. See: | 567 | ;; incorrectly. See: |
| 572 | ;; http://permalink.gmane.org/gmane.emacs.devel/119627 | 568 | ;; http://permalink.gmane.org/gmane.emacs.devel/119627 |
| 573 | (when recompute-faces | 569 | (when recompute-faces |
| 574 | (tty-set-up-initial-frame-faces))))) | 570 | (tty-set-up-initial-frame-faces)))) |
| 575 | 571 | ||
| 576 | (run-hooks 'terminal-init-xterm-hook)) | 572 | (run-hooks 'terminal-init-xterm-hook)) |
| 577 | 573 | ||