diff options
| author | Stefan Monnier | 2002-04-12 03:33:20 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-04-12 03:33:20 +0000 |
| commit | c6005bf36e701b8abd23ed58f8c9eb53ef2fad83 (patch) | |
| tree | 5ce7fbf048521c66160bcd4343a52dedeaf2e3ae | |
| parent | efcc2791fae2a2bf44ddb18b7a86d37dee7205ce (diff) | |
| download | emacs-c6005bf36e701b8abd23ed58f8c9eb53ef2fad83.tar.gz emacs-c6005bf36e701b8abd23ed58f8c9eb53ef2fad83.zip | |
(xterm-mouse-mode): Use define-minor-mode.
| -rw-r--r-- | lisp/xt-mouse.el | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index b03539532c3..d5c67978424 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el | |||
| @@ -106,7 +106,6 @@ | |||
| 106 | "Position of last xterm mouse event relative to the frame.") | 106 | "Position of last xterm mouse event relative to the frame.") |
| 107 | 107 | ||
| 108 | ;; Indicator for the xterm-mouse mode. | 108 | ;; Indicator for the xterm-mouse mode. |
| 109 | (defvar xterm-mouse-mode nil) | ||
| 110 | 109 | ||
| 111 | (defun xterm-mouse-position-function (pos) | 110 | (defun xterm-mouse-position-function (pos) |
| 112 | "Bound to `mouse-position-function' in XTerm mouse mode." | 111 | "Bound to `mouse-position-function' in XTerm mouse mode." |
| @@ -159,41 +158,30 @@ | |||
| 159 | (list window pos point | 158 | (list window pos point |
| 160 | (/ (nth 2 (current-time)) 1000))))) | 159 | (/ (nth 2 (current-time)) 1000))))) |
| 161 | 160 | ||
| 162 | (or (assq 'xterm-mouse-mode minor-mode-alist) | ||
| 163 | (setq minor-mode-alist | ||
| 164 | (cons '(xterm-mouse-mode (" Mouse")) minor-mode-alist))) | ||
| 165 | |||
| 166 | ;;;###autoload | 161 | ;;;###autoload |
| 167 | (defun xterm-mouse-mode (arg) | 162 | (define-minor-mode xterm-mouse-mode |
| 168 | "Toggle XTerm mouse mode. | 163 | "Toggle XTerm mouse mode. |
| 169 | With prefix arg, turn XTerm mouse mode on iff arg is positive. | 164 | With prefix arg, turn XTerm mouse mode on iff arg is positive. |
| 170 | 165 | ||
| 171 | Turn it on to use emacs mouse commands, and off to use xterm mouse commands." | 166 | Turn it on to use emacs mouse commands, and off to use xterm mouse commands." |
| 172 | (interactive "P") | 167 | nil " Mouse" nil |
| 173 | (if (or (and (null arg) xterm-mouse-mode) | 168 | (if xterm-mouse-mode |
| 174 | (<= (prefix-numeric-value arg) 0)) | 169 | ;; Turn it on |
| 175 | ;; Turn it off | 170 | (unless window-system |
| 176 | (if xterm-mouse-mode | 171 | (setq mouse-position-function #'xterm-mouse-position-function) |
| 177 | (progn | 172 | (turn-on-xterm-mouse-tracking)) |
| 178 | (turn-off-xterm-mouse-tracking) | 173 | ;; Turn it off |
| 179 | (setq xterm-mouse-mode nil | 174 | (turn-off-xterm-mouse-tracking 'force) |
| 180 | mouse-position-function nil) | 175 | (setq mouse-position-function nil))) |
| 181 | (set-buffer-modified-p (buffer-modified-p)))) | ||
| 182 | ;;Turn it on | ||
| 183 | (unless (or window-system xterm-mouse-mode) | ||
| 184 | (setq xterm-mouse-mode t | ||
| 185 | mouse-position-function #'xterm-mouse-position-function) | ||
| 186 | (turn-on-xterm-mouse-tracking) | ||
| 187 | (set-buffer-modified-p (buffer-modified-p))))) | ||
| 188 | 176 | ||
| 189 | (defun turn-on-xterm-mouse-tracking () | 177 | (defun turn-on-xterm-mouse-tracking () |
| 190 | "Enable Emacs mouse tracking in xterm." | 178 | "Enable Emacs mouse tracking in xterm." |
| 191 | (if xterm-mouse-mode | 179 | (if xterm-mouse-mode |
| 192 | (send-string-to-terminal "\e[?1000h"))) | 180 | (send-string-to-terminal "\e[?1000h"))) |
| 193 | 181 | ||
| 194 | (defun turn-off-xterm-mouse-tracking () | 182 | (defun turn-off-xterm-mouse-tracking (&optional force) |
| 195 | "Disable Emacs mouse tracking in xterm." | 183 | "Disable Emacs mouse tracking in xterm." |
| 196 | (if xterm-mouse-mode | 184 | (if (or force xterm-mouse-mode) |
| 197 | (send-string-to-terminal "\e[?1000l"))) | 185 | (send-string-to-terminal "\e[?1000l"))) |
| 198 | 186 | ||
| 199 | ;; Restore normal mouse behaviour outside Emacs. | 187 | ;; Restore normal mouse behaviour outside Emacs. |