annotate lisp/mouse.el @ 12436:ffd777dc7d29

(mouse-selection-click-count-buffer): New variable. (mouse-drag-region): Set it. (mouse-save-then-kill): Test it.
author Richard M. Stallman <rms@gnu.org>
date Thu, 29 Jun 1995 22:19:13 +0000
parents 8d2679d3f095
children ce881909d36a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; mouse.el --- window system-independent mouse support.
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
2
11235
e6bdaaa6ce1b Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 11023
diff changeset
3 ;;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
840
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
4
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
5 ;; Maintainer: FSF
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
6 ;; Keywords: hardware
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
7
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
8 ;;; This file is part of GNU Emacs.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
11 ;;; it under the terms of the GNU General Public License as published by
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
12 ;;; the Free Software Foundation; either version 2, or (at your option)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
13 ;;; any later version.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
18 ;;; GNU General Public License for more details.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
20 ;;; You should have received a copy of the GNU General Public License
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
2308
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
24 ;;; Commentary:
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
25
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
26 ;; This package provides various useful commands (including help
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
27 ;; system access) through the mouse. All this code assumes that mouse
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
28 ;; interpretation has been abstracted into Emacs input events.
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
29 ;;
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
30 ;; The code is rather X-dependent.
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
31
2232
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2070
diff changeset
32 ;;; Code:
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2070
diff changeset
33
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
34 ;;; Utility functions.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
35
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
36 ;;; Indent track-mouse like progn.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
37 (put 'track-mouse 'lisp-indent-function 0)
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
39 (defvar mouse-yank-at-point nil
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
40 "*If non-nil, mouse yank commands yank at point instead of at click.")
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
41
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
42 ;; Provide a mode-specific menu on a mouse button.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
43
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
44 (defun mouse-major-mode-menu (event)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
45 "Pop up a mode-specific menu of mouse commands."
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
46 ;; Switch to the window clicked on, because otherwise
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
47 ;; the mode's commands may not make sense.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
48 (interactive "@e")
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
49 (let ((newmap (make-sparse-keymap))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
50 (unread-command-events (list event)))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
51 ;; Make a keymap in which our last command leads to a menu
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
52 (define-key newmap (vector (car event))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
53 (nconc (make-sparse-keymap "Menu")
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
54 (mouse-major-mode-menu-1
11023
498940aefc37 (mouse-major-mode-menu): Avoid confusing error message when there's no current
Karl Heuer <kwzh@gnu.org>
parents: 10838
diff changeset
55 (and (current-local-map)
498940aefc37 (mouse-major-mode-menu): Avoid confusing error message when there's no current
Karl Heuer <kwzh@gnu.org>
parents: 10838
diff changeset
56 (lookup-key (current-local-map) [menu-bar])))))
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
57 (mouse-major-mode-menu-compute-equiv-keys newmap)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
58 (command-execute
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
59 ;; Make NEWMAP override the usual definition
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
60 ;; of the mouse button that got us here.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
61 ;; Then read the user's menu choice.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
62 (let ((minor-mode-map-alist
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
63 (cons (cons t newmap) minor-mode-map-alist)))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
64 (lookup-key newmap (read-key-sequence ""))))))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
65
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
66 ;; Compute and cache the equivalent keys in MENU and all its submenus.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
67 (defun mouse-major-mode-menu-compute-equiv-keys (menu)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
68 (and (eq (car menu) 'keymap)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
69 (x-popup-menu nil menu))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
70 (while menu
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
71 (and (consp (car menu))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
72 (consp (cdr (car menu)))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
73 (let ((tail (cdr (car menu))))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
74 (while (and (consp tail)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
75 (not (eq (car tail) 'keymap)))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
76 (setq tail (cdr tail)))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
77 (if (consp tail)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
78 (mouse-major-mode-menu-compute-equiv-keys tail))))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
79 (setq menu (cdr menu))))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
80
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
81 ;; Given a mode's menu bar keymap,
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
82 ;; if it defines exactly one menu bar menu,
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
83 ;; return just that menu.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
84 ;; Otherwise return a menu for all of them.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
85 (defun mouse-major-mode-menu-1 (menubar)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
86 (if menubar
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
87 (let ((tail menubar)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
88 submap)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
89 (while tail
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
90 (if (consp (car tail))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
91 (if submap
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
92 (setq submap t)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
93 (setq submap (cdr (car tail)))))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
94 (setq tail (cdr tail)))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
95 (if (eq submap t) menubar
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
96 submap))))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
97
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
98 ;; Commands that operate on windows.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
99
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
100 (defun mouse-minibuffer-check (event)
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
101 (let ((w (posn-window (event-start event))))
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
102 (and (window-minibuffer-p w)
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
103 (not (minibuffer-window-active-p w))
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
104 (error "Minibuffer window is not active")))
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
105 ;; Give temporary modes such as isearch a chance to turn off.
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
106 (run-hooks 'mouse-leave-buffer-hook))
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
107
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
108 (defun mouse-delete-window (click)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
109 "Delete the window you click on.
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
110 This must be bound to a mouse click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
111 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
112 (mouse-minibuffer-check click)
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
113 (delete-window (posn-window (event-start click))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
114
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
115 (defun mouse-select-window (click)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
116 "Select the window clicked on; don't move point."
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
117 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
118 (mouse-minibuffer-check click)
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
119 (let ((oframe (selected-frame))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
120 (frame (window-frame (posn-window (event-start click)))))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
121 (select-window (posn-window (event-start click)))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
122 (raise-frame frame)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
123 (select-frame frame)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
124 (or (eq frame oframe)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
125 (set-mouse-position (selected-frame) (1- (frame-width)) 0))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
126 (unfocus-frame)))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
127
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
128 (defun mouse-tear-off-window (click)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
129 "Delete the window clicked on, and create a new frame displaying its buffer."
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
130 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
131 (mouse-minibuffer-check click)
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
132 (let* ((window (posn-window (event-start click)))
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
133 (buf (window-buffer window))
7363
f35fe65c9755 (mouse-tear-off-window): Change new-frame to make-frame.
Karl Heuer <kwzh@gnu.org>
parents: 7302
diff changeset
134 (frame (make-frame)))
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
135 (select-frame frame)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
136 (switch-to-buffer buf)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
137 (delete-window window)))
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
138
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
139 (defun mouse-delete-other-windows ()
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
140 "Delete all window except the one you click on."
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
141 (interactive "@")
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (delete-other-windows))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
144 (defun mouse-split-window-vertically (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
145 "Select Emacs window mouse is on, then split it vertically in half.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
146 The window is split at the line clicked on.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
147 This command must be bound to a mouse click."
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
148 (interactive "@e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
149 (mouse-minibuffer-check click)
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
150 (let ((start (event-start click)))
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
151 (select-window (posn-window start))
7637
cc55e77a9819 (mouse-split-window-vertically): Treat scroll bar events just like others.
Richard M. Stallman <rms@gnu.org>
parents: 7593
diff changeset
152 (let ((new-height (1+ (cdr (posn-col-row (event-end click)))))
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
153 (first-line window-min-height)
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
154 (last-line (- (window-height) window-min-height)))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
155 (if (< last-line first-line)
8426
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
156 (error "Window too short to split")
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
157 (split-window-vertically
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
158 (min (max new-height first-line) last-line))))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
160 (defun mouse-split-window-horizontally (click)
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
161 "Select Emacs window mouse is on, then split it horizontally in half.
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
162 The window is split at the column clicked on.
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
163 This command must be bound to a mouse click."
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
164 (interactive "@e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
165 (mouse-minibuffer-check click)
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
166 (let ((start (event-start click)))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
167 (select-window (posn-window start))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
168 (let ((new-width (1+ (car (posn-col-row (event-end click)))))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
169 (first-col window-min-width)
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
170 (last-col (- (window-width) window-min-width)))
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
171 (if (< last-col first-col)
8426
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
172 (error "Window too narrow to split")
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
173 (split-window-horizontally
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
174 (min (max new-width first-col) last-col))))))
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
175
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
176 (defun mouse-drag-mode-line (start-event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
177 "Change the height of a window by dragging on the mode line."
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
178 (interactive "e")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
179 ;; Give temporary modes such as isearch a chance to turn off.
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
180 (run-hooks 'mouse-leave-buffer-hook)
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
181 (let ((done nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
182 (echo-keystrokes 0)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
183 (start-event-frame (window-frame (car (car (cdr start-event)))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
184 (start-event-window (car (car (cdr start-event))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
185 (start-nwindows (count-windows t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
186 (old-selected-window (selected-window))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
187 should-enlarge-minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
188 event mouse minibuffer y top bot edges wconfig params growth)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
189 (setq params (frame-parameters))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
190 (if (and (not (setq minibuffer (cdr (assq 'minibuffer params))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
191 (one-window-p t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
192 (error "Attempt to resize sole window"))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
193 (track-mouse
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
194 (progn
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
195 ;; enlarge-window only works on the selected window, so
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
196 ;; we must select the window where the start event originated.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
197 ;; unwind-protect will restore the old selected window later.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
198 (select-window start-event-window)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
199 ;; if this is the bottommost ordinary window, then to
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
200 ;; move its modeline the minibuffer must be enlarged.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
201 (setq should-enlarge-minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
202 (and minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
203 (not (one-window-p t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
204 (= (nth 1 (window-edges minibuffer))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
205 (nth 3 (window-edges)))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
206 ;; loop reading events and sampling the position of
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
207 ;; the mouse.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
208 (while (not done)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
209 (setq event (read-event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
210 mouse (mouse-position))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
211 ;; do nothing if
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
212 ;; - there is a switch-frame event.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
213 ;; - the mouse isn't in the frame that we started in
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
214 ;; - the mouse isn't in any Emacs frame
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
215 ;; drag if
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
216 ;; - there is a mouse-movement event
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
217 ;; - there is a scroll-bar-movement event
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
218 ;; (same as mouse movement for our purposes)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
219 ;; quit if
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
220 ;; - there is a keyboard event or some other unknown event
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
221 ;; unknown event.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
222 (cond ((integerp event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
223 (setq done t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
224 ((eq (car event) 'switch-frame)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
225 nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
226 ((not (memq (car event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
227 '(mouse-movement scroll-bar-movement)))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
228 (if (consp event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
229 (setq unread-command-events
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
230 (cons event unread-command-events)))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
231 (setq done t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
232 ((not (eq (car mouse) start-event-frame))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
233 nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
234 ((null (car (cdr mouse)))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
235 nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
236 (t
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
237 (setq y (cdr (cdr mouse))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
238 edges (window-edges)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
239 top (nth 1 edges)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
240 bot (nth 3 edges))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
241 ;; scale back a move that would make the
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
242 ;; window too short.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
243 (cond ((< (- y top -1) window-min-height)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
244 (setq y (+ top window-min-height -1))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
245 ;; compute size change needed
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
246 (setq growth (- y bot -1)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
247 wconfig (current-window-configuration))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
248 ;; grow/shrink minibuffer?
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
249 (if should-enlarge-minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
250 (progn
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
251 ;; yes. briefly select minibuffer so
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
252 ;; enlarge-window will affect the
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
253 ;; correct window.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
254 (select-window minibuffer)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
255 ;; scale back shrinkage if it would
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
256 ;; make the minibuffer less than 1
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
257 ;; line tall.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
258 (if (and (> growth 0)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
259 (< (- (window-height minibuffer)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
260 growth)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
261 1))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
262 (setq growth (1- (window-height minibuffer))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
263 (enlarge-window (- growth))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
264 (select-window start-event-window))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
265 ;; no. grow/shrink the selected window
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
266 (enlarge-window growth))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
267 ;; if this window's growth caused another
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
268 ;; window to be deleted because it was too
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
269 ;; short, rescind the change.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
270 ;;
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
271 ;; if size change caused space to be stolen
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
272 ;; from a window above this one, rescind the
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
273 ;; change, but only if we didn't grow/srhink
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
274 ;; the minibuffer. minibuffer size changes
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
275 ;; can cause all windows to shrink... no way
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
276 ;; around it.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
277 (if (or (/= start-nwindows (count-windows t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
278 (and (not should-enlarge-minibuffer)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
279 (/= top (nth 1 (window-edges)))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
280 (set-window-configuration wconfig)))))))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
281
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
282 (defun mouse-set-point (event)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
283 "Move point to the position clicked on with the mouse.
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
284 This should be bound to a mouse click event type."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
285 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
286 (mouse-minibuffer-check event)
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
287 ;; Use event-end in case called from mouse-drag-region.
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
288 ;; If EVENT is a click, event-end and event-start give same value.
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
289 (let ((posn (event-end event)))
8426
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
290 (if (not (windowp (posn-window posn)))
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
291 (error "Cursor not in text area of window"))
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
292 (select-window (posn-window posn))
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
293 (if (numberp (posn-point posn))
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
294 (goto-char (posn-point posn)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
296 (defvar mouse-last-region-beg nil)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
297 (defvar mouse-last-region-end nil)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
298 (defvar mouse-last-region-tick nil)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
299
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
300 (defun mouse-region-match ()
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
301 "Return non-nil if there's an active region that was set with the mouse."
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
302 (and (mark t) mark-active
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
303 (eq mouse-last-region-beg (region-beginning))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
304 (eq mouse-last-region-end (region-end))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
305 (eq mouse-last-region-tick (buffer-modified-tick))))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
306
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
307 (defun mouse-set-region (click)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
308 "Set the region to the text dragged over, and copy to kill ring.
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
309 This should be bound to a mouse drag event."
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
310 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
311 (mouse-minibuffer-check click)
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
312 (let ((posn (event-start click))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
313 (end (event-end click)))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
314 (select-window (posn-window posn))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
315 (if (numberp (posn-point posn))
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
316 (goto-char (posn-point posn)))
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
317 ;; If mark is highlighted, no need to bounce the cursor.
12078
eb9f9e9cd522 (mouse-set-region): Don't bounce the cursor on X.
Karl Heuer <kwzh@gnu.org>
parents: 11863
diff changeset
318 ;; On X, we highlight while dragging, thus once again no need to bounce.
eb9f9e9cd522 (mouse-set-region): Don't bounce the cursor on X.
Karl Heuer <kwzh@gnu.org>
parents: 11863
diff changeset
319 (or transient-mark-mode
eb9f9e9cd522 (mouse-set-region): Don't bounce the cursor on X.
Karl Heuer <kwzh@gnu.org>
parents: 11863
diff changeset
320 (eq (framep (selected-frame)) 'x)
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
321 (sit-for 1))
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
322 (push-mark)
2802
02c75b605550 (mouse-set-region): Call set-mark to activate mark.
Richard M. Stallman <rms@gnu.org>
parents: 2799
diff changeset
323 (set-mark (point))
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
324 (if (numberp (posn-point end))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
325 (goto-char (posn-point end)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
326 ;; Don't set this-command to kill-region, so that a following
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
327 ;; C-w will not double the text in the kill ring.
12257
29b6db180047 (mouse-set-region): Bind last-command with this-command.
Richard M. Stallman <rms@gnu.org>
parents: 12078
diff changeset
328 ;; Ignore last-command so we don't append to a preceding kill.
29b6db180047 (mouse-set-region): Bind last-command with this-command.
Richard M. Stallman <rms@gnu.org>
parents: 12078
diff changeset
329 (let (this-command last-command)
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
330 (copy-region-as-kill (mark) (point)))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
331 (mouse-set-region-1)))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
332
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
333 (defun mouse-set-region-1 ()
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
334 (setq mouse-last-region-beg (region-beginning))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
335 (setq mouse-last-region-end (region-end))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
336 (setq mouse-last-region-tick (buffer-modified-tick)))
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
337
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
338 (defvar mouse-scroll-delay 0.25
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
339 "*The pause between scroll steps caused by mouse drags, in seconds.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
340 If you drag the mouse beyond the edge of a window, Emacs scrolls the
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
341 window to bring the text beyond that edge into view, with a delay of
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
342 this many seconds between scroll steps. Scrolling stops when you move
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
343 the mouse back into the window, or release the button.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
344 This variable's value may be non-integral.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
345 Setting this to zero causes Emacs to scroll as fast as it can.")
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
346
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
347 (defun mouse-scroll-subr (window jump &optional overlay start)
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
348 "Scroll the window WINDOW, JUMP lines at a time, until new input arrives.
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
349 If OVERLAY is an overlay, let it stretch from START to the far edge of
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
350 the newly visible text.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
351 Upon exit, point is at the far edge of the newly visible text."
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
352 (let ((opoint (point)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
353 (while (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
354 (goto-char (window-start window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
355 (if (not (zerop (vertical-motion jump window)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
356 (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
357 (set-window-start window (point))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
358 (if (natnump jump)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
359 (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
360 (goto-char (window-end window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
361 ;; window-end doesn't reflect the window's new
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
362 ;; start position until the next redisplay. Hurrah.
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
363 (vertical-motion (1- jump) window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
364 (goto-char (window-start window)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
365 (if overlay
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
366 (move-overlay overlay start (point)))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
367 ;; Now that we have scrolled WINDOW properly,
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
368 ;; put point back where it was for the redisplay
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
369 ;; so that we don't mess up the selected window.
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
370 (or (eq window (selected-window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
371 (goto-char opoint))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
372 (sit-for mouse-scroll-delay)))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
373 (or (eq window (selected-window))
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
374 (goto-char opoint))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
375
11453
5ed0795c4155 Create mouse-drag-overlay as a dead overlay, instead
Karl Heuer <kwzh@gnu.org>
parents: 11235
diff changeset
376 ;; Create an overlay and immediately delete it, to get "overlay in no buffer".
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
377 (defvar mouse-drag-overlay (make-overlay 1 1))
11453
5ed0795c4155 Create mouse-drag-overlay as a dead overlay, instead
Karl Heuer <kwzh@gnu.org>
parents: 11235
diff changeset
378 (delete-overlay mouse-drag-overlay)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
379 (overlay-put mouse-drag-overlay 'face 'region)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
380
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
381 (defvar mouse-selection-click-count 0)
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
382
12436
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
383 (defvar mouse-selection-click-count-buffer nil)
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
384
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
385 (defun mouse-drag-region (start-event)
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
386 "Set the region to the text that the mouse is dragged over.
4532
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
387 Highlight the drag area as you move the mouse.
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
388 This must be bound to a button-down mouse event.
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
389 In Transient Mark mode, the highlighting remains once you
c2afed091afb (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4490
diff changeset
390 release the mouse button. Otherwise, it does not."
3566
dc2b64ef30dc (mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents: 3420
diff changeset
391 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
392 (mouse-minibuffer-check start-event)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
393 (let* ((start-posn (event-start start-event))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
394 (start-point (posn-point start-posn))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
395 (start-window (posn-window start-posn))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
396 (start-frame (window-frame start-window))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
397 (bounds (window-edges start-window))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
398 (top (nth 1 bounds))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
399 (bottom (if (window-minibuffer-p start-window)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
400 (nth 3 bounds)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
401 ;; Don't count the mode line.
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
402 (1- (nth 3 bounds))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
403 (click-count (1- (event-click-count start-event))))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
404 (setq mouse-selection-click-count click-count)
12436
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
405 (setq mouse-selection-click-count-buffer (current-buffer))
4490
8362b57424dc (mouse-set-point): Error if click in inactive minibuffer.
Richard M. Stallman <rms@gnu.org>
parents: 4472
diff changeset
406 (mouse-set-point start-event)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
407 (let ((range (mouse-start-end start-point start-point click-count)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
408 (move-overlay mouse-drag-overlay (car range) (nth 1 range)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
409 (window-buffer start-window)))
4200
3f5f55401364 (mouse-drag-region): Use deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents: 4081
diff changeset
410 (deactivate-mark)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
411 (let (event end end-point)
3566
dc2b64ef30dc (mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents: 3420
diff changeset
412 (track-mouse
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
413 (while (progn
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
414 (setq event (read-event))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
415 (or (mouse-movement-p event)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
416 (eq (car-safe event) 'switch-frame)))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
417 (if (eq (car-safe event) 'switch-frame)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
418 nil
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
419 (setq end (event-end event)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
420 end-point (posn-point end))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
421
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
422 (cond
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
423 ;; Are we moving within the original window?
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
424 ((and (eq (posn-window end) start-window)
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
425 (integer-or-marker-p end-point))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
426 (goto-char end-point)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
427 (let ((range (mouse-start-end start-point (point) click-count)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
428 (move-overlay mouse-drag-overlay (car range) (nth 1 range))))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
429
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
430 (t
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
431 (let ((mouse-row (cdr (cdr (mouse-position)))))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
432 (cond
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
433 ((null mouse-row))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
434 ((< mouse-row top)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
435 (mouse-scroll-subr start-window (- mouse-row top)
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
436 mouse-drag-overlay start-point))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
437 ((>= mouse-row bottom)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
438 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
439 mouse-drag-overlay start-point)))))))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
440 (if (consp event)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
441 (let ((fun (key-binding (vector (car event)))))
10554
f5f5c52de2e4 (mouse-drag-region): Modify previous change--don't run the ordinary binding
Richard M. Stallman <rms@gnu.org>
parents: 10553
diff changeset
442 ;; Run the binding of the terminating up-event, if possible.
f5f5c52de2e4 (mouse-drag-region): Modify previous change--don't run the ordinary binding
Richard M. Stallman <rms@gnu.org>
parents: 10553
diff changeset
443 ;; In the case of a multiple click, it gives the wrong results,
f5f5c52de2e4 (mouse-drag-region): Modify previous change--don't run the ordinary binding
Richard M. Stallman <rms@gnu.org>
parents: 10553
diff changeset
444 ;; because it would fail to set up a region.
f5f5c52de2e4 (mouse-drag-region): Modify previous change--don't run the ordinary binding
Richard M. Stallman <rms@gnu.org>
parents: 10553
diff changeset
445 (if (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
446 (progn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
447 (setq this-command fun)
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
448 ;; Delete the overlay before calling the function,
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
449 ;; because delete-overlay increases buffer-modified-tick.
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
450 (delete-overlay mouse-drag-overlay)
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
451 (funcall fun event))
10369
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
452 (if (not (= (overlay-start mouse-drag-overlay)
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
453 (overlay-end mouse-drag-overlay)))
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
454 (let (last-command this-command)
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
455 (push-mark (overlay-start mouse-drag-overlay) t t)
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
456 (goto-char (overlay-end mouse-drag-overlay))
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
457 (delete-overlay mouse-drag-overlay)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
458 (copy-region-as-kill (point) (mark t))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
459 (mouse-set-region-1))
10369
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
460 (goto-char (overlay-end mouse-drag-overlay))
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
461 (setq this-command 'mouse-set-point)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
462 (delete-overlay mouse-drag-overlay))))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
463 (delete-overlay mouse-drag-overlay)))))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
464
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
465 ;; Commands to handle xterm-style multiple clicks.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
466
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
467 (defun mouse-skip-word (dir)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
468 "Skip over word, over whitespace, or over identical punctuation.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
469 If DIR is positive skip forward; if negative, skip backward."
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
470 (let* ((char (following-char))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
471 (syntax (char-to-string (char-syntax char))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
472 (if (or (string= syntax "w") (string= syntax " "))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
473 (if (< dir 0)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
474 (skip-syntax-backward syntax)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
475 (skip-syntax-forward syntax))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
476 (if (< dir 0)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
477 (while (and (not (bobp)) (= (preceding-char) char))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
478 (forward-char -1))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
479 (while (and (not (eobp)) (= (following-char) char))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
480 (forward-char 1))))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
481
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
482 ;; Return a list of region bounds based on START and END according to MODE.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
483 ;; If MODE is 0 then set point to (min START END), mark to (max START END).
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
484 ;; If MODE is 1 then set point to start of word at (min START END),
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
485 ;; mark to end of word at (max START END).
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
486 ;; If MODE is 2 then do the same for lines.
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
487 (defun mouse-start-end (start end mode)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
488 (if (> start end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
489 (let ((temp start))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
490 (setq start end
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
491 end temp)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
492 (setq mode (mod mode 3))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
493 (cond ((= mode 0)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
494 (list start end))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
495 ((and (= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
496 (= start end)
5869
91dcabd87088 (mouse-start-end): Check START rather than point for being at eob.
Karl Heuer <kwzh@gnu.org>
parents: 5799
diff changeset
497 (char-after start)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
498 (= (char-syntax (char-after start)) ?\())
5879
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
499 (list start
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
500 (save-excursion
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
501 (goto-char start)
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
502 (forward-sexp 1)
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
503 (point))))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
504 ((and (= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
505 (= start end)
5869
91dcabd87088 (mouse-start-end): Check START rather than point for being at eob.
Karl Heuer <kwzh@gnu.org>
parents: 5799
diff changeset
506 (char-after start)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
507 (= (char-syntax (char-after start)) ?\)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
508 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
509 (goto-char (1+ start))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
510 (backward-sexp 1)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
511 (point))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
512 (1+ start)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
513 ((= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
514 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
515 (goto-char start)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
516 (mouse-skip-word -1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
517 (point))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
518 (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
519 (goto-char end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
520 (mouse-skip-word 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
521 (point))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
522 ((= mode 2)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
523 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
524 (goto-char start)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
525 (beginning-of-line 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
526 (point))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
527 (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
528 (goto-char end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
529 (forward-line 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
530 (point))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
531
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
532 ;; Subroutine: set the mark where CLICK happened,
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
533 ;; but don't do anything else.
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
534 (defun mouse-set-mark-fast (click)
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
535 (mouse-minibuffer-check click)
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
536 (let ((posn (event-start click)))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
537 (select-window (posn-window posn))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
538 (if (numberp (posn-point posn))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
539 (push-mark (posn-point posn) t t))))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
540
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
541 ;; Momentarily show where the mark is, if highlighting doesn't show it.
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
542 (defun mouse-show-mark ()
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
543 (or transient-mark-mode
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
544 (save-excursion
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
545 (goto-char (mark t))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
546 (sit-for 1))))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
547
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
548 (defun mouse-set-mark (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
549 "Set mark at the position clicked on with the mouse.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
550 Display cursor at that position for a second.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
551 This must be bound to a mouse click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
552 (interactive "e")
8534
a446d13c46ea (mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents: 8519
diff changeset
553 (mouse-minibuffer-check click)
a446d13c46ea (mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents: 8519
diff changeset
554 (select-window (posn-window (event-start click)))
a446d13c46ea (mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents: 8519
diff changeset
555 ;; We don't use save-excursion because that preserves the mark too.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (let ((point-save (point)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (unwind-protect
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
558 (progn (mouse-set-point click)
3119
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
559 (push-mark nil t t)
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
560 (or transient-mark-mode
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
561 (sit-for 1)))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (goto-char point-save))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
564 (defun mouse-kill (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
565 "Kill the region between point and the mouse click.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
566 The text is saved in the kill ring, as with \\[kill-region]."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
567 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
568 (mouse-minibuffer-check click)
6301
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
569 (let* ((posn (event-start click))
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
570 (click-posn (posn-point posn)))
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
571 (select-window (posn-window posn))
1039
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
572 (if (numberp click-posn)
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
573 (kill-region (min (point) click-posn)
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
574 (max (point) click-posn)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
576 (defun mouse-yank-at-click (click arg)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
577 "Insert the last stretch of killed text at the position clicked on.
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
578 Also move point to one end of the text thus inserted (normally the end).
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
579 Prefix arguments are interpreted as with \\[yank].
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
580 If `mouse-yank-at-point' is non-nil, insert at point
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
581 regardless of where you click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
582 (interactive "e\nP")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
583 ;; Give temporary modes such as isearch a chance to turn off.
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
584 (run-hooks 'mouse-leave-buffer-hook)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
585 (or mouse-yank-at-point (mouse-set-point click))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
586 (setq this-command 'yank)
12357
8d2679d3f095 (mouse-yank-at-click): Clear mouse-selection-click-count.
Richard M. Stallman <rms@gnu.org>
parents: 12257
diff changeset
587 (setq mouse-selection-click-count 0)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
588 (yank arg))
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
589
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
590 (defun mouse-kill-ring-save (click)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
591 "Copy the region between point and the mouse click in the kill ring.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
592 This does not delete the region; it acts like \\[kill-ring-save]."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
593 (interactive "e")
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
594 (mouse-set-mark-fast click)
8135
1f57b34ade27 (mouse-drag-region): Bind this-command like last-command.
Richard M. Stallman <rms@gnu.org>
parents: 8117
diff changeset
595 (let (this-command last-command)
1f57b34ade27 (mouse-drag-region): Bind this-command like last-command.
Richard M. Stallman <rms@gnu.org>
parents: 8117
diff changeset
596 (kill-ring-save (point) (mark t)))
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
597 (mouse-show-mark))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
599 ;;; This function used to delete the text between point and the mouse
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
600 ;;; whenever it was equal to the front of the kill ring, but some
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
601 ;;; people found that confusing.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
602
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
603 ;;; A list (TEXT START END), describing the text and position of the last
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
604 ;;; invocation of mouse-save-then-kill.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
605 (defvar mouse-save-then-kill-posn nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
606
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
607 (defun mouse-save-then-kill-delete-region (beg end)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
608 ;; We must make our own undo boundaries
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
609 ;; because they happen automatically only for the current buffer.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
610 (undo-boundary)
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
611 (if (or (= beg end) (eq buffer-undo-list t))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
612 ;; If we have no undo list in this buffer,
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
613 ;; just delete.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
614 (delete-region beg end)
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
615 ;; Delete, but make the undo-list entry share with the kill ring.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
616 ;; First, delete just one char, so in case buffer is being modified
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
617 ;; for the first time, the undo list records that fact.
7866
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
618 (let (before-change-function after-change-function
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
619 before-change-functions after-change-functions)
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
620 (delete-region beg
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
621 (+ beg (if (> end beg) 1 -1))))
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
622 (let ((buffer-undo-list buffer-undo-list))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
623 ;; Undo that deletion--but don't change the undo list!
7866
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
624 (let (before-change-function after-change-function
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
625 before-change-functions after-change-functions)
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
626 (primitive-undo 1 buffer-undo-list))
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
627 ;; Now delete the rest of the specified region,
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
628 ;; but don't record it.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
629 (setq buffer-undo-list t)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
630 (if (/= (length (car kill-ring)) (- (max end beg) (min end beg)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
631 (error "Lossage in mouse-save-then-kill-delete-region"))
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
632 (delete-region beg end))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
633 (let ((tail buffer-undo-list))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
634 ;; Search back in buffer-undo-list for the string
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
635 ;; that came from deleting one character.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
636 (while (and tail (not (stringp (car (car tail)))))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
637 (setq tail (cdr tail)))
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
638 ;; Replace it with an entry for the entire deleted text.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
639 (and tail
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
640 (setcar tail (cons (car kill-ring) (min beg end))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
641 (undo-boundary))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
642
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
643 (defun mouse-save-then-kill (click)
1765
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
644 "Save text to point in kill ring; the second time, kill the text.
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
645 If the text between point and the mouse is the same as what's
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
646 at the front of the kill ring, this deletes the text.
1cc3ee5afc82 (mouse-save-then-kill): When deleting, avoid delay
Richard M. Stallman <rms@gnu.org>
parents: 1728
diff changeset
647 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
648 which prepares for a second click to delete the text.
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
649
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
650 If you have selected words or lines, this command extends the
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
651 selection through the word or line clicked on. If you do this
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
652 again in a different position, it extends the selection again.
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
653 If you do this twice in the same position, the selection is killed."
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
654 (interactive "e")
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
655 (let ((before-scroll point-before-scroll))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
656 (mouse-minibuffer-check click)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
657 (let ((click-posn (posn-point (event-start click)))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
658 ;; Don't let a subsequent kill command append to this one:
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
659 ;; prevent setting this-command to kill-region.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
660 (this-command this-command))
12436
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
661 (if (and (save-excursion
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
662 (set-buffer (window-buffer (posn-window (event-start click))))
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
663 (and (mark t) (> (mod mouse-selection-click-count 3) 0)
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
664 ;; Don't be fooled by a recent click in some other buffer.
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
665 (eq mouse-selection-click-count-buffer
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
666 (current-buffer)))))
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
667 (if (not (and (eq last-command 'mouse-save-then-kill)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
668 (equal click-posn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
669 (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
670 ;; Find both ends of the object selected by this click.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
671 (let* ((range
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
672 (mouse-start-end click-posn click-posn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
673 mouse-selection-click-count)))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
674 ;; Move whichever end is closer to the click.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
675 ;; That's what xterm does, and it seems reasonable.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
676 (if (< (abs (- click-posn (mark t)))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
677 (abs (- click-posn (point))))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
678 (set-mark (car range))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
679 (goto-char (nth 1 range)))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
680 ;; We have already put the old region in the kill ring.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
681 ;; Replace it with the extended region.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
682 ;; (It would be annoying to make a separate entry.)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
683 (kill-new (buffer-substring (point) (mark t)) t)
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
684 (mouse-set-region-1)
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
685 ;; Arrange for a repeated mouse-3 to kill this region.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
686 (setq mouse-save-then-kill-posn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
687 (list (car kill-ring) (point) click-posn))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
688 (mouse-show-mark))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
689 ;; If we click this button again without moving it,
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
690 ;; that time kill.
11818
f470809e6a60 (mouse-save-then-kill): When making a new region
Richard M. Stallman <rms@gnu.org>
parents: 11453
diff changeset
691 (mouse-save-then-kill-delete-region (mark) (point))
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
692 (setq mouse-selection-click-count 0)
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
693 (setq mouse-save-then-kill-posn nil))
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
694 (if (and (eq last-command 'mouse-save-then-kill)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
695 mouse-save-then-kill-posn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
696 (eq (car mouse-save-then-kill-posn) (car kill-ring))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
697 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
698 ;; If this is the second time we've called
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
699 ;; mouse-save-then-kill, delete the text from the buffer.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
700 (progn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
701 (mouse-save-then-kill-delete-region (point) (mark))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
702 ;; After we kill, another click counts as "the first time".
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
703 (setq mouse-save-then-kill-posn nil))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
704 (if (or (and (eq last-command 'mouse-save-then-kill)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
705 mouse-save-then-kill-posn)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
706 (and mark-active transient-mark-mode)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
707 (and (memq last-command
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
708 '(mouse-drag-region mouse-set-region))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
709 (or mark-even-if-inactive
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
710 (not transient-mark-mode))))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
711 ;; We have a selection or suitable region, so adjust it.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
712 (let* ((posn (event-start click))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
713 (new (posn-point posn)))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
714 (select-window (posn-window posn))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
715 (if (numberp new)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
716 (progn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
717 ;; Move whichever end of the region is closer to the click.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
718 ;; That is what xterm does, and it seems reasonable.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
719 (if (< (abs (- new (point))) (abs (- new (mark t))))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
720 (goto-char new)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
721 (set-mark new))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
722 (setq deactivate-mark nil)))
11818
f470809e6a60 (mouse-save-then-kill): When making a new region
Richard M. Stallman <rms@gnu.org>
parents: 11453
diff changeset
723 (kill-new (buffer-substring (point) (mark t)) t)
f470809e6a60 (mouse-save-then-kill): When making a new region
Richard M. Stallman <rms@gnu.org>
parents: 11453
diff changeset
724 (mouse-show-mark))
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
725 ;; Set the mark where point is, then move where clicked.
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
726 (mouse-set-mark-fast click)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
727 (if before-scroll
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
728 (goto-char before-scroll))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
729 (exchange-point-and-mark)
11863
18e97591e9bd (mouse-save-then-kill): Fix previous change.
Karl Heuer <kwzh@gnu.org>
parents: 11818
diff changeset
730 (kill-new (buffer-substring (point) (mark t))))
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
731 (mouse-set-region-1)
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
732 (setq mouse-save-then-kill-posn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
733 (list (car kill-ring) (point) click-posn)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
734
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
735 (global-set-key [M-mouse-1] 'mouse-start-secondary)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
736 (global-set-key [M-drag-mouse-1] 'mouse-set-secondary)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
737 (global-set-key [M-down-mouse-1] 'mouse-drag-secondary)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
738 (global-set-key [M-mouse-3] 'mouse-secondary-save-then-kill)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
739 (global-set-key [M-mouse-2] 'mouse-yank-secondary)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
740
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
741 ;; An overlay which records the current secondary selection
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
742 ;; or else is deleted when there is no secondary selection.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
743 ;; May be nil.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
744 (defvar mouse-secondary-overlay nil)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
745
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
746 (defvar mouse-secondary-click-count 0)
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
747
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
748 ;; A marker which records the specified first end for a secondary selection.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
749 ;; May be nil.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
750 (defvar mouse-secondary-start nil)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
751
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
752 (defun mouse-start-secondary (click)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
753 "Set one end of the secondary selection to the position clicked on.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
754 Use \\[mouse-secondary-save-then-kill] to set the other end
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
755 and complete the secondary selection."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
756 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
757 (mouse-minibuffer-check click)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
758 (let ((posn (event-start click)))
3823
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
759 (save-excursion
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
760 (set-buffer (window-buffer (posn-window posn)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
761 ;; Cancel any preexisting secondary selection.
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
762 (if mouse-secondary-overlay
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
763 (delete-overlay mouse-secondary-overlay))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
764 (if (numberp (posn-point posn))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
765 (progn
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
766 (or mouse-secondary-start
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
767 (setq mouse-secondary-start (make-marker)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
768 (move-marker mouse-secondary-start (posn-point posn)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
769
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
770 (defun mouse-set-secondary (click)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
771 "Set the secondary selection to the text that the mouse is dragged over.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
772 This must be bound to a mouse drag event."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
773 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
774 (mouse-minibuffer-check click)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
775 (let ((posn (event-start click))
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
776 beg
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
777 (end (event-end click)))
3823
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
778 (save-excursion
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
779 (set-buffer (window-buffer (posn-window posn)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
780 (if (numberp (posn-point posn))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
781 (setq beg (posn-point posn)))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
782 (if mouse-secondary-overlay
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
783 (move-overlay mouse-secondary-overlay beg (posn-point end))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
784 (setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
785 (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
786
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
787 (defun mouse-drag-secondary (start-event)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
788 "Set the secondary selection to the text that the mouse is dragged over.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
789 Highlight the drag area as you move the mouse.
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
790 This must be bound to a button-down mouse event."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
791 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
792 (mouse-minibuffer-check start-event)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
793 (let* ((start-posn (event-start start-event))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
794 (start-point (posn-point start-posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
795 (start-window (posn-window start-posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
796 (start-frame (window-frame start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
797 (bounds (window-edges start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
798 (top (nth 1 bounds))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
799 (bottom (if (window-minibuffer-p start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
800 (nth 3 bounds)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
801 ;; Don't count the mode line.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
802 (1- (nth 3 bounds))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
803 (click-count (1- (event-click-count start-event))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
804 (save-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
805 (set-buffer (window-buffer start-window))
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
806 (setq mouse-secondary-click-count click-count)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
807 (or mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
808 (setq mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
809 (make-overlay (point) (point))))
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
810 (overlay-put mouse-secondary-overlay 'face 'secondary-selection)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
811 (if (> (mod click-count 3) 0)
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
812 ;; Double or triple press: make an initial selection
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
813 ;; of one word or line.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
814 (let ((range (mouse-start-end start-point start-point click-count)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
815 (set-marker mouse-secondary-start nil)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
816 (move-overlay mouse-secondary-overlay 1 1
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
817 (window-buffer start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
818 (move-overlay mouse-secondary-overlay (car range) (nth 1 range)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
819 (window-buffer start-window)))
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
820 ;; Single-press: cancel any preexisting secondary selection.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
821 (or mouse-secondary-start
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
822 (setq mouse-secondary-start (make-marker)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
823 (set-marker mouse-secondary-start start-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
824 (delete-overlay mouse-secondary-overlay))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
825 (let (event end end-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
826 (track-mouse
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
827 (while (progn
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
828 (setq event (read-event))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
829 (or (mouse-movement-p event)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
830 (eq (car-safe event) 'switch-frame)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
831
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
832 (if (eq (car-safe event) 'switch-frame)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
833 nil
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
834 (setq end (event-end event)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
835 end-point (posn-point end))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
836 (cond
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
837 ;; Are we moving within the original window?
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
838 ((and (eq (posn-window end) start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
839 (integer-or-marker-p end-point))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
840 (let ((range (mouse-start-end start-point end-point
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
841 click-count)))
8224
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
842 (if (or (/= start-point end-point)
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
843 (null (marker-position mouse-secondary-start)))
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
844 (progn
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
845 (set-marker mouse-secondary-start nil)
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
846 (move-overlay mouse-secondary-overlay
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
847 (car range) (nth 1 range))))))
7588
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
848 (t
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
849 (let ((mouse-row (cdr (cdr (mouse-position)))))
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
850 (cond
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
851 ((null mouse-row))
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
852 ((< mouse-row top)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
853 (mouse-scroll-subr start-window (- mouse-row top)
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
854 mouse-secondary-overlay start-point))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
855 ((>= mouse-row bottom)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
856 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
7588
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
857 mouse-secondary-overlay start-point)))))))))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
858
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
859 (if (consp event)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
860 ;;; (eq (get (event-basic-type event) 'event-kind) 'mouse-click)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
861 ;;; (eq (posn-window (event-end event)) start-window)
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
862 ;;; (numberp (posn-point (event-end event)))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
863 (if (marker-position mouse-secondary-start)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
864 (save-window-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
865 (delete-overlay mouse-secondary-overlay)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
866 (x-set-selection 'SECONDARY nil)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
867 (select-window start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
868 (save-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
869 (goto-char mouse-secondary-start)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
870 (sit-for 1)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
871 (x-set-selection
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
872 'SECONDARY
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
873 (buffer-substring (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
874 (overlay-end mouse-secondary-overlay)))))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
875
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
876 (defun mouse-yank-secondary (click)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
877 "Insert the secondary selection at the position clicked on.
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
878 Move point to the end of the inserted text.
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
879 If `mouse-yank-at-point' is non-nil, insert at point
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
880 regardless of where you click."
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
881 (interactive "e")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
882 ;; Give temporary modes such as isearch a chance to turn off.
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
883 (run-hooks 'mouse-leave-buffer-hook)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
884 (or mouse-yank-at-point (mouse-set-point click))
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
885 (insert (x-get-selection 'SECONDARY)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
886
5280
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
887 (defun mouse-kill-secondary ()
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
888 "Kill the text in the secondary selection.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
889 This is intended more as a keyboard command than as a mouse command
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
890 but it can work as either one.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
891
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
892 The current buffer (in case of keyboard use), or the buffer clicked on,
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
893 must be the one that the secondary selection is in. This requirement
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
894 is to prevent accidents."
5280
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
895 (interactive)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
896 (let* ((keys (this-command-keys))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
897 (click (elt keys (1- (length keys)))))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
898 (or (eq (overlay-buffer mouse-secondary-overlay)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
899 (if (listp click)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
900 (window-buffer (posn-window (event-start click)))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
901 (current-buffer)))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
902 (error "Select or click on the buffer where the secondary selection is")))
10838
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
903 (let (this-command)
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
904 (save-excursion
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
905 (set-buffer (overlay-buffer mouse-secondary-overlay))
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
906 (kill-region (overlay-start mouse-secondary-overlay)
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
907 (overlay-end mouse-secondary-overlay))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
908 (delete-overlay mouse-secondary-overlay)
10838
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
909 ;;; (x-set-selection 'SECONDARY nil)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
910 (setq mouse-secondary-overlay nil))
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
911
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
912 (defun mouse-secondary-save-then-kill (click)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
913 "Save text to point in kill ring; the second time, kill the text.
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
914 You must use this in a buffer where you have recently done \\[mouse-start-secondary].
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
915 If the text between where you did \\[mouse-start-secondary] and where
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
916 you use this command matches the text at the front of the kill ring,
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
917 this command deletes the text.
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
918 Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
919 which prepares for a second click with this command to delete the text.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
920
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
921 If you have already made a secondary selection in that buffer,
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
922 this command extends or retracts the selection to where you click.
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
923 If you do this again in a different position, it extends or retracts
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
924 again. If you do this twice in the same position, it kills the selection."
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
925 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
926 (mouse-minibuffer-check click)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
927 (let ((posn (event-start click))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
928 (click-posn (posn-point (event-start click)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
929 ;; Don't let a subsequent kill command append to this one:
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
930 ;; prevent setting this-command to kill-region.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
931 (this-command this-command))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
932 (or (eq (window-buffer (posn-window posn))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
933 (or (and mouse-secondary-overlay
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
934 (overlay-buffer mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
935 (if mouse-secondary-start
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
936 (marker-buffer mouse-secondary-start))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
937 (error "Wrong buffer"))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
938 (save-excursion
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
939 (set-buffer (window-buffer (posn-window posn)))
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
940 (if (> (mod mouse-secondary-click-count 3) 0)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
941 (if (not (and (eq last-command 'mouse-secondary-save-then-kill)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
942 (equal click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
943 (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
944 ;; Find both ends of the object selected by this click.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
945 (let* ((range
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
946 (mouse-start-end click-posn click-posn
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
947 mouse-secondary-click-count)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
948 ;; Move whichever end is closer to the click.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
949 ;; That's what xterm does, and it seems reasonable.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
950 (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
951 (abs (- click-posn (overlay-end mouse-secondary-overlay))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
952 (move-overlay mouse-secondary-overlay (car range)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
953 (overlay-end mouse-secondary-overlay))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
954 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
955 (overlay-start mouse-secondary-overlay)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
956 (nth 1 range)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
957 ;; We have already put the old region in the kill ring.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
958 ;; Replace it with the extended region.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
959 ;; (It would be annoying to make a separate entry.)
8765
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
960 (kill-new (buffer-substring
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
961 (overlay-start mouse-secondary-overlay)
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
962 (overlay-end mouse-secondary-overlay)) t)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
963 ;; Arrange for a repeated mouse-3 to kill this region.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
964 (setq mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
965 (list (car kill-ring) (point) click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
966 ;; If we click this button again without moving it,
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
967 ;; that time kill.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
968 (progn
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
969 (mouse-save-then-kill-delete-region
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
970 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
971 (overlay-end mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
972 (setq mouse-save-then-kill-posn nil)
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
973 (setq mouse-secondary-click-count 0)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
974 (delete-overlay mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
975 (if (and (eq last-command 'mouse-secondary-save-then-kill)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
976 mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
977 (eq (car mouse-save-then-kill-posn) (car kill-ring))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
978 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
979 ;; If this is the second time we've called
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
980 ;; mouse-secondary-save-then-kill, delete the text from the buffer.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
981 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
982 (mouse-save-then-kill-delete-region
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
983 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
984 (overlay-end mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
985 (setq mouse-save-then-kill-posn nil)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
986 (delete-overlay mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
987 (if (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
988 ;; We have a selection, so adjust it.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
989 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
990 (if (numberp click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
991 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
992 ;; Move whichever end of the region is closer to the click.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
993 ;; That is what xterm does, and it seems reasonable.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
994 (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
995 (abs (- click-posn (overlay-end mouse-secondary-overlay))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
996 (move-overlay mouse-secondary-overlay click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
997 (overlay-end mouse-secondary-overlay))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
998 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
999 (overlay-start mouse-secondary-overlay)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1000 click-posn))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1001 (setq deactivate-mark nil)))
8224
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
1002 (if (eq last-command 'mouse-secondary-save-then-kill)
8765
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
1003 ;; If the front of the kill ring comes from
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
1004 ;; an immediately previous use of this command,
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
1005 ;; replace it with the extended region.
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
1006 ;; (It would be annoying to make a separate entry.)
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
1007 (kill-new (buffer-substring
8224
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
1008 (overlay-start mouse-secondary-overlay)
8765
77933f36ddc2 (mouse-save-then-kill, mouse-secondary-save-then-kill): Use the kill-new
Karl Heuer <kwzh@gnu.org>
parents: 8534
diff changeset
1009 (overlay-end mouse-secondary-overlay)) t)
8224
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
1010 (copy-region-as-kill (overlay-start mouse-secondary-overlay)
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
1011 (overlay-end mouse-secondary-overlay))))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1012 (if mouse-secondary-start
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1013 ;; All we have is one end of a selection,
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1014 ;; so put the other end here.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1015 (let ((start (+ 0 mouse-secondary-start)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1016 (kill-ring-save start click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1017 (if mouse-secondary-overlay
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1018 (move-overlay mouse-secondary-overlay start click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1019 (setq mouse-secondary-overlay (make-overlay start click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1020 (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1021 (setq mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1022 (list (car kill-ring) (point) click-posn))))
10782
806b3e3fd93c (mouse-buffer-menu): Don't clear selection when we kill it.
Richard M. Stallman <rms@gnu.org>
parents: 10720
diff changeset
1023 (if (overlay-buffer mouse-secondary-overlay)
806b3e3fd93c (mouse-buffer-menu): Don't clear selection when we kill it.
Richard M. Stallman <rms@gnu.org>
parents: 10720
diff changeset
1024 (x-set-selection 'SECONDARY
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1025 (buffer-substring
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1026 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1027 (overlay-end mouse-secondary-overlay)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1028
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1029 (defun mouse-buffer-menu (event)
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1030 "Pop up a menu of buffers for selection with the mouse.
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1031 This switches buffers in the window that you clicked on,
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1032 and selects that window."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
1033 (interactive "e")
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
1034 (mouse-minibuffer-check event)
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1035 (let ((menu
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1036 (list "Buffer Menu"
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1037 (cons "Select Buffer"
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1038 (let ((tail (buffer-list))
3899
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1039 (maxbuf 0)
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1040 head)
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1041 (while tail
3899
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1042 (or (eq ?\ (aref (buffer-name (car tail)) 0))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1043 (setq maxbuf
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1044 (max maxbuf
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1045 (length (buffer-name (car tail))))))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1046 (setq tail (cdr tail)))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1047 (setq tail (buffer-list))
a0655a72182b (mouse-buffer-menu): Include % and * in each item.
Richard M. Stallman <rms@gnu.org>
parents: 3823
diff changeset
1048 (while tail
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1049 (let ((elt (car tail)))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1050 (if (not (string-match "^ "
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1051 (buffer-name elt)))
10790
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1052 (setq head
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1053 (cons
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1054 (cons
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1055 (format
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1056 (format "%%%ds %%s%%s %%s" maxbuf)
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1057 (buffer-name elt)
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1058 (if (buffer-modified-p elt) "*" " ")
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1059 (save-excursion
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1060 (set-buffer elt)
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1061 (if buffer-read-only "%" " "))
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1062 (or (buffer-file-name elt)
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1063 (save-excursion
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1064 (set-buffer elt)
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1065 (if list-buffers-directory
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1066 (expand-file-name
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1067 list-buffers-directory)))
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1068 ""))
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1069 elt)
7d1a9faaf158 Made mouse-buffer-menu use list-buffers-directory if buffer-file-name is nil.
Simon Marshall <simon@gnu.org>
parents: 10782
diff changeset
1070 head))))
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1071 (setq tail (cdr tail)))
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1072 (reverse head))))))
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1073 (let ((buf (x-popup-menu event menu))
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1074 (window (posn-window (event-start event))))
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1075 (if buf
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1076 (progn
3420
08adfe96ca93 (mouse-buffer-menu): Don't select the event's window,
Richard M. Stallman <rms@gnu.org>
parents: 3231
diff changeset
1077 (or (framep window) (select-window window))
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1078 (switch-to-buffer buf))))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1080 ;;; These need to be rewritten for the new scroll bar implementation.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1082 ;;;!! ;; Commands for the scroll bar.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1083 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1084 ;;;!! (defun mouse-scroll-down (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1085 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1086 ;;;!! (scroll-down (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1087 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1088 ;;;!! (defun mouse-scroll-up (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1089 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1090 ;;;!! (scroll-up (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1091 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1092 ;;;!! (defun mouse-scroll-down-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1093 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1094 ;;;!! (scroll-down nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1095 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1096 ;;;!! (defun mouse-scroll-up-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1097 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1098 ;;;!! (scroll-up nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1099 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1100 ;;;!! (defun mouse-scroll-move-cursor (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1101 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1102 ;;;!! (move-to-window-line (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1103 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1104 ;;;!! (defun mouse-scroll-absolute (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1105 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1106 ;;;!! (let* ((pos (car event))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1107 ;;;!! (position (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1108 ;;;!! (length (car (cdr pos))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1109 ;;;!! (if (<= length 0) (setq length 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1110 ;;;!! (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1111 ;;;!! (newpos (* (/ (* (/ (buffer-size) scale-factor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1112 ;;;!! position)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1113 ;;;!! length)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1114 ;;;!! scale-factor)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1115 ;;;!! (goto-char newpos)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1116 ;;;!! (recenter '(4)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1117 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1118 ;;;!! (defun mouse-scroll-left (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1119 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1120 ;;;!! (scroll-left (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1121 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1122 ;;;!! (defun mouse-scroll-right (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1123 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1124 ;;;!! (scroll-right (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1125 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1126 ;;;!! (defun mouse-scroll-left-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1127 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1128 ;;;!! (scroll-left nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1129 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1130 ;;;!! (defun mouse-scroll-right-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1131 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1132 ;;;!! (scroll-right nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1133 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1134 ;;;!! (defun mouse-scroll-move-cursor-horizontally (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1135 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1136 ;;;!! (move-to-column (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1137 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1138 ;;;!! (defun mouse-scroll-absolute-horizontally (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1139 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1140 ;;;!! (let* ((pos (car event))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1141 ;;;!! (position (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1142 ;;;!! (length (car (cdr pos))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1143 ;;;!! (set-window-hscroll (selected-window) 33)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1144 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1145 ;;;!! (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1146 ;;;!! (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1147 ;;;!! (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1148 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1149 ;;;!! (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1150 ;;;!! (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1151 ;;;!! (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1152 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1153 ;;;!! (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1154 ;;;!! (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1155 ;;;!! (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1156 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1157 ;;;!! (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1158 ;;;!! (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1159 ;;;!! (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1160 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1161 ;;;!! (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1162 ;;;!! (global-set-key [horizontal-scroll-bar mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1163 ;;;!! 'mouse-scroll-absolute-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1164 ;;;!! (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1165 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1166 ;;;!! (global-set-key [horizontal-slider mouse-1]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1167 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1168 ;;;!! (global-set-key [horizontal-slider mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1169 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1170 ;;;!! (global-set-key [horizontal-slider mouse-3]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1171 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1172 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1173 ;;;!! (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1174 ;;;!! (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1175 ;;;!! (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1176 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1177 ;;;!! (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1178 ;;;!! (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1179 ;;;!! (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1180 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1181 ;;;!! (global-set-key [horizontal-scroll-bar S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1182 ;;;!! 'mouse-split-window-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1183 ;;;!! (global-set-key [mode-line S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1184 ;;;!! 'mouse-split-window-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1185 ;;;!! (global-set-key [vertical-scroll-bar S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1186 ;;;!! 'mouse-split-window)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1187
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1188 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1189 ;;;!! ;;;; Here are experimental things being tested. Mouse events
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1190 ;;;!! ;;;; are of the form:
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1191 ;;;!! ;;;; ((x y) window screen-part key-sequence timestamp)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1192 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1193 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1194 ;;;!! ;;;; Dynamically track mouse coordinates
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1195 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1196 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1197 ;;;!! ;;(defun track-mouse (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1198 ;;;!! ;; "Track the coordinates, absolute and relative, of the mouse."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1199 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1200 ;;;!! ;; (while mouse-grabbed
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1201 ;;;!! ;; (let* ((pos (read-mouse-position (selected-screen)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1202 ;;;!! ;; (abs-x (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1203 ;;;!! ;; (abs-y (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1204 ;;;!! ;; (relative-coordinate (coordinates-in-window-p
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1205 ;;;!! ;; (list (car pos) (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1206 ;;;!! ;; (selected-window))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1207 ;;;!! ;; (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1208 ;;;!! ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1209 ;;;!! ;; (car relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1210 ;;;!! ;; (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1211 ;;;!! ;; (message "mouse: [%d %d]" abs-x abs-y)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1212 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1213 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1214 ;;;!! ;; Dynamically put a box around the line indicated by point
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1215 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1216 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1217 ;;;!! ;;(require 'backquote)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1218 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1219 ;;;!! ;;(defun mouse-select-buffer-line (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1220 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1221 ;;;!! ;; (let ((relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1222 ;;;!! ;; (coordinates-in-window-p (car event) (selected-window)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1223 ;;;!! ;; (abs-y (car (cdr (car event)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1224 ;;;!! ;; (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1225 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1226 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1227 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1228 ;;;!! ;; (x-draw-rectangle
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1229 ;;;!! ;; (selected-screen)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1230 ;;;!! ;; abs-y 0
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1231 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1232 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1233 ;;;!! ;; (end-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1234 ;;;!! ;; (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1235 ;;;!! ;; (beginning-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1236 ;;;!! ;; (- (region-end) (region-beginning))) 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1237 ;;;!! ;; (sit-for 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1238 ;;;!! ;; (x-erase-rectangle (selected-screen))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1239 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1240 ;;;!! ;;(defvar last-line-drawn nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1241 ;;;!! ;;(defvar begin-delim "[^ \t]")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1242 ;;;!! ;;(defvar end-delim "[^ \t]")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1243 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1244 ;;;!! ;;(defun mouse-boxing (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1245 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1246 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1247 ;;;!! ;; (let ((screen (selected-screen)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1248 ;;;!! ;; (while (= (x-mouse-events) 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1249 ;;;!! ;; (let* ((pos (read-mouse-position screen))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1250 ;;;!! ;; (abs-x (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1251 ;;;!! ;; (abs-y (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1252 ;;;!! ;; (relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1253 ;;;!! ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1254 ;;;!! ;; (selected-window)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1255 ;;;!! ;; (begin-reg nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1256 ;;;!! ;; (end-reg nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1257 ;;;!! ;; (end-column nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1258 ;;;!! ;; (begin-column nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1259 ;;;!! ;; (if (and (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1260 ;;;!! ;; (or (not last-line-drawn)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1261 ;;;!! ;; (not (= last-line-drawn abs-y))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1262 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1263 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1264 ;;;!! ;; (if (= (following-char) 10)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1265 ;;;!! ;; ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1266 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1267 ;;;!! ;; (setq begin-reg (1- (re-search-forward end-delim)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1268 ;;;!! ;; (setq begin-column (1- (current-column)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1269 ;;;!! ;; (end-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1270 ;;;!! ;; (setq end-reg (1+ (re-search-backward begin-delim)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1271 ;;;!! ;; (setq end-column (1+ (current-column)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1272 ;;;!! ;; (message "%s" (buffer-substring begin-reg end-reg))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1273 ;;;!! ;; (x-draw-rectangle screen
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1274 ;;;!! ;; (setq last-line-drawn abs-y)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1275 ;;;!! ;; begin-column
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1276 ;;;!! ;; (- end-column begin-column) 1))))))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1277 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1278 ;;;!! ;;(defun mouse-erase-box ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1279 ;;;!! ;; (interactive)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1280 ;;;!! ;; (if last-line-drawn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1281 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1282 ;;;!! ;; (x-erase-rectangle (selected-screen))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1283 ;;;!! ;; (setq last-line-drawn nil))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1284 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1285 ;;;!! ;;; (defun test-x-rectangle ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1286 ;;;!! ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1287 ;;;!! ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1288 ;;;!! ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1289 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1290 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1291 ;;;!! ;; Here is how to do double clicking in lisp. About to change.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1292 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1293 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1294 ;;;!! (defvar double-start nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1295 ;;;!! (defconst double-click-interval 300
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1296 ;;;!! "Max ticks between clicks")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1297 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1298 ;;;!! (defun double-down (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1299 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1300 ;;;!! (if double-start
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1301 ;;;!! (let ((interval (- (nth 4 event) double-start)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1302 ;;;!! (if (< interval double-click-interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1303 ;;;!! (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1304 ;;;!! (backward-up-list 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1305 ;;;!! ;; (message "Interval %d" interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1306 ;;;!! (sleep-for 1)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1307 ;;;!! (setq double-start nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1308 ;;;!! (setq double-start (nth 4 event))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1309 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1310 ;;;!! (defun double-up (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1311 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1312 ;;;!! (and double-start
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1313 ;;;!! (> (- (nth 4 event ) double-start) double-click-interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1314 ;;;!! (setq double-start nil)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1315 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1316 ;;;!! ;;; (defun x-test-doubleclick ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1317 ;;;!! ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1318 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left 'double-down)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1319 ;;;!! ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1320 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1321 ;;;!! ;;
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1322 ;;;!! ;; This scrolls while button is depressed. Use preferable in scroll bar.
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1323 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1324 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1325 ;;;!! (defvar scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1326 ;;;!! (defconst scroll-speed 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1327 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1328 ;;;!! (defun incr-scroll-down (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1329 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1330 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1331 ;;;!! (incremental-scroll scroll-speed))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1332 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1333 ;;;!! (defun incr-scroll-up (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1334 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1335 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1336 ;;;!! (incremental-scroll (- scroll-speed)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1337 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1338 ;;;!! (defun incremental-scroll (n)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1339 ;;;!! (while (= (x-mouse-events) 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1340 ;;;!! (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1341 ;;;!! (scroll-down n)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1342 ;;;!! (sit-for 300 t)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1343 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1344 ;;;!! (defun incr-scroll-stop (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1345 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1346 ;;;!! (message "Scrolled %d lines" scrolled-lines)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1347 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1348 ;;;!! (sleep-for 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1349 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1350 ;;;!! ;;; (defun x-testing-scroll ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1351 ;;;!! ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1352 ;;;!! ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1353 ;;;!! ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1354 ;;;!! ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1355 ;;;!! ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1356 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1357 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1358 ;;;!! ;; Some playthings suitable for picture mode? They need work.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1359 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1360 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1361 ;;;!! (defun mouse-kill-rectangle (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1362 ;;;!! "Kill the rectangle between point and the mouse cursor."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1363 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1364 ;;;!! (let ((point-save (point)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1365 ;;;!! (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1366 ;;;!! (mouse-set-point event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1367 ;;;!! (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1368 ;;;!! (if (> point-save (point))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1369 ;;;!! (kill-rectangle (point) point-save)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1370 ;;;!! (kill-rectangle point-save (point))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1371 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1372 ;;;!! (defun mouse-open-rectangle (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1373 ;;;!! "Kill the rectangle between point and the mouse cursor."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1374 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1375 ;;;!! (let ((point-save (point)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1376 ;;;!! (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1377 ;;;!! (mouse-set-point event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1378 ;;;!! (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1379 ;;;!! (if (> point-save (point))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1380 ;;;!! (open-rectangle (point) point-save)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1381 ;;;!! (open-rectangle point-save (point))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1382 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1383 ;;;!! ;; Must be a better way to do this.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1384 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1385 ;;;!! (defun mouse-multiple-insert (n char)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1386 ;;;!! (while (> n 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1387 ;;;!! (insert char)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1388 ;;;!! (setq n (1- n))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1389 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1390 ;;;!! ;; What this could do is not finalize until button was released.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1391 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1392 ;;;!! (defun mouse-move-text (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1393 ;;;!! "Move text from point to cursor position, inserting spaces."
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1394 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1395 ;;;!! (let* ((relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1396 ;;;!! (coordinates-in-window-p (car event) (selected-window))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1397 ;;;!! (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1398 ;;;!! (cond ((> (current-column) (car relative-coordinate))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1399 ;;;!! (delete-char
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1400 ;;;!! (- (car relative-coordinate) (current-column))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1401 ;;;!! ((< (current-column) (car relative-coordinate))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1402 ;;;!! (mouse-multiple-insert
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1403 ;;;!! (- (car relative-coordinate) (current-column)) " "))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1404 ;;;!! ((= (current-column) (car relative-coordinate)) (ding))))))
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1405
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1406 ;; Choose a completion with the mouse.
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1407
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1408 (defun mouse-choose-completion (event)
4371
fb0e37e7afae (mouse-choose-completion): Actually choose that alternative,
Richard M. Stallman <rms@gnu.org>
parents: 4294
diff changeset
1409 "Click on an alternative in the `*Completions*' buffer to choose it."
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1410 (interactive "e")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
1411 ;; Give temporary modes such as isearch a chance to turn off.
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
1412 (run-hooks 'mouse-leave-buffer-hook)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1413 (let ((buffer (window-buffer))
8477
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1414 choice
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1415 base-size)
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1416 (save-excursion
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1417 (set-buffer (window-buffer (posn-window (event-start event))))
6163
f349bcb0ff59 (mouse-choose-completion): Use that as the buffer to edit.
Richard M. Stallman <rms@gnu.org>
parents: 6090
diff changeset
1418 (if completion-reference-buffer
f349bcb0ff59 (mouse-choose-completion): Use that as the buffer to edit.
Richard M. Stallman <rms@gnu.org>
parents: 6090
diff changeset
1419 (setq buffer completion-reference-buffer))
8477
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1420 (setq base-size completion-base-size)
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1421 (save-excursion
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1422 (goto-char (posn-point (event-start event)))
7593
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1423 (let (beg end)
8204
f5c8a4e8c4a5 (mouse-choose-completion): Use mouse-face properties to find string to use.
Richard M. Stallman <rms@gnu.org>
parents: 8200
diff changeset
1424 (if (and (not (eobp)) (get-text-property (point) 'mouse-face))
f5c8a4e8c4a5 (mouse-choose-completion): Use mouse-face properties to find string to use.
Richard M. Stallman <rms@gnu.org>
parents: 8200
diff changeset
1425 (setq end (point) beg (1+ (point))))
f5c8a4e8c4a5 (mouse-choose-completion): Use mouse-face properties to find string to use.
Richard M. Stallman <rms@gnu.org>
parents: 8200
diff changeset
1426 (if (null beg)
f5c8a4e8c4a5 (mouse-choose-completion): Use mouse-face properties to find string to use.
Richard M. Stallman <rms@gnu.org>
parents: 8200
diff changeset
1427 (error "No completion here"))
f5c8a4e8c4a5 (mouse-choose-completion): Use mouse-face properties to find string to use.
Richard M. Stallman <rms@gnu.org>
parents: 8200
diff changeset
1428 (setq beg (previous-single-property-change beg 'mouse-face))
8381
9d751556d1c7 (mouse-choose-completion): Check for next-single-property-change
Richard M. Stallman <rms@gnu.org>
parents: 8268
diff changeset
1429 (setq end (or (next-single-property-change end 'mouse-face)
9d751556d1c7 (mouse-choose-completion): Check for next-single-property-change
Richard M. Stallman <rms@gnu.org>
parents: 8268
diff changeset
1430 (point-max)))
7593
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1431 (setq choice (buffer-substring beg end)))))
6231
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1432 (let ((owindow (selected-window)))
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1433 (select-window (posn-window (event-start event)))
7794
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1434 (if (and (one-window-p t 'selected-frame)
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1435 (window-dedicated-p (selected-window)))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1436 ;; This is a special buffer's frame
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1437 (iconify-frame (selected-frame))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1438 (or (window-dedicated-p (selected-window))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1439 (bury-buffer)))
6231
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1440 (select-window owindow))
8477
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1441 (choose-completion-string choice buffer base-size)))
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1442
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1443 ;; Font selection.
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1444
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1445 (defun font-menu-add-default ()
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1446 (let* ((default (cdr (assq 'font (frame-parameters (selected-frame)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1447 (font-alist x-fixed-font-alist)
4563
b9118969ce28 (font-menu-add-default): Use list, not cons, for new elt.
Richard M. Stallman <rms@gnu.org>
parents: 4562
diff changeset
1448 (elt (or (assoc "Misc" font-alist) (nth 1 font-alist))))
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1449 (if (assoc "Default" elt)
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1450 (delete (assoc "Default" elt) elt))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1451 (setcdr elt
4562
477fbf60722b (font-menu-add-default): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 4554
diff changeset
1452 (cons (list "Default"
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1453 (cdr (assq 'font (frame-parameters (selected-frame)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1454 (cdr elt)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1455
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1456 (defvar x-fixed-font-alist
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1457 '("Font menu"
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1458 ("Misc"
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1459 ;; For these, we specify the pixel height and width.
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1460 ("fixed" "fixed")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1461 ("6x10" "-misc-fixed-medium-r-normal--10-*-*-*-c-60-iso8859-1" "6x10")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1462 ("6x12"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1463 "-misc-fixed-medium-r-semicondensed--12-*-*-*-c-60-iso8859-1" "6x12")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1464 ("6x13"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1465 "-misc-fixed-medium-r-semicondensed--13-*-*-*-c-60-iso8859-1" "6x13")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1466 ("7x13" "-misc-fixed-medium-r-normal--13-*-*-*-c-70-iso8859-1" "7x13")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1467 ("7x14" "-misc-fixed-medium-r-normal--14-*-*-*-c-70-iso8859-1" "7x14")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1468 ("8x13" "-misc-fixed-medium-r-normal--13-*-*-*-c-80-iso8859-1" "8x13")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1469 ("9x15" "-misc-fixed-medium-r-normal--15-*-*-*-c-90-iso8859-1" "9x15")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1470 ("10x20" "-misc-fixed-medium-r-normal--20-*-*-*-c-100-iso8859-1" "10x20")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1471 ("11x18" "-misc-fixed-medium-r-normal--18-*-*-*-c-110-iso8859-1" "11x18")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1472 ("12x24" "-misc-fixed-medium-r-normal--24-*-*-*-c-120-iso8859-1" "12x24")
4274
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1473 ("")
8487
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1474 ("clean 5x8"
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1475 "-schumacher-clean-medium-r-normal--8-*-*-*-c-50-iso8859-1")
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1476 ("clean 6x8"
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1477 "-schumacher-clean-medium-r-normal--8-*-*-*-c-60-iso8859-1")
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1478 ("clean 8x8"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1479 "-schumacher-clean-medium-r-normal--8-*-*-*-c-80-iso8859-1")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1480 ("clean 8x10"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1481 "-schumacher-clean-medium-r-normal--10-*-*-*-c-80-iso8859-1")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1482 ("clean 8x14"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1483 "-schumacher-clean-medium-r-normal--14-*-*-*-c-80-iso8859-1")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1484 ("clean 8x16"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1485 "-schumacher-clean-medium-r-normal--16-*-*-*-c-80-iso8859-1")
4274
6e46ab2ea271 (x-fixed-font-alist): Give some fonts long patterns.
Richard M. Stallman <rms@gnu.org>
parents: 4221
diff changeset
1486 ("")
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1487 ("sony 8x16" "-sony-fixed-medium-r-normal--16-*-*-*-c-80-iso8859-1"))
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1488 ;;; We don't seem to have these; who knows what they are.
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1489 ;;; ("fg-18" "fg-18")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1490 ;;; ("fg-25" "fg-25")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1491 ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1492 ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1493 ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1494 ;;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1495 ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1496 ("Courier"
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1497 ;; For these, we specify the point height.
3231
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1498 ("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1499 ("10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1500 ("12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1501 ("14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1502 ("18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1503 ("24" "-adobe-courier-medium-r-normal--*-240-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1504 ("8 bold" "-adobe-courier-bold-r-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1505 ("10 bold" "-adobe-courier-bold-r-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1506 ("12 bold" "-adobe-courier-bold-r-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1507 ("14 bold" "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1508 ("18 bold" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1509 ("24 bold" "-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1510 ("8 slant" "-adobe-courier-medium-o-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1511 ("10 slant" "-adobe-courier-medium-o-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1512 ("12 slant" "-adobe-courier-medium-o-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1513 ("14 slant" "-adobe-courier-medium-o-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1514 ("18 slant" "-adobe-courier-medium-o-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1515 ("24 slant" "-adobe-courier-medium-o-normal--*-240-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1516 ("8 bold slant" "-adobe-courier-bold-o-normal--*-80-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1517 ("10 bold slant" "-adobe-courier-bold-o-normal--*-100-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1518 ("12 bold slant" "-adobe-courier-bold-o-normal--*-120-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1519 ("14 bold slant" "-adobe-courier-bold-o-normal--*-140-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1520 ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1")
fb322590dda0 (x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents: 3119
diff changeset
1521 ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1"))
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1522 )
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1523 "X fonts suitable for use in Emacs.")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1524
6867
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1525 (defun mouse-set-font (&rest fonts)
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1526 "Select an emacs font from a list of known good fonts"
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1527 (interactive
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1528 (x-popup-menu last-nonmenu-event x-fixed-font-alist))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1529 (if fonts
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1530 (let (font)
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1531 (while fonts
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1532 (condition-case nil
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1533 (progn
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1534 (set-default-font (car fonts))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1535 (setq font (car fonts))
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1536 (setq fonts nil))
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1537 (error
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1538 (setq fonts (cdr fonts)))))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1539 (if (null font)
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1540 (error "Font not found")))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1541
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1542 ;;; Bindings for mouse commands.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1543
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
1544 (define-key global-map [down-mouse-1] 'mouse-drag-region)
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1545 (global-set-key [mouse-1] 'mouse-set-point)
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
1546 (global-set-key [drag-mouse-1] 'mouse-set-region)
1057
d9775f33488d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1056
diff changeset
1547
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1548 ;; These are tested for in mouse-drag-region.
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1549 (global-set-key [double-mouse-1] 'mouse-set-point)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1550 (global-set-key [triple-mouse-1] 'mouse-set-point)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1551
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1552 (global-set-key [mouse-2] 'mouse-yank-at-click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1553 (global-set-key [mouse-3] 'mouse-save-then-kill)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
1554
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1555 ;; By binding these to down-going events, we let the user use the up-going
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1556 ;; event to make the selection, saving a click.
9753
00144934b449 Put mouse-set-font on C-down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1557 (global-set-key [C-down-mouse-1] 'mouse-set-font)
00144934b449 Put mouse-set-font on C-down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1558 ;; C-down-mouse-2 is bound in facemenu.el.
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
1559 (global-set-key [C-down-mouse-3] 'mouse-major-mode-menu)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
1560
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1561
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1562 ;; Replaced with dragging mouse-1
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1563 ;; (global-set-key [S-mouse-1] 'mouse-set-mark)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
1564
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1565 (global-set-key [mode-line mouse-1] 'mouse-select-window)
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
1566 (global-set-key [mode-line drag-mouse-1] 'mouse-select-window)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
1567 (global-set-key [mode-line down-mouse-1] 'mouse-drag-mode-line)
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1568 (global-set-key [mode-line mouse-2] 'mouse-delete-other-windows)
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1569 (global-set-key [mode-line mouse-3] 'mouse-delete-window)
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1570 (global-set-key [mode-line C-mouse-2] 'mouse-split-window-horizontally)
8174
0c7bcd40a21e ([vertical-scroll-bar C-mouse-2]): Split the window.
Richard M. Stallman <rms@gnu.org>
parents: 8135
diff changeset
1571 (global-set-key [vertical-scroll-bar C-mouse-2] 'mouse-split-window-vertically)
8268
3ff0307b8c0d ([vertical-line C-mouse-2]): Bind it as in a scroll bar.
Richard M. Stallman <rms@gnu.org>
parents: 8255
diff changeset
1572 (global-set-key [vertical-line C-mouse-2] 'mouse-split-window-vertically)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1573
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1574 (provide 'mouse)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1575
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1576 ;;; mouse.el ends here