diff options
| author | Dan Nicolaescu | 2007-07-16 04:05:08 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-07-16 04:05:08 +0000 |
| commit | 2b1070c8f0cf09e10dbca4e3b298d961ea99c036 (patch) | |
| tree | fbdb2821bf800c3ac7d1aad97373f8a1cf46b036 | |
| parent | fd5306d288cffa8397d9fd8187872208525713f0 (diff) | |
| download | emacs-2b1070c8f0cf09e10dbca4e3b298d961ea99c036.tar.gz emacs-2b1070c8f0cf09e10dbca4e3b298d961ea99c036.zip | |
(xterm-turn-on-modify-other-keys)
(xterm-turn-off-modify-other-keys): New functions.
(terminal-init-xterm): Enable the modifyOtherKeys feature if the
terminal supports it.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/term/xterm.el | 40 |
2 files changed, 46 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3fff69b4d1b..0f527e004a8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2007-07-16 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * term/xterm.el (xterm-turn-on-modify-other-keys) | ||
| 4 | (xterm-turn-off-modify-other-keys): New functions. | ||
| 5 | (terminal-init-xterm): Enable the modifyOtherKeys feature if the | ||
| 6 | terminal supports it. | ||
| 7 | |||
| 1 | 2007-07-16 Thien-Thi Nguyen <ttn@gnuvola.org> | 8 | 2007-07-16 Thien-Thi Nguyen <ttn@gnuvola.org> |
| 2 | 9 | ||
| 3 | * bookmark.el (bookmark-show-all-annotations): | 10 | * bookmark.el (bookmark-show-all-annotations): |
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index a7249536f7b..5d26b4abd34 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el | |||
| @@ -400,7 +400,37 @@ | |||
| 400 | ;; Do it! | 400 | ;; Do it! |
| 401 | (xterm-register-default-colors) | 401 | (xterm-register-default-colors) |
| 402 | ;; This recomputes all the default faces given the colors we've just set up. | 402 | ;; This recomputes all the default faces given the colors we've just set up. |
| 403 | (tty-set-up-initial-frame-faces))) | 403 | (tty-set-up-initial-frame-faces) |
| 404 | |||
| 405 | ;; Try to turn on the modifyOtherKeys feature on modern xterms. | ||
| 406 | ;; When it is turned on much more key bindings work: things like | ||
| 407 | ;; C-. C-, etc. | ||
| 408 | ;; To do that we need to find out if the current terminal supports | ||
| 409 | ;; modifyOtherKeys. At this time only xterm does. | ||
| 410 | (let ((coding-system-for-read 'binary) | ||
| 411 | (chr nil) | ||
| 412 | (str nil)) | ||
| 413 | ;; Try to find out the type of terminal by sending a "Secondary | ||
| 414 | ;; Device Attributes (DA)" query. | ||
| 415 | (send-string-to-terminal "\e[>0c") | ||
| 416 | |||
| 417 | ;; The reply should be of the form: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c | ||
| 418 | (when (equal (read-event nil nil 0.1) ?\e) | ||
| 419 | (when (equal (read-event nil nil 0.1) ?\[) | ||
| 420 | (while (not (equal (setq chr (read-event nil nil 0.1)) ?c)) | ||
| 421 | (setq str (concat str (string chr)))) | ||
| 422 | (when (string-match ">0;\\([0-9]+\\);0" str) | ||
| 423 | ;; NUMBER2 is the xterm version number, look for something | ||
| 424 | ;; greater than 216, the version when modifyOtherKeys was | ||
| 425 | ;; introduced. | ||
| 426 | (when (>= (string-to-number | ||
| 427 | (substring str (match-beginning 1) (match-end 1))) 216) | ||
| 428 | ;; Make sure that the modifyOtherKeys state is restored when | ||
| 429 | ;; suspending, resuming and exiting. | ||
| 430 | (add-hook 'suspend-hook 'xterm-turn-off-modify-other-keys) | ||
| 431 | (add-hook 'suspend-resume-hook 'xterm-turn-on-modify-other-keys) | ||
| 432 | (add-hook 'kill-emacs-hook 'xterm-turn-off-modify-other-keys) | ||
| 433 | (xterm-turn-on-modify-other-keys)))))))) | ||
| 404 | 434 | ||
| 405 | ;; Set up colors, for those versions of xterm that support it. | 435 | ;; Set up colors, for those versions of xterm that support it. |
| 406 | (defvar xterm-standard-colors | 436 | (defvar xterm-standard-colors |
| @@ -518,5 +548,13 @@ versions of xterm." | |||
| 518 | ;; right colors, so clear them. | 548 | ;; right colors, so clear them. |
| 519 | (clear-face-cache))) | 549 | (clear-face-cache))) |
| 520 | 550 | ||
| 551 | (defun xterm-turn-on-modify-other-keys () | ||
| 552 | "Turn on the modifyOtherKeys feature of xterm." | ||
| 553 | (send-string-to-terminal "\e[>4;1m")) | ||
| 554 | |||
| 555 | (defun xterm-turn-off-modify-other-keys () | ||
| 556 | "Turn off the modifyOtherKeys feature of xterm." | ||
| 557 | (send-string-to-terminal "\e[>4m")) | ||
| 558 | |||
| 521 | ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a | 559 | ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a |
| 522 | ;;; xterm.el ends here | 560 | ;;; xterm.el ends here |