diff options
| author | Mike Williams | 2002-07-14 10:14:28 +0000 |
|---|---|---|
| committer | Mike Williams | 2002-07-14 10:14:28 +0000 |
| commit | 4bc65152ebd086e14758366823c3328b06b26b3e (patch) | |
| tree | d22f78de337ef0a2488dac36b0c9160cd11f7bfc | |
| parent | 00feb952358e6b03b6c0c76840cfab94e3779f0c (diff) | |
| download | emacs-4bc65152ebd086e14758366823c3328b06b26b3e.tar.gz emacs-4bc65152ebd086e14758366823c3328b06b26b3e.zip | |
(mouse-sel-bound-events): New constant.
(mouse-sel-save-original-bindings): New function.
(mouse-sel-restore-original-bindings): New function.
(mouse-sel-bindings): Save/restore original mouse-bindings.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/mouse-sel.el | 134 |
2 files changed, 74 insertions, 67 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a9d1b6703b3..87c57d49690 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2002-07-14 Mike Williams <mdub@bigfoot.com> | ||
| 2 | |||
| 3 | * mouse-sel.el (mouse-sel-bound-events): New constant. | ||
| 4 | (mouse-sel-save-original-bindings): New function. | ||
| 5 | (mouse-sel-restore-original-bindings): New function. | ||
| 6 | (mouse-sel-bindings): Save/restore original mouse-bindings. | ||
| 7 | |||
| 1 | 2002-07-13 Stefan Monnier <monnier@cs.yale.edu> | 8 | 2002-07-13 Stefan Monnier <monnier@cs.yale.edu> |
| 2 | 9 | ||
| 3 | * emacs-lisp/cl.el (cl-set-substring): Fix thinko. | 10 | * emacs-lisp/cl.el (cl-set-substring): Fix thinko. |
diff --git a/lisp/mouse-sel.el b/lisp/mouse-sel.el index 731a945aba4..25fdc92b296 100644 --- a/lisp/mouse-sel.el +++ b/lisp/mouse-sel.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; mouse-sel.el --- multi-click selection support for Emacs 19 | 1 | ;;; mouse-sel.el --- multi-click selection support for Emacs 19 |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1993, 1994, 1995, 2001 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1993,1994,1995,2001,2002 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Mike Williams <mdub@bigfoot.com> | 5 | ;; Author: Mike Williams <mdub@bigfoot.com> |
| 6 | ;; Keywords: mouse | 6 | ;; Keywords: mouse |
| @@ -231,50 +231,73 @@ primary selection and region." | |||
| 231 | 231 | ||
| 232 | ;;=== Key bindings ======================================================== | 232 | ;;=== Key bindings ======================================================== |
| 233 | 233 | ||
| 234 | (defconst mouse-sel-bound-events | ||
| 235 | '([down-mouse-1] [mouse-1] [drag-mouse-1] | ||
| 236 | [mouse-2] | ||
| 237 | [down-mouse-3] [mouse-3] | ||
| 238 | [M-mouse-2] | ||
| 239 | [M-down-mouse-1] [M-mouse-1] [M-drag-mouse-1] | ||
| 240 | [M-down-mouse-3] [M-mouse-3]) | ||
| 241 | "A list of events that mouse-sel binds.") | ||
| 242 | |||
| 243 | (defun mouse-sel-save-original-bindings () | ||
| 244 | "Save the current bindings for `mouse-sel-bound-events'." | ||
| 245 | (setq mouse-sel-original-bindings nil) | ||
| 246 | (mapc (function | ||
| 247 | (lambda (event) | ||
| 248 | (setq mouse-sel-original-bindings | ||
| 249 | (cons (cons event (lookup-key global-map event)) | ||
| 250 | mouse-sel-original-bindings)))) | ||
| 251 | mouse-sel-bound-events)) | ||
| 252 | |||
| 253 | (defun mouse-sel-restore-original-bindings () | ||
| 254 | "Restore the original bindings for `mouse-sel-bound-events'." | ||
| 255 | (mapc (function | ||
| 256 | (lambda (binding) | ||
| 257 | (if (cdr binding) | ||
| 258 | (global-set-key (car binding) (cdr binding)) | ||
| 259 | (global-unset-key (car binding))))) | ||
| 260 | mouse-sel-original-bindings)) | ||
| 261 | |||
| 234 | (defun mouse-sel-bindings (bind) | 262 | (defun mouse-sel-bindings (bind) |
| 235 | (cond ((not bind) | 263 | (cond |
| 236 | ;; These bindings are taken from mouse.el, i.e., they are the default | 264 | |
| 237 | ;; bindings. It would be better to restore the previous bindings. | 265 | ;; Default mouse-sel bindings |
| 238 | ;; Primary selection bindings. | 266 | ((and bind mouse-sel-default-bindings) |
| 239 | (global-set-key [mouse-1] 'mouse-set-point) | 267 | |
| 240 | (global-set-key [mouse-2] 'mouse-yank-at-click) | 268 | ;; Save original bindings |
| 241 | (global-set-key [mouse-3] 'mouse-save-then-kill) | 269 | (mouse-sel-save-original-bindings) |
| 242 | (global-set-key [down-mouse-1] 'mouse-drag-region) | 270 | |
| 243 | (global-set-key [drag-mouse-1] 'mouse-set-region) | 271 | ;; Primary selection bindings. |
| 244 | (global-set-key [double-mouse-1] 'mouse-set-point) | 272 | ;; |
| 245 | (global-set-key [triple-mouse-1] 'mouse-set-point) | 273 | ;; Bind keys to `ignore' instead of unsetting them because |
| 246 | ;; Secondary selection bindings. | 274 | ;; modes may bind `down-mouse-1', for instance, without |
| 247 | (global-set-key [M-mouse-1] 'mouse-start-secondary) | 275 | ;; binding other `up-mouse-1' or `mouse-1'. If we unset |
| 248 | (global-set-key [M-mouse-2] 'mouse-yank-secondary) | 276 | ;; `mouse-1', this leads to a bitch_at_user when the mouse |
| 249 | (global-set-key [M-mouse-3] 'mouse-secondary-save-then-kill) | 277 | ;; goes up because no matching binding is found for that. |
| 250 | (global-set-key [M-drag-mouse-1] 'mouse-set-secondary) | 278 | (global-set-key [mouse-1] 'ignore) |
| 251 | (global-set-key [M-down-mouse-1] 'mouse-drag-secondary)) | 279 | (global-set-key [drag-mouse-1] 'ignore) |
| 252 | (mouse-sel-default-bindings | 280 | (global-set-key [mouse-3] 'ignore) |
| 253 | ;; | 281 | (global-set-key [down-mouse-1] 'mouse-select) |
| 254 | ;; Primary selection bindings. | 282 | (unless (eq mouse-sel-default-bindings 'interprogram-cut-paste) |
| 255 | 283 | (global-set-key [mouse-2] 'mouse-insert-selection) | |
| 256 | ;; Bind keys to `ignore' instead of unsetting them because | 284 | (setq interprogram-cut-function nil |
| 257 | ;; modes may bind `down-mouse-1', for instance, without | 285 | interprogram-paste-function nil)) |
| 258 | ;; binding other `up-mouse-1' or `mouse-1'. If we unset | 286 | (global-set-key [down-mouse-3] 'mouse-extend) |
| 259 | ;; `mouse-1', this leads to a bitch_at_user when the mouse | 287 | |
| 260 | ;; goes up because no matching binding is found for that. | 288 | ;; Secondary selection bindings. |
| 261 | (global-set-key [mouse-1] 'ignore) | 289 | (global-set-key [M-mouse-1] 'ignore) |
| 262 | (global-set-key [drag-mouse-1] 'ignore) | 290 | (global-set-key [M-drag-mouse-1] 'ignore) |
| 263 | (global-set-key [mouse-3] 'ignore) | 291 | (global-set-key [M-mouse-3] 'ignore) |
| 264 | (global-set-key [down-mouse-1] 'mouse-select) | 292 | (global-set-key [M-down-mouse-1] 'mouse-select-secondary) |
| 265 | (unless (eq mouse-sel-default-bindings 'interprogram-cut-paste) | 293 | (global-set-key [M-mouse-2] 'mouse-insert-secondary) |
| 266 | (global-set-key [mouse-2] 'mouse-insert-selection) | 294 | (global-set-key [M-down-mouse-3] 'mouse-extend-secondary)) |
| 267 | (setq interprogram-cut-function nil | 295 | |
| 268 | interprogram-paste-function nil)) | 296 | ((not bind) |
| 269 | (global-set-key [down-mouse-3] 'mouse-extend) | 297 | ;; Restore original bindings |
| 270 | ;; | 298 | (mouse-sel-restore-original-bindings)) |
| 271 | ;; Secondary selection bindings. | 299 | |
| 272 | (global-set-key [M-mouse-1] 'ignore) | 300 | )) |
| 273 | (global-set-key [M-drag-mouse-1] 'ignore) | ||
| 274 | (global-set-key [M-mouse-3] 'ignore) | ||
| 275 | (global-set-key [M-down-mouse-1] 'mouse-select-secondary) | ||
| 276 | (global-set-key [M-mouse-2] 'mouse-insert-secondary) | ||
| 277 | (global-set-key [M-down-mouse-3] 'mouse-extend-secondary)))) | ||
| 278 | 301 | ||
| 279 | ;;=== Command Variable ==================================================== | 302 | ;;=== Command Variable ==================================================== |
| 280 | 303 | ||
| @@ -716,29 +739,6 @@ If `mouse-yank-at-point' is non-nil, insert at point instead." | |||
| 716 | (let ((overlay (mouse-sel-selection-overlay selection))) | 739 | (let ((overlay (mouse-sel-selection-overlay selection))) |
| 717 | (delete-overlay overlay))) | 740 | (delete-overlay overlay))) |
| 718 | 741 | ||
| 719 | ;;=== Bug reporting ======================================================= | ||
| 720 | |||
| 721 | ;(defconst mouse-sel-maintainer-address "mikew@gopher.dosli.govt.nz") | ||
| 722 | |||
| 723 | ;(defun mouse-sel-submit-bug-report () | ||
| 724 | ; "Submit a bug report on mouse-sel.el via mail." | ||
| 725 | ; (interactive) | ||
| 726 | ; (require 'reporter) | ||
| 727 | ; (reporter-submit-bug-report | ||
| 728 | ; mouse-sel-maintainer-address | ||
| 729 | ; (concat "mouse-sel.el " | ||
| 730 | ; (or (condition-case nil mouse-sel-version (error)) | ||
| 731 | ; "(distributed with Emacs)")) | ||
| 732 | ; (list 'transient-mark-mode | ||
| 733 | ; 'delete-selection-mode | ||
| 734 | ; 'mouse-sel-default-bindings | ||
| 735 | ; 'mouse-sel-leave-point-near-mouse | ||
| 736 | ; 'mouse-sel-cycle-clicks | ||
| 737 | ; 'mouse-sel-selection-alist | ||
| 738 | ; 'mouse-sel-set-selection-function | ||
| 739 | ; 'mouse-sel-get-selection-function | ||
| 740 | ; 'mouse-yank-at-point))) | ||
| 741 | |||
| 742 | (provide 'mouse-sel) | 742 | (provide 'mouse-sel) |
| 743 | 743 | ||
| 744 | ;;; mouse-sel.el ends here | 744 | ;;; mouse-sel.el ends here |