+2007-09-15 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * xt-mouse.el (xterm-mouse-mode): Add hooks here not at the top
+ level. Remove the hooks when turning off the mode.
+
+ * term/xterm.el: Require xt-mouse at compile time.
+ (terminal-init-xterm): Turn on xterm mouse tracking for this
+ terminal if xterm-mouse-mode is enabled.
+
2007-09-14 Dan Nicolaescu <dann@ics.uci.edu>
* term/xterm.el (xterm-function-map): Replace bindings that were
;;; Code:
+(eval-when-compile (require 'xt-mouse))
+
(defvar xterm-function-map
(let ((map (make-sparse-keymap)))
(xterm-register-default-colors)
;; This recomputes all the default faces given the colors we've just set up.
(tty-set-up-initial-frame-faces)
-
+
+ (when xterm-mouse-mode
+ (turn-on-xterm-mouse-tracking-on-terminal
+ (frame-terminal (selected-frame))))
+
;; Try to turn on the modifyOtherKeys feature on modern xterms.
;; When it is turned on much more key bindings work: things like
;; C-. C-, etc.
(if xterm-mouse-mode
;; Turn it on
(progn
+ ;; Frame creation and deletion.
+ (add-hook 'after-make-frame-functions
+ 'turn-on-xterm-mouse-tracking-on-terminal)
+ (add-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
+
+ ;; Restore normal mouse behaviour outside Emacs.
+ (add-hook 'suspend-tty-functions
+ 'turn-off-xterm-mouse-tracking-on-terminal)
+ (add-hook 'resume-tty-functions
+ 'turn-on-xterm-mouse-tracking-on-terminal)
+ (add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
+ (add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
+ (add-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)
(setq mouse-position-function #'xterm-mouse-position-function)
(turn-on-xterm-mouse-tracking))
;; Turn it off
+ (remove-hook 'after-make-frame-functions
+ 'turn-on-xterm-mouse-tracking-on-terminal)
+ (remove-hook 'delete-frame-functions 'xterm-mouse-handle-delete-frame)
+ (remove-hook 'suspend-tty-functions
+ 'turn-off-xterm-mouse-tracking-on-terminal)
+ (remove-hook 'resume-tty-functions
+ 'turn-on-xterm-mouse-tracking-on-terminal)
+ (remove-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
+ (remove-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
+ (remove-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)
(turn-off-xterm-mouse-tracking 'force)
(setq mouse-position-function nil)))