emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/mouse-sel.el


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/mouse-sel.el
Date: Tue, 16 Jul 2002 09:27:05 -0400

Index: emacs/lisp/mouse-sel.el
diff -c emacs/lisp/mouse-sel.el:1.34 emacs/lisp/mouse-sel.el:1.35
*** emacs/lisp/mouse-sel.el:1.34        Mon Jul 15 07:48:44 2002
--- emacs/lisp/mouse-sel.el     Tue Jul 16 09:27:05 2002
***************
*** 93,100 ****
  ;;
  ;;       Mouse sets selection, and pastes from kill-ring
  ;;       mouse-1              mouse-select
! ;;       mouse-2              mouse-yank-at-click
  ;;       mouse-3              mouse-extend
  ;;
  ;;       Selection/kill-ring interaction is retained
  ;;         interprogram-cut-function   = x-select-text
--- 93,101 ----
  ;;
  ;;       Mouse sets selection, and pastes from kill-ring
  ;;       mouse-1              mouse-select
! ;;       mouse-2              mouse-insert-selection
  ;;       mouse-3              mouse-extend
+ ;;     In this mode, mouse-insert-selection just calls mouse-yank-at-click.
  ;;
  ;;       Selection/kill-ring interaction is retained
  ;;         interprogram-cut-function   = x-select-text
***************
*** 149,166 ****
    "Mouse selection enhancement."
    :group 'mouse)
  
