123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- (defvar mouse-copy-last-paste-start nil
- "Internal to `mouse-drag-secondary-pasting'.")
- (defvar mouse-copy-last-paste-end nil
- "Internal to `mouse-drag-secondary-pasting'.")
- (defvar mouse-copy-have-drag-bug nil
- "Set to enable mouse-copy-work-around-drag-bug.
- See `mouse-copy-work-around-drag-bug' for details.")
- (defun mouse-copy-work-around-drag-bug (start-event end-event)
- "Code to work around a bug in post-19.29 Emacs: it drops mouse-drag events.
- The problem occurs under XFree86-3.1.1 (X11R6pl11) but not under X11R5,
- and under post-19.29 but not early versions of Emacs.
- 19.29 and 19.30 seems to drop mouse drag events
- sometimes. (Reproducible under XFree86-3.1.1 (X11R6pl11) and
- XFree86-3.1.2 under Linux 1.2.x. Doesn't occur under X11R5 and SunOS
- 4.1.1.)
- To see if you have the problem:
- Disable this routine (with (setq mouse-copy-have-drag-bug nil)).
- Click and drag for a while.
- If highlighting stops tracking, you have the bug.
- If you have the bug (or the real fix :-), please let me know."
-
-
-
- (save-excursion
- (let*
- ((start-posn (event-start start-event))
- (end-posn (event-end end-event))
- (end-buffer (window-buffer (posn-window end-posn)))
-
- (range (progn
- (set-buffer end-buffer)
- (mouse-start-end (posn-point start-posn)
- (posn-point end-posn)
- (1- (event-click-count start-event)))))
- (beg (car range))
- (end (car (cdr range))))
-
- (if mouse-secondary-overlay
- (move-overlay mouse-secondary-overlay beg end)
- (setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
- (overlay-put mouse-secondary-overlay 'face 'secondary-selection)
-
-
- (set-buffer end-buffer)
- (x-set-selection 'SECONDARY (buffer-substring beg end)))))
- (defun mouse-drag-secondary-pasting (start-event)
- "Drag out a secondary selection, then paste it at the current point.
- To test this function, evaluate:
- (global-set-key [M-down-mouse-1] 'mouse-drag-secondary-pasting)
- put the point at one place, then click and drag over some other region."
- (interactive "e")
-
-
-
-
-
- (if (and mouse-copy-last-paste-start
- (>= (event-click-count start-event) 2))
- (delete-region mouse-copy-last-paste-start
- mouse-copy-last-paste-end))
-
-
-
-
- (if (mouse-drag-secondary start-event)
- (progn
- (if mouse-copy-have-drag-bug
- (mouse-copy-work-around-drag-bug start-event last-input-event))
-
- (setq mouse-copy-last-paste-start (point))
- (insert (x-get-selection 'SECONDARY))
- (setq mouse-copy-last-paste-end (point)))
- (setq mouse-copy-last-paste-start nil)))
- (defun mouse-kill-preserving-secondary ()
- "Kill the text in the secondary selection, but leave the selection set.
- This command is like \\[mouse-kill-secondary] (that is, the secondary
- selection is deleted and placed in the kill ring), except that it also
- leaves the secondary buffer active on exit.
- This command was derived from mouse-kill-secondary in emacs-19.28
- by johnh@ficus.cs.ucla.edu."
- (interactive)
- (let* ((keys (this-command-keys))
- (click (elt keys (1- (length keys)))))
- (or (eq (overlay-buffer mouse-secondary-overlay)
- (if (listp click)
- (window-buffer (posn-window (event-start click)))
- (current-buffer)))
- (error "Select or click on the buffer where the secondary selection is")))
- (with-current-buffer (overlay-buffer mouse-secondary-overlay)
- (kill-region (overlay-start mouse-secondary-overlay)
- (overlay-end mouse-secondary-overlay)))
-
-
-
- )
- (defun mouse-drag-secondary-moving (start-event)
- "Sweep out a secondary selection, then move it to the current point."
- (interactive "e")
-
-
-
- (if (mouse-drag-secondary start-event)
- (progn
- (mouse-kill-preserving-secondary)
- (insert (x-get-selection 'SECONDARY))))
- )
- (provide 'mouse-copy)
|