chiark / gitweb /
Import ~/emacs from zealot
[ian-dotfiles.git] / home / emacs / x-fix-mouse.el
1 ;;; x-fix-mouse.el
2 ;;;
3 ;;; make mouse-based paste ignore the mouse position and use the emacs point
4 ;;; instead.  Make cut-text set the mark so the mouse can be used naturally
5 ;;; to select a region (e.g. to indent code).
6 ;;;
7 ;;; Jean-Francois Lamy 1989-09-21
8 ;;; lamy@ai.utoronto.ca
9
10 (require 'x-mouse); These two lines
11 (provide 'x-fix-mouse); added by 89iwj@eng.cam.ac.uk
12
13 (defun x-cut-text (arg &optional kill)
14   "Copy text between point and mouse into window system cut buffer.
15 Set mark to current mouse position. Save in Emacs kill ring also."
16   (if (coordinates-in-window-p arg (selected-window))
17       (progn
18        (x-mouse-set-mark arg)
19          (let ((beg (point)) (end (mark)))
20            (x-store-cut-buffer (buffer-substring beg end))
21            (copy-region-as-kill beg end)
22            (if kill (delete-region beg end))))
23     (message "Mouse not in selected window")))
24
25 (defun x-paste-text (arg)
26   "Insert window system cut buffer contents at current point."
27   (insert (x-get-cut-buffer)))
28
29 (defun x-cut-and-wipe-text (arg)
30   "Kill text between point and mark; also copy to window system cut buffer."
31   (x-cut-text arg t))
32
33 (defun x-cut-text-if-moved (arg &optional kill)
34   (let ((opoint (point)))
35     (x-mouse-set-point arg)
36     (cond 
37      ((not (equal (point) opoint))
38       (goto-char opoint)
39       (x-cut-text arg kill)))))
40
41 ;------- End of Forwarded Message