- (defcustom mouse-sel-mode nil
-   "Toggle Mouse Sel mode.
- When Mouse Sel mode is enabled, mouse selection is enhanced in various ways.
- Setting this variable directly does not take effect;
- use either \\[customize] or the function `mouse-sel-mode'."
-   :set (lambda (symbol value)
-        (mouse-sel-mode (or value 0)))
-   :initialize 'custom-initialize-default
-   :type 'boolean
-   :group 'mouse-sel
-   :require 'mouse-sel)
- 
  (defcustom mouse-sel-leave-point-near-mouse t
    "*Leave point near last mouse position.
  If non-nil, \\[mouse-select] and \\[mouse-extend] will leave point at the end
--- 150,155 ----
***************
*** 181,190 ****
                 (other :tag "default bindings" t))
    :group 'mouse-sel)
  
  ;;=== User Command ========================================================
  
  ;;;###autoload
! (defun mouse-sel-mode (&optional arg)
    "Toggle Mouse Sel mode.
  With prefix ARG, turn Mouse Sel mode on if and only if ARG is positive.
  Returns the new status of Mouse Sel mode (non-nil means on).
--- 170,207 ----
                 (other :tag "default bindings" t))
    :group 'mouse-sel)
  
+ ;;=== Key bindings ========================================================
+ 
+ (defconst mouse-sel-bound-events
+   '(;; Primary selection bindings.
+     ;;
+     ;; Bind keys to `ignore' instead of unsetting them because modes may
+     ;; bind `down-mouse-1', for instance, without binding `mouse-1'.
+     ;; If we unset `mouse-1', this leads to a bitch_at_user when the
+     ;; mouse goes up because no matching binding is found for that.
+     ([mouse-1]                . ignore)
+     ([drag-mouse-1]   . ignore)
+     ([mouse-3]                . ignore)
+     ([down-mouse-1]   . mouse-select)
+     ([down-mouse-3]   . mouse-extend)
+     ([mouse-2]                . mouse-insert-selection)
+     ;; Secondary selection bindings.
+     ([M-mouse-1]      . ignore)
+     ([M-drag-mouse-1] . ignore)
+     ([M-mouse-3]      . ignore)
+     ([M-down-mouse-1] . mouse-select-secondary)
+     ([M-mouse-2]      . mouse-insert-secondary)
+     ([M-down-mouse-3] . mouse-extend-secondary))
+   "An alist of events that `mouse-sel-mode' binds.")
+ 
  ;;=== User Command ========================================================
  
+ (defvar mouse-sel-original-bindings nil)
+ (defvar mouse-sel-original-interprogram-cut-function nil)
+ (defvar mouse-sel-original-interprogram-cut-function nil)
+ 
  ;;;###autoload
! (define-minor-mode mouse-sel-mode
    "Toggle Mouse Sel mode.
  With prefix ARG, turn Mouse Sel mode on if and only if ARG is positive.
  Returns the new status of Mouse Sel mode (non-nil means on).
***************
*** 203,212 ****
  Quad-clicking selects paragraphs.
  
  - Selecting sets the region & X primary selection, but does NOT affect
! the kill-ring, nor do the kill-ring function change the X selection.
  Because the mouse handlers set the primary selection directly,
! mouse-sel sets the variables interprogram-cut-function and
! interprogram-paste-function to nil.
  
  - Clicking mouse-2 inserts the contents of the primary selection at
  the mouse position (or point, if `mouse-yank-at-point' is non-nil).
--- 220,229 ----
  Quad-clicking selects paragraphs.
  
  - Selecting sets the region & X primary selection, but does NOT affect
! the `kill-ring', nor do the kill-ring functions change the X selection.
  Because the mouse handlers set the primary selection directly,
! mouse-sel sets the variables `interprogram-cut-function' and
! `interprogram-paste-function' to nil.
  
  - Clicking mouse-2 inserts the contents of the primary selection at
  the mouse position (or point, if `mouse-yank-at-point' is non-nil).
***************
*** 219,311 ****
  - M-mouse-1, M-mouse-2 & M-mouse-3 work similarly to mouse-1, mouse-2
  & mouse-3, but operate on the X secondary selection rather than the
  primary selection and region."
!   (interactive "P")
!   (let ((on-p (if arg
!                 (> (prefix-numeric-value arg) 0)
!               (not mouse-sel-mode))))
!     (if on-p
        (add-hook 'x-lost-selection-hooks 'mouse-sel-lost-selection-hook)
!       (remove-hook 'x-lost-selection-hooks 'mouse-sel-lost-selection-hook))
!     (mouse-sel-bindings on-p)
!     (setq mouse-sel-mode on-p)))
! 
! ;;=== Key bindings ========================================================
  
- (defconst mouse-sel-bound-events
-   '([down-mouse-1] [mouse-1] [drag-mouse-1]
-     [mouse-2]
-     [down-mouse-3] [mouse-3]
-     [M-mouse-2]
-     [M-down-mouse-1] [M-mouse-1] [M-drag-mouse-1]
-     [M-down-mouse-3] [M-mouse-3])
-   "A list of events that mouse-sel binds.")
- 
- (defun mouse-sel-bindings (bind)
-   (cond 
- 
-    ;; Default mouse-sel bindings
-    ((and bind mouse-sel-default-bindings) 
- 
-     ;; Save original bindings
-     (setq mouse-sel-original-bindings nil)
-     (mapc (function 
-            (lambda (event)
-              (setq mouse-sel-original-bindings
-                    (cons (cons event (lookup-key global-map event))
-                          mouse-sel-original-bindings))))
-           mouse-sel-bound-events)
-     (setq mouse-sel-original-interprogram-cut-function 
-           interprogram-cut-function
-           mouse-sel-original-interprogram-paste-function
-           interprogram-paste-function)
-     
-     ;; Primary selection bindings.
-     ;;
-     ;; Bind keys to `ignore' instead of unsetting them because
-     ;; modes may bind `down-mouse-1', for instance, without
-     ;; binding other `up-mouse-1' or `mouse-1'.  If we unset
-     ;; `mouse-1', this leads to a bitch_at_user when the mouse
-     ;; goes up because no matching binding is found for that.
-     (global-set-key [mouse-1]           'ignore)
-     (global-set-key [drag-mouse-1]      'ignore)
-     (global-set-key [mouse-3]           'ignore)
-     (global-set-key [down-mouse-1]    'mouse-select)
-     (unless (eq mouse-sel-default-bindings 'interprogram-cut-paste)
-       (global-set-key [mouse-2]         'mouse-insert-selection)
-       (setq interprogram-cut-function nil
-             interprogram-paste-function nil))
-     (global-set-key [down-mouse-3]      'mouse-extend)
- 
-     ;; Secondary selection bindings.
-     (global-set-key [M-mouse-1]         'ignore)
-     (global-set-key [M-drag-mouse-1]    'ignore)
-     (global-set-key [M-mouse-3]         'ignore)
-     (global-set-key [M-down-mouse-1]  'mouse-select-secondary)
-     (global-set-key [M-mouse-2]         'mouse-insert-secondary)
-     (global-set-key [M-down-mouse-3]  'mouse-extend-secondary))
-    
-    ((not bind)
      ;; Restore original bindings
!     (mapc (function 
!            (lambda (binding)
!              (if (cdr binding)
!                  (global-set-key (car binding) (cdr binding))
!                (global-unset-key (car binding)))))
!           mouse-sel-original-bindings)
!     (setq interprogram-cut-function 
            mouse-sel-original-interprogram-cut-function
            interprogram-paste-function
!           mouse-sel-original-interprogram-paste-function))
!    
!    ))
! 
! ;;=== Command Variable ====================================================
! 
! ;; This has to come after the function `mouse-sel-mode' and its callee.
! ;; An alternative is to put the option `mouse-sel-mode' here and remove its
! ;; `:initialize' keyword.
! (when mouse-sel-mode
!   (mouse-sel-mode t))
  
  ;;=== Internal Variables/Constants ========================================
  
--- 236,270 ----
  - M-mouse-1, M-mouse-2 & M-mouse-3 work similarly to mouse-1, mouse-2
  & mouse-3, but operate on the X secondary selection rather than the
  primary selection and region."
!   :global t
!   (if mouse-sel-mode
!       (progn
        (add-hook 'x-lost-selection-hooks 'mouse-sel-lost-selection-hook)
!       (when mouse-sel-default-bindings
!         ;; Save original bindings and replace them with new ones.
!         (setq mouse-sel-original-bindings
!               (mapcar (lambda (binding)
!                         (let ((event (car binding)))
!                           (prog1 (cons event (lookup-key global-map event))
!                             (global-set-key event (cdr binding)))))
!                       mouse-sel-bound-events))
!         ;; Update interprogram functions.
!         (setq mouse-sel-original-interprogram-cut-function
!               interprogram-cut-function
!               mouse-sel-original-interprogram-paste-function
!               interprogram-paste-function)
!         (unless (eq mouse-sel-default-bindings 'interprogram-cut-paste)
!           (setq interprogram-cut-function nil
!                 interprogram-paste-function nil))))
  
      ;; Restore original bindings
!     (remove-hook 'x-lost-selection-hooks 'mouse-sel-lost-selection-hook)
!     (dolist (binding mouse-sel-original-bindings)
!       (global-set-key (car binding) (cdr binding)))
!     (setq interprogram-cut-function
            mouse-sel-original-interprogram-cut-function
            interprogram-paste-function
!           mouse-sel-original-interprogram-paste-function)))
  
  ;;=== Internal Variables/Constants ========================================
  
***************
*** 711,721 ****
  
  ;;=== Paste ===============================================================
  
! (defun mouse-insert-selection (event)
    "Insert the contents of the PRIMARY selection at mouse click.
  If `mouse-yank-at-point' is non-nil, insert at point instead."
!   (interactive "e")
!   (mouse-insert-selection-internal 'PRIMARY event))
  
  (defun mouse-insert-secondary (event)
    "Insert the contents of the SECONDARY selection at mouse click.
--- 670,682 ----
  
  ;;=== Paste ===============================================================
  
! (defun mouse-insert-selection (event arg)
    "Insert the contents of the PRIMARY selection at mouse click.
  If `mouse-yank-at-point' is non-nil, insert at point instead."
!   (interactive "e\nP")
!   (if (eq mouse-sel-default-bindings 'interprogram-cut-paste)
!       (mouse-yank-at-click event arg)
!     (mouse-insert-selection-internal 'PRIMARY event)))
  
  (defun mouse-insert-secondary (event)
    "Insert the contents of the SECONDARY selection at mouse click.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]