annotate lisp/mouse.el @ 17803:906dcb974266

Don't include term.el.
author Richard M. Stallman <rms@gnu.org>
date Wed, 14 May 1997 19:51:33 +0000
parents 6a187f72db92
children 56f88318699c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
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
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
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
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
8 ;; This file is part of GNU Emacs.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
13 ;; any later version.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
18 ;; GNU General Public License for more details.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13307
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14179
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
23 ;; Boston, MA 02111-1307, USA.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
2308
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
25 ;;; Commentary:
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
26
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
27 ;; 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
28 ;; 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
29 ;; 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
30 ;;
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
31 ;; The code is rather X-dependent.
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
32
2232
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2070
diff changeset
33 ;;; Code:
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2070
diff changeset
34
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
35 ;;; Utility functions.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
36
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
37 ;;; Indent track-mouse like progn.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
38 (put 'track-mouse 'lisp-indent-function 0)
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
40 (defcustom mouse-yank-at-point nil
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
41 "*If non-nil, mouse yank commands yank at point instead of at click."
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
42 :type 'boolean
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
43 :group 'mouse)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
44
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
45 ;; 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
46
16621
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
47 (defun mouse-major-mode-menu (event prefix)
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
48 "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
49 ;; 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
50 ;; the mode's commands may not make sense.
16621
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
51 (interactive "@e\nP")
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
52 (let (;; This is where mouse-major-mode-menu-prefix
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
53 ;; returns the prefix we should use (after menu-bar).
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
54 ;; It is either nil or (SOME-SYMBOL).
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
55 (mouse-major-mode-menu-prefix nil)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
56 ;; Make a keymap in which our last command leads to a menu
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
57 (newmap (make-sparse-keymap (concat mode-name " Mode")))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
58 result)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
59 ;; Make our menu inherit from the desired keymap
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
60 ;; which we want to display as the menu now.
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
61 (set-keymap-parent newmap
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
62 (mouse-major-mode-menu-1
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
63 (and (current-local-map)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
64 (lookup-key (current-local-map) [menu-bar]))))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
65 (setq result (x-popup-menu t (list newmap)))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
66 (if result
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
67 (let ((command (key-binding
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
68 (apply 'vector (append '(menu-bar)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
69 mouse-major-mode-menu-prefix
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
70 result)))))
16621
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
71 ;; Clear out echoing, which perhaps shows a prefix arg.
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
72 (message "")
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
73 (if command
16621
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
74 (progn
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
75 (setq prefix-arg prefix)
042bf1d82a14 (mouse-major-mode-menu): Propagate prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 16590
diff changeset
76 (command-execute command)))))))
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
77
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
78 ;; Compute and cache the equivalent keys in MENU and all its submenus.
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
79 ;;;(defun mouse-major-mode-menu-compute-equiv-keys (menu)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
80 ;;; (and (eq (car menu) 'keymap)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
81 ;;; (x-popup-menu nil menu))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
82 ;;; (while menu
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
83 ;;; (and (consp (car menu))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
84 ;;; (consp (cdr (car menu)))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
85 ;;; (let ((tail (cdr (car menu))))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
86 ;;; (while (and (consp tail)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
87 ;;; (not (eq (car tail) 'keymap)))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
88 ;;; (setq tail (cdr tail)))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
89 ;;; (if (consp tail)
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
90 ;;; (mouse-major-mode-menu-compute-equiv-keys tail))))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
91 ;;; (setq menu (cdr menu))))
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
92
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
93 ;; 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
94 ;; 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
95 ;; return just that menu.
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
96 ;; 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
97 (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
98 (if menubar
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
99 (let ((tail menubar)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
100 submap)
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
101 (while tail
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
102 (if (consp (car tail))
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
103 (if submap
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
104 (setq submap t)
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
105 (setq submap (car tail))))
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
106 (setq tail (cdr tail)))
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
107 (if (eq submap t)
15657
6ad5994053af (mouse-major-mode-menu-1): No need to copy the top
Karl Heuer <kwzh@gnu.org>
parents: 15642
diff changeset
108 menubar
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
109 (setq mouse-major-mode-menu-prefix (list (car submap)))
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
110 (cdr (cdr submap))))))
9488
114fe3739aa3 (mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents: 9206
diff changeset
111
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
112 ;; 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
113
6266
66c0ed95c03f (mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents: 6231
diff changeset
114 (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
115 (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
116 (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
117 (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
118 (error "Minibuffer window is not active")))
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
119 ;; 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
120 (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
121
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
122 (defun mouse-delete-window (click)
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
123 "Delete the window you click on.
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
124 This must be bound to a mouse click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
125 (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
126 (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
127 (delete-window (posn-window (event-start click))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
128
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
129 (defun mouse-select-window (click)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
130 "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
131 (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
132 (mouse-minibuffer-check click)
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
133 (let ((oframe (selected-frame))
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
134 (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
135 (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
136 (raise-frame frame)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
137 (select-frame frame)
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
138 (or (eq frame oframe)
16087
26b552f014ff (mouse-select-window): Don't call unfocus-frame.
Richard M. Stallman <rms@gnu.org>
parents: 16016
diff changeset
139 (set-mouse-position (selected-frame) (1- (frame-width)) 0))))
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
140
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
141 (defun mouse-tear-off-window (click)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
142 "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
143 (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
144 (mouse-minibuffer-check click)
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
145 (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
146 (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
147 (frame (make-frame)))
1421
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
148 (select-frame frame)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
149 (switch-to-buffer buf)
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
150 (delete-window window)))
a8378792a31d * mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents: 1420
diff changeset
151
1363
f34d8e4d1d7b * mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents: 1214
diff changeset
152 (defun mouse-delete-other-windows ()
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
153 "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
154 (interactive "@")
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (delete-other-windows))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
157 (defun mouse-split-window-vertically (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
158 "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
159 The window is split at the line clicked on.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
160 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
161 (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
162 (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
163 (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
164 (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
165 (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
166 (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
167 (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
168 (if (< last-line first-line)
8426
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
169 (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
170 (split-window-vertically
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
171 (min (max new-height first-line) last-line))))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
173 (defun mouse-split-window-horizontally (click)
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
174 "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
175 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
176 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
177 (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
178 (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
179 (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
180 (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
181 (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
182 (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
183 (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
184 (if (< last-col first-col)
8426
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
185 (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
186 (split-window-horizontally
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
187 (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
188
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
189 (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
190 "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
191 (interactive "e")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
192 ;; 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
193 (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
194 (let ((done nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
195 (echo-keystrokes 0)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
196 (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
197 (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
198 (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
199 (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
200 should-enlarge-minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
201 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
202 (setq params (frame-parameters))
16636
ba78d234fe6c (mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents: 16621
diff changeset
203 (setq minibuffer (cdr (assq 'minibuffer params)))
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
204 (track-mouse
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
205 (progn
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
206 ;; 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
207 ;; 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
208 ;; 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
209 (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
210 ;; 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
211 ;; 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
212 (setq should-enlarge-minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
213 (and minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
214 (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
215 (= (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
216 (nth 3 (window-edges)))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
217 ;; 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
218 ;; the mouse.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
219 (while (not done)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
220 (setq event (read-event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
221 mouse (mouse-position))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
222 ;; do nothing if
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
223 ;; - 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
224 ;; - 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
225 ;; - 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
226 ;; drag if
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
227 ;; - 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
228 ;; - 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
229 ;; (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
230 ;; quit if
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
231 ;; - 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
232 ;; unknown event.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
233 (cond ((integerp event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
234 (setq done t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
235 ((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
236 nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
237 ((not (memq (car event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
238 '(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
239 (if (consp event)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
240 (setq unread-command-events
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
241 (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
242 (setq done t))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
243 ((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
244 nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
245 ((null (car (cdr mouse)))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
246 nil)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
247 (t
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
248 (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
249 edges (window-edges)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
250 top (nth 1 edges)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
251 bot (nth 3 edges))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
252 ;; 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
253 ;; window too short.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
254 (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
255 (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
256 ;; compute size change needed
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
257 (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
258 wconfig (current-window-configuration))
16636
ba78d234fe6c (mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents: 16621
diff changeset
259 ;; Check for an error case.
ba78d234fe6c (mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents: 16621
diff changeset
260 (if (and (/= growth 0)
ba78d234fe6c (mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents: 16621
diff changeset
261 (not minibuffer)
ba78d234fe6c (mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents: 16621
diff changeset
262 (one-window-p t))
ba78d234fe6c (mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents: 16621
diff changeset
263 (error "Attempt to resize sole window"))
8519
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
264 ;; grow/shrink minibuffer?
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
265 (if should-enlarge-minibuffer
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
266 (progn
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
267 ;; 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
268 ;; 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
269 ;; correct window.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
270 (select-window minibuffer)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
271 ;; 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
272 ;; 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
273 ;; line tall.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
274 (if (and (> growth 0)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
275 (< (- (window-height minibuffer)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
276 growth)
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
277 1))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
278 (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
279 (enlarge-window (- growth))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
280 (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
281 ;; 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
282 (enlarge-window growth))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
283 ;; 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
284 ;; 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
285 ;; short, rescind the change.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
286 ;;
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
287 ;; 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
288 ;; 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
289 ;; 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
290 ;; 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
291 ;; 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
292 ;; around it.
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
293 (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
294 (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
295 (/= 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
296 (set-window-configuration wconfig)))))))))
7802e26b3bfd (mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents: 8487
diff changeset
297
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
298 (defun mouse-drag-vertical-line (start-event)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
299 "Change the width of a window by dragging on the vertical line."
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
300 (interactive "e")
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
301 ;; Give temporary modes such as isearch a chance to turn off.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
302 (run-hooks 'mouse-leave-buffer-hook)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
303 (let ((done nil)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
304 (echo-keystrokes 0)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
305 (start-event-frame (window-frame (car (car (cdr start-event)))))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
306 (start-event-window (car (car (cdr start-event))))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
307 (start-nwindows (count-windows t))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
308 (old-selected-window (selected-window))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
309 event mouse x left right edges wconfig growth)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
310 (if (one-window-p t)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
311 (error "Attempt to resize sole ordinary window"))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
312 (if (= (nth 2 (window-edges start-event-window))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
313 (frame-width start-event-frame))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
314 (error "Attempt to drag rightmost scrollbar"))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
315 (track-mouse
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
316 (progn
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
317 ;; enlarge-window only works on the selected window, so
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
318 ;; we must select the window where the start event originated.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
319 ;; unwind-protect will restore the old selected window later.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
320 (select-window start-event-window)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
321 ;; loop reading events and sampling the position of
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
322 ;; the mouse.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
323 (while (not done)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
324 (setq event (read-event)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
325 mouse (mouse-position))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
326 ;; do nothing if
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
327 ;; - there is a switch-frame event.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
328 ;; - the mouse isn't in the frame that we started in
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
329 ;; - the mouse isn't in any Emacs frame
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
330 ;; drag if
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
331 ;; - there is a mouse-movement event
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
332 ;; - there is a scroll-bar-movement event
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
333 ;; (same as mouse movement for our purposes)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
334 ;; quit if
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
335 ;; - there is a keyboard event or some other unknown event
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
336 ;; unknown event.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
337 (cond ((integerp event)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
338 (setq done t))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
339 ((eq (car event) 'switch-frame)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
340 nil)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
341 ((not (memq (car event)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
342 '(mouse-movement scroll-bar-movement)))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
343 (if (consp event)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
344 (setq unread-command-events
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
345 (cons event unread-command-events)))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
346 (setq done t))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
347 ((not (eq (car mouse) start-event-frame))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
348 nil)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
349 ((null (car (cdr mouse)))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
350 nil)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
351 (t
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
352 (setq x (car (cdr mouse))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
353 edges (window-edges)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
354 left (nth 0 edges)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
355 right (nth 2 edges))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
356 ;; scale back a move that would make the
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
357 ;; window too thin.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
358 (cond ((< (- x left -1) window-min-width)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
359 (setq x (+ left window-min-width -1))))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
360 ;; compute size change needed
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
361 (setq growth (- x right -1)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
362 wconfig (current-window-configuration))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
363 (enlarge-window growth t)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
364 ;; if this window's growth caused another
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
365 ;; window to be deleted because it was too
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
366 ;; thin, rescind the change.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
367 ;;
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
368 ;; if size change caused space to be stolen
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
369 ;; from a window to the left of this one,
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
370 ;; rescind the change.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
371 (if (or (/= start-nwindows (count-windows t))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
372 (/= left (nth 0 (window-edges))))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
373 (set-window-configuration wconfig)))))))))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
374
4554
cf541ed1fed8 (mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents: 4532
diff changeset
375 (defun mouse-set-point (event)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
376 "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
377 This should be bound to a mouse click event type."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
378 (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
379 (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
380 ;; 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
381 ;; 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
382 (let ((posn (event-end event)))
8426
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
383 (if (not (windowp (posn-window posn)))
3abe02e03dc8 Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents: 8381
diff changeset
384 (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
385 (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
386 (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
387 (goto-char (posn-point posn)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
389 (defvar mouse-last-region-beg nil)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
390 (defvar mouse-last-region-end nil)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
391 (defvar mouse-last-region-tick nil)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
392
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
393 (defun mouse-region-match ()
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
394 "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
395 (and (mark t) mark-active
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
396 (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
397 (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
398 (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
399
1420
4005f73e5712 (mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents: 1363
diff changeset
400 (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
401 "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
402 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
403 (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
404 (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
405 (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
406 (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
407 (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
408 (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
409 (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
410 ;; 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
411 ;; 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
412 (or transient-mark-mode
16590
a0cfcb9f8033 Use w32 instead of ms-windows for window-system symbol
Geoff Voelker <voelker@cs.washington.edu>
parents: 16318
diff changeset
413 (memq (framep (selected-frame)) '(x pc w32))
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
414 (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
415 (push-mark)
2802
02c75b605550 (mouse-set-region): Call set-mark to activate mark.
Richard M. Stallman <rms@gnu.org>
parents: 2799
diff changeset
416 (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
417 (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
418 (goto-char (posn-point end)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
419 ;; 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
420 ;; 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
421 ;; 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
422 (let (this-command last-command)
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
423 (copy-region-as-kill (mark) (point)))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
424 (mouse-set-region-1)))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
425
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
426 (defun mouse-set-region-1 ()
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
427 (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
428 (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
429 (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
430
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
431 (defcustom mouse-scroll-delay 0.25
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
432 "*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
433 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
434 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
435 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
436 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
437 This variable's value may be non-integral.
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
438 Setting this to zero causes Emacs to scroll as fast as it can."
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
439 :type 'number
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
440 :group 'mouse)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
441
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
442 (defcustom mouse-scroll-min-lines 1
13068
9cc4392719e3 [These changes were actually in the previous version.
Richard M. Stallman <rms@gnu.org>
parents: 13038
diff changeset
443 "*The minimum number of lines scrolled by dragging mouse out of window.
9cc4392719e3 [These changes were actually in the previous version.
Richard M. Stallman <rms@gnu.org>
parents: 13038
diff changeset
444 Moving the mouse out the top or bottom edge of the window begins
9cc4392719e3 [These changes were actually in the previous version.
Richard M. Stallman <rms@gnu.org>
parents: 13038
diff changeset
445 scrolling repeatedly. The number of lines scrolled per repetition
9cc4392719e3 [These changes were actually in the previous version.
Richard M. Stallman <rms@gnu.org>
parents: 13038
diff changeset
446 is normally equal to the number of lines beyond the window edge that
9cc4392719e3 [These changes were actually in the previous version.
Richard M. Stallman <rms@gnu.org>
parents: 13038
diff changeset
447 the mouse has moved. However, it always scrolls at least the number
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
448 of lines specified by this variable."
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
449 :type 'integer
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
450 :group 'mouse)
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
451
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
452 (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
453 "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
454 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
455 the newly visible text.
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
456 Upon exit, point is at the far edge of the newly visible text."
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
457 (cond
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
458 ((and (> jump 0) (< jump mouse-scroll-min-lines))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
459 (setq jump mouse-scroll-min-lines))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
460 ((and (< jump 0) (< (- jump) mouse-scroll-min-lines))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
461 (setq jump (- mouse-scroll-min-lines))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
462 (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
463 (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
464 (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
465 (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
466 (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
467 (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
468 (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
469 (progn
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
470 (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
471 ;; 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
472 ;; 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
473 (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
474 (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
475 (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
476 (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
477 ;; 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
478 ;; 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
479 ;; 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
480 (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
481 (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
482 (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
483 (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
484 (goto-char opoint))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
485
11453
5ed0795c4155 Create mouse-drag-overlay as a dead overlay, instead
Karl Heuer <kwzh@gnu.org>
parents: 11235
diff changeset
486 ;; 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
487 (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
488 (delete-overlay mouse-drag-overlay)
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
489 (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
490
5027
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
491 (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
492
12436
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
493 (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
494
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
495 (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
496 "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
497 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
498 This must be bound to a button-down mouse event.
15116
a152ab5c09b0 (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15082
diff changeset
499 In Transient Mark mode, the highlighting remains as long as the mark
a152ab5c09b0 (mouse-drag-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15082
diff changeset
500 remains active. Otherwise, it remains until the next input event."
3566
dc2b64ef30dc (mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents: 3420
diff changeset
501 (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
502 (mouse-minibuffer-check start-event)
14179
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
503 (let* ((echo-keystrokes 0)
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
504 (start-posn (event-start start-event))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
505 (start-point (posn-point start-posn))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
506 (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
507 (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
508 (bounds (window-edges start-window))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
509 (top (nth 1 bounds))
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
510 (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
511 (nth 3 bounds)
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
512 ;; 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
513 (1- (nth 3 bounds))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
514 (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
515 (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
516 (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
517 (mouse-set-point start-event)
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
518 ;; In case the down click is in the middle of some intangible text,
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
519 ;; use the end of that text, and put it in START-POINT.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
520 (if (< (point) start-point)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
521 (goto-char start-point))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
522 (setq start-point (point))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
523 (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
524 (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
525 (window-buffer start-window)))
4200
3f5f55401364 (mouse-drag-region): Use deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents: 4081
diff changeset
526 (deactivate-mark)
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
527 ;; end-of-range is used only in the single-click case.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
528 ;; It is the place where the drag has reached so far
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
529 ;; (but not outside the window where the drag started).
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
530 (let (event end end-point last-end-point (end-of-range (point)))
3566
dc2b64ef30dc (mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents: 3420
diff changeset
531 (track-mouse
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
532 (while (progn
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
533 (setq event (read-event))
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
534 (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
535 (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
536 (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
537 nil
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
538 (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
539 end-point (posn-point end))
16304
ba59fb4dd237 (mouse-drag-region): Ignore event end-point if it is not a number.
Richard M. Stallman <rms@gnu.org>
parents: 16201
diff changeset
540 (if (numberp end-point)
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
541 (setq last-end-point end-point))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
542
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
543 (cond
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
544 ;; 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
545 ((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
546 (integer-or-marker-p end-point))
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
547 ;; Go to START-POINT first, so that when we move to END-POINT,
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
548 ;; if it's in the middle of intangible text,
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
549 ;; point jumps in the direction away from START-POINT.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
550 (goto-char start-point)
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
551 (goto-char end-point)
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
552 (if (zerop (% click-count 3))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
553 (setq end-of-range (point)))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
554 (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
555 (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
556
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
557 (t
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
558 (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
559 (cond
6923
5df81bebf7f7 (mouse-drag-region): Handle scroll off top/bottom.
Karl Heuer <kwzh@gnu.org>
parents: 6914
diff changeset
560 ((null mouse-row))
3961
e828d5f28ca2 * mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents: 3928
diff changeset
561 ((< mouse-row top)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
562 (mouse-scroll-subr start-window (- mouse-row top)
13307
4bc9015f709e (mouse-drag-region): Set end-of-range after calling mouse-scroll-subr.
Richard M. Stallman <rms@gnu.org>
parents: 13068
diff changeset
563 mouse-drag-overlay start-point)
4bc9015f709e (mouse-drag-region): Set end-of-range after calling mouse-scroll-subr.
Richard M. Stallman <rms@gnu.org>
parents: 13068
diff changeset
564 ;; Without this, point tends to jump back to the starting
4bc9015f709e (mouse-drag-region): Set end-of-range after calling mouse-scroll-subr.
Richard M. Stallman <rms@gnu.org>
parents: 13068
diff changeset
565 ;; position where the mouse button was pressed down.
4bc9015f709e (mouse-drag-region): Set end-of-range after calling mouse-scroll-subr.
Richard M. Stallman <rms@gnu.org>
parents: 13068
diff changeset
566 (setq end-of-range (overlay-start mouse-drag-overlay)))
8064
d04a39ce4f1d (mouse-scroll-subr): Don't do anything special at eob.
Richard M. Stallman <rms@gnu.org>
parents: 7966
diff changeset
567 ((>= mouse-row bottom)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
568 (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
13307
4bc9015f709e (mouse-drag-region): Set end-of-range after calling mouse-scroll-subr.
Richard M. Stallman <rms@gnu.org>
parents: 13068
diff changeset
569 mouse-drag-overlay start-point)
4bc9015f709e (mouse-drag-region): Set end-of-range after calling mouse-scroll-subr.
Richard M. Stallman <rms@gnu.org>
parents: 13068
diff changeset
570 (setq end-of-range (overlay-end mouse-drag-overlay))))))))))
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
571 (if (consp event)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
572 (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
573 ;; 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
574 ;; 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
575 ;; because it would fail to set up a region.
15082
bd6c6923b90e (mouse-drag-region): Leave region highlighted until the next input event.
Richard M. Stallman <rms@gnu.org>
parents: 14881
diff changeset
576 (if nil ;; (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
12844
a6bcb0568121 (mouse-drag-region): Unread the up-event rather than execute it here.
Richard M. Stallman <rms@gnu.org>
parents: 12553
diff changeset
577 ;; In this case, we can just let the up-event execute normally.
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
578 (let ((end (event-end event)))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
579 ;; Set the position in the event before we replay it,
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
580 ;; because otherwise it may have a position in the wrong
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
581 ;; buffer.
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
582 (setcar (cdr end) end-of-range)
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
583 ;; 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
584 ;; 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
585 (delete-overlay mouse-drag-overlay)
12844
a6bcb0568121 (mouse-drag-region): Unread the up-event rather than execute it here.
Richard M. Stallman <rms@gnu.org>
parents: 12553
diff changeset
586 (setq unread-command-events
a6bcb0568121 (mouse-drag-region): Unread the up-event rather than execute it here.
Richard M. Stallman <rms@gnu.org>
parents: 12553
diff changeset
587 (cons event unread-command-events)))
10369
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
588 (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
589 (overlay-end mouse-drag-overlay)))
16304
ba59fb4dd237 (mouse-drag-region): Ignore event end-point if it is not a number.
Richard M. Stallman <rms@gnu.org>
parents: 16201
diff changeset
590 (let* ((stop-point
ba59fb4dd237 (mouse-drag-region): Ignore event end-point if it is not a number.
Richard M. Stallman <rms@gnu.org>
parents: 16201
diff changeset
591 (if (numberp (posn-point (event-end event)))
ba59fb4dd237 (mouse-drag-region): Ignore event end-point if it is not a number.
Richard M. Stallman <rms@gnu.org>
parents: 16201
diff changeset
592 (posn-point (event-end event))
ba59fb4dd237 (mouse-drag-region): Ignore event end-point if it is not a number.
Richard M. Stallman <rms@gnu.org>
parents: 16201
diff changeset
593 last-end-point))
15476
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
594 ;; The end that comes from where we ended the drag.
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
595 ;; Point goes here.
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
596 (region-termination
15642
6a3622bb0f31 (mouse-drag-region): Cope if stop-point is nil.
Karl Heuer <kwzh@gnu.org>
parents: 15633
diff changeset
597 (if (and stop-point (< stop-point start-point))
15476
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
598 (overlay-start mouse-drag-overlay)
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
599 (overlay-end mouse-drag-overlay)))
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
600 ;; The end that comes from where we started the drag.
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
601 ;; Mark goes there.
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
602 (region-commencement
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
603 (- (+ (overlay-end mouse-drag-overlay)
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
604 (overlay-start mouse-drag-overlay))
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
605 region-termination))
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
606 last-command this-command)
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
607 (push-mark region-commencement t t)
0236199fc5f1 (mouse-drag-region): Be smart about which end
Richard M. Stallman <rms@gnu.org>
parents: 15475
diff changeset
608 (goto-char region-termination)
15169
a00021443533 (mouse-drag-region): Set the region before reading a
Richard M. Stallman <rms@gnu.org>
parents: 15116
diff changeset
609 (copy-region-as-kill (point) (mark t))
15880
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
610 (let ((buffer (current-buffer)))
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
611 (mouse-show-mark)
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
612 ;; mouse-show-mark can call read-event,
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
613 ;; and that means the Emacs server could switch buffers
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
614 ;; under us. If that happened,
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
615 ;; avoid trying to use the region.
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
616 (and (mark t) mark-active
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
617 (eq buffer (current-buffer))
2fe76a330b1e (mouse-drag-region): Don't call mouse-set-region-1
Richard M. Stallman <rms@gnu.org>
parents: 15657
diff changeset
618 (mouse-set-region-1))))
10369
1b6d44607114 (mouse-drag-region): As once in the past,
Richard M. Stallman <rms@gnu.org>
parents: 10258
diff changeset
619 (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
620 (setq this-command 'mouse-set-point)
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
621 (delete-overlay mouse-drag-overlay))))
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
622 (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
623
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
624 ;; 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
625
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
626 (defun mouse-skip-word (dir)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
627 "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
628 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
629 (let* ((char (following-char))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
630 (syntax (char-to-string (char-syntax char))))
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
631 (cond ((or (string= syntax "w") (string= syntax " "))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
632 (if (< dir 0)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
633 (skip-syntax-backward syntax)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
634 (skip-syntax-forward syntax)))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
635 ((string= syntax "_")
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
636 (if (< dir 0)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
637 (skip-syntax-backward "w_")
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
638 (skip-syntax-forward "w_")))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
639 ((< dir 0)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
640 (while (and (not (bobp)) (= (preceding-char) char))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
641 (forward-char -1)))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
642 (t
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
643 (while (and (not (eobp)) (= (following-char) char))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
644 (forward-char 1))))))
3928
c5f9d7f928a7 * mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents: 3899
diff changeset
645
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
646 ;; 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
647 ;; 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
648 ;; 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
649 ;; 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
650 ;; 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
651 (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
652 (if (> start end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
653 (let ((temp start))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
654 (setq start end
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
655 end temp)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
656 (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
657 (cond ((= mode 0)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
658 (list start end))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
659 ((and (= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
660 (= 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
661 (char-after start)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
662 (= (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
663 (list start
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
664 (save-excursion
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
665 (goto-char start)
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
666 (forward-sexp 1)
66aadd6ba5e6 (mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents: 5869
diff changeset
667 (point))))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
668 ((and (= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
669 (= 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
670 (char-after start)
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
671 (= (char-syntax (char-after start)) ?\)))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
672 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
673 (goto-char (1+ start))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
674 (backward-sexp 1)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
675 (point))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
676 (1+ start)))
15561
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
677 ((and (= mode 1)
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
678 (= start end)
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
679 (char-after start)
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
680 (= (char-syntax (char-after start)) ?\"))
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
681 (let ((open (or (eq start (point-min))
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
682 (save-excursion
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
683 (goto-char (- start 1))
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
684 (looking-at "\\s(\\|\\s \\|\\s>")))))
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
685 (if open
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
686 (list start
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
687 (save-excursion
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
688 (condition-case nil
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
689 (progn
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
690 (goto-char start)
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
691 (forward-sexp 1)
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
692 (point))
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
693 (error end))))
16746
9d2a854bac89 (mouse-start-end): Put values in proper order,
Richard M. Stallman <rms@gnu.org>
parents: 16636
diff changeset
694 (list (save-excursion
15561
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
695 (condition-case nil
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
696 (progn
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
697 (goto-char (1+ start))
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
698 (backward-sexp 1)
6f50026fd1e6 (mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents: 15476
diff changeset
699 (point))
16746
9d2a854bac89 (mouse-start-end): Put values in proper order,
Richard M. Stallman <rms@gnu.org>
parents: 16636
diff changeset
700 (error end)))
9d2a854bac89 (mouse-start-end): Put values in proper order,
Richard M. Stallman <rms@gnu.org>
parents: 16636
diff changeset
701 (1+ start)))))
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
702 ((= mode 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
703 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
704 (goto-char start)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
705 (mouse-skip-word -1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
706 (point))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
707 (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
708 (goto-char end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
709 (mouse-skip-word 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
710 (point))))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
711 ((= mode 2)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
712 (list (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
713 (goto-char start)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
714 (beginning-of-line 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
715 (point))
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
716 (save-excursion
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
717 (goto-char end)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
718 (forward-line 1)
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
719 (point))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
720
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
721 ;; Subroutine: set the mark where CLICK happened,
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
722 ;; but don't do anything else.
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
723 (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
724 (mouse-minibuffer-check click)
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
725 (let ((posn (event-start click)))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
726 (select-window (posn-window posn))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
727 (if (numberp (posn-point posn))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
728 (push-mark (posn-point posn) t t))))
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
729
15613
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
730 (defun mouse-undouble-last-event (events)
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
731 (let* ((index (1- (length events)))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
732 (last (nthcdr index events))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
733 (event (car last))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
734 (basic (event-basic-type event))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
735 (modifiers (delq 'double (delq 'triple (copy-sequence (event-modifiers event)))))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
736 (new
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
737 (if (consp event)
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
738 (cons (event-convert-list (nreverse (cons basic modifiers)))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
739 (cdr event))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
740 event)))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
741 (setcar last new)
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
742 (if (key-binding (apply 'vector events))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
743 t
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
744 (setcar last event)
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
745 nil)))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
746
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
747 ;; Momentarily show where the mark is, if highlighting doesn't show it.
15941
f063cae001ee (mouse-region-delete-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15880
diff changeset
748
f063cae001ee (mouse-region-delete-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15880
diff changeset
749 (defvar mouse-region-delete-keys '([delete])
f063cae001ee (mouse-region-delete-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15880
diff changeset
750 "List of keys which shall cause the mouse region to be deleted.")
f063cae001ee (mouse-region-delete-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15880
diff changeset
751
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
752 (defun mouse-show-mark ()
15613
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
753 (if transient-mark-mode
15321
1aeaf1224f0b (mouse-show-mark): Use temporary highlighting if possible instead of a pause.
Richard M. Stallman <rms@gnu.org>
parents: 15169
diff changeset
754 (if window-system
15613
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
755 (delete-overlay mouse-drag-overlay))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
756 (if window-system
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
757 (let ((inhibit-quit t)
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
758 (echo-keystrokes 0)
16016
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
759 event events key ignore
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
760 x-lost-selection-hooks)
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
761 (add-hook 'x-lost-selection-hooks
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
762 '(lambda (seltype)
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
763 (if (eq seltype 'PRIMARY)
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
764 (progn (setq ignore t)
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
765 (throw 'mouse-show-mark t)))))
15613
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
766 (move-overlay mouse-drag-overlay (point) (mark t))
16016
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
767 (catch 'mouse-show-mark
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
768 (while (progn (setq event (read-event))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
769 (setq events (append events (list event)))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
770 (setq key (apply 'vector events))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
771 (and (memq 'down (event-modifiers event))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
772 (not (key-binding key))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
773 (not (member key mouse-region-delete-keys))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
774 (not (mouse-undouble-last-event events))))))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
775 ;; If we lost the selection, just turn off the highlighting.
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
776 (if ignore
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
777 nil
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
778 ;; For certain special keys, delete the region.
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
779 (if (member key mouse-region-delete-keys)
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
780 (delete-region (overlay-start mouse-drag-overlay)
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
781 (overlay-end mouse-drag-overlay))
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
782 ;; Otherwise, unread the key so it gets executed normally.
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
783 (setq unread-command-events
2ee7579db4a9 (mouse-show-mark): Detect loss of selection
Richard M. Stallman <rms@gnu.org>
parents: 15941
diff changeset
784 (nconc events unread-command-events))))
15613
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
785 (setq quit-flag nil)
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
786 (delete-overlay mouse-drag-overlay))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
787 (save-excursion
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
788 (goto-char (mark t))
4c646bed64d0 (mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents: 15561
diff changeset
789 (sit-for 1)))))
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
790
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
791 (defun mouse-set-mark (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
792 "Set mark at the position clicked on with the mouse.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
793 Display cursor at that position for a second.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
794 This must be bound to a mouse click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
795 (interactive "e")
8534
a446d13c46ea (mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents: 8519
diff changeset
796 (mouse-minibuffer-check click)
a446d13c46ea (mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents: 8519
diff changeset
797 (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
798 ;; 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
799 (let ((point-save (point)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (unwind-protect
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
801 (progn (mouse-set-point click)
3119
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
802 (push-mark nil t t)
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
803 (or transient-mark-mode
0d4886af9262 (mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents: 2802
diff changeset
804 (sit-for 1)))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (goto-char point-save))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
807 (defun mouse-kill (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
808 "Kill the region between point and the mouse click.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
809 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
810 (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
811 (mouse-minibuffer-check click)
6301
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
812 (let* ((posn (event-start click))
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
813 (click-posn (posn-point posn)))
80e3ee8d618d (mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents: 6266
diff changeset
814 (select-window (posn-window posn))
1039
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
815 (if (numberp click-posn)
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
816 (kill-region (min (point) click-posn)
8ab465f7a7ff *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 840
diff changeset
817 (max (point) click-posn)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
819 (defun mouse-yank-at-click (click arg)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
820 "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
821 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
822 Prefix arguments are interpreted as with \\[yank].
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
823 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
824 regardless of where you click."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
825 (interactive "e\nP")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
826 ;; 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
827 (run-hooks 'mouse-leave-buffer-hook)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
828 (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
829 (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
830 (setq mouse-selection-click-count 0)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
831 (yank arg))
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
832
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
833 (defun mouse-kill-ring-save (click)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
834 "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
835 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
836 (interactive "e")
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
837 (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
838 (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
839 (kill-ring-save (point) (mark t)))
3712
9e0f49a8f967 (mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3566
diff changeset
840 (mouse-show-mark))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
842 ;;; 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
843 ;;; 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
844 ;;; people found that confusing.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
845
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
846 ;;; 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
847 ;;; invocation of mouse-save-then-kill.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
848 (defvar mouse-save-then-kill-posn nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
849
5007
8ed435ca9650 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 4906
diff changeset
850 (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
851 ;; We must make our own undo boundaries
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
852 ;; 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
853 (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
854 (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
855 ;; 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
856 ;; just delete.
38980ea73075 (mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents: 5007
diff changeset
857 (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
858 ;; 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
859 ;; 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
860 ;; 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
861 (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
862 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
863 (delete-region beg
44680acb5d14 (mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents: 7794
diff changeset
864 (+ 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
865 (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
866 ;; 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
867 (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
868 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
869 (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
870 ;; 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
871 ;; 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
872 (setq buffer-undo-list t)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
873 (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
874 (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
875 (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
876 (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
877 ;; 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
878 ;; 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
879 (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
880 (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
881 ;; 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
882 (and tail
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
883 (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
884 (undo-boundary))
4751
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
885
1214
467833df795b (mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents: 1113
diff changeset
886 (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
887 "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
888 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
889 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
890 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
891 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
892
c63ce262aa4d (mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents: 4738
diff changeset
893 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
894 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
895 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
896 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
897 (interactive "e")
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
898 (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
899 (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
900 (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
901 ;; 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
902 ;; 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
903 (this-command this-command))
12436
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
904 (if (and (save-excursion
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
905 (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
906 (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
907 ;; 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
908 (eq mouse-selection-click-count-buffer
ffd777dc7d29 (mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12357
diff changeset
909 (current-buffer)))))
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
910 (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
911 (equal click-posn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
912 (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
913 ;; 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
914 (let* ((range
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
915 (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
916 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
917 ;; 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
918 ;; 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
919 (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
920 (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
921 (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
922 (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
923 ;; 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
924 ;; 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
925 ;; (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
926 (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
927 (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
928 ;; 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
929 (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
930 (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
931 (mouse-show-mark))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
932 ;; 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
933 ;; that time kill.
11818
f470809e6a60 (mouse-save-then-kill): When making a new region
Richard M. Stallman <rms@gnu.org>
parents: 11453
diff changeset
934 (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
935 (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
936 (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
937 (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
938 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
939 (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
940 (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
941 ;; 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
942 ;; 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
943 (progn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
944 (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
945 ;; 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
946 (setq mouse-save-then-kill-posn nil))
15321
1aeaf1224f0b (mouse-show-mark): Use temporary highlighting if possible instead of a pause.
Richard M. Stallman <rms@gnu.org>
parents: 15169
diff changeset
947 ;; This is not a repetition.
1aeaf1224f0b (mouse-show-mark): Use temporary highlighting if possible instead of a pause.
Richard M. Stallman <rms@gnu.org>
parents: 15169
diff changeset
948 ;; We are adjusting an old selection or creating a new one.
10556
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
949 (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
950 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
951 (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
952 (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
953 '(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
954 (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
955 (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
956 ;; 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
957 (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
958 (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
959 (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
960 (if (numberp new)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
961 (progn
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
962 ;; 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
963 ;; 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
964 (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
965 (goto-char new)
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
966 (set-mark new))
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
967 (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
968 (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
969 (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
970 ;; 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
971 (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
972 (if before-scroll
fda9e00240b0 (mouse-save-then-kill): When we don't use existing
Richard M. Stallman <rms@gnu.org>
parents: 10554
diff changeset
973 (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
974 (exchange-point-and-mark)
15321
1aeaf1224f0b (mouse-show-mark): Use temporary highlighting if possible instead of a pause.
Richard M. Stallman <rms@gnu.org>
parents: 15169
diff changeset
975 (kill-new (buffer-substring (point) (mark t)))
1aeaf1224f0b (mouse-show-mark): Use temporary highlighting if possible instead of a pause.
Richard M. Stallman <rms@gnu.org>
parents: 15169
diff changeset
976 (if window-system
1aeaf1224f0b (mouse-show-mark): Use temporary highlighting if possible instead of a pause.
Richard M. Stallman <rms@gnu.org>
parents: 15169
diff changeset
977 (mouse-show-mark)))
10720
4526bdcc806e (mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents: 10556
diff changeset
978 (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
979 (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
980 (list (car kill-ring) (point) click-posn)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
981
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
982 (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
983 (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
984 (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
985 (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
986 (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
987
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
988 ;; An overlay which records the current secondary selection
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
989 ;; 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
990 ;; May be nil.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
991 (defvar mouse-secondary-overlay nil)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
992
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
993 (defvar mouse-secondary-click-count 0)
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
994
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
995 ;; 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
996 ;; May be nil.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
997 (defvar mouse-secondary-start nil)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
998
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
999 (defun mouse-start-secondary (click)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1000 "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
1001 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
1002 and complete the secondary selection."
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1003 (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
1004 (mouse-minibuffer-check click)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1005 (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
1006 (save-excursion
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
1007 (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
1008 ;; 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
1009 (if mouse-secondary-overlay
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
1010 (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
1011 (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
1012 (progn
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
1013 (or mouse-secondary-start
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
1014 (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
1015 (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
1016
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1017 (defun mouse-set-secondary (click)
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1018 "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
1019 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
1020 (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
1021 (mouse-minibuffer-check click)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1022 (let ((posn (event-start click))
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1023 beg
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1024 (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
1025 (save-excursion
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
1026 (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
1027 (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
1028 (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
1029 (if mouse-secondary-overlay
7747dabf897f (mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents: 3808
diff changeset
1030 (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
1031 (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
1032 (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
1033
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1034 (defun mouse-drag-secondary (start-event)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1035 "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
1036 Highlight the drag area as you move the mouse.
16318
86f1da650461 (mouse-drag-secondary): Make sure to return nil
Richard M. Stallman <rms@gnu.org>
parents: 16304
diff changeset
1037 This must be bound to a button-down mouse event.
86f1da650461 (mouse-drag-secondary): Make sure to return nil
Richard M. Stallman <rms@gnu.org>
parents: 16304
diff changeset
1038 The function returns a non-nil value if it creates a secondary selection."
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1039 (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
1040 (mouse-minibuffer-check start-event)
14179
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
1041 (let* ((echo-keystrokes 0)
7db5b89b78b6 (mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents: 13872
diff changeset
1042 (start-posn (event-start start-event))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1043 (start-point (posn-point start-posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1044 (start-window (posn-window start-posn))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1045 (start-frame (window-frame start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1046 (bounds (window-edges start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1047 (top (nth 1 bounds))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1048 (bottom (if (window-minibuffer-p start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1049 (nth 3 bounds)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1050 ;; Don't count the mode line.
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1051 (1- (nth 3 bounds))))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1052 (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
1053 (save-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1054 (set-buffer (window-buffer start-window))
9206
06864fef4ec3 (mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8765
diff changeset
1055 (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
1056 (or mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1057 (setq mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1058 (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
1059 (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
1060 (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
1061 ;; 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
1062 ;; of one word or line.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1063 (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
1064 (set-marker mouse-secondary-start nil)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1065 (move-overlay mouse-secondary-overlay 1 1
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1066 (window-buffer start-window))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1067 (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
1068 (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
1069 ;; 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
1070 (or mouse-secondary-start
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1071 (setq mouse-secondary-start (make-marker)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1072 (set-marker mouse-secondary-start start-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1073 (delete-overlay mouse-secondary-overlay))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1074 (let (event end end-point)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1075 (track-mouse
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1076 (while (progn
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1077 (setq event (read-event))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1078 (or (mouse-movement-p event)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1079 (eq (car-safe event) 'switch-frame)))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1080
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1081 (if (eq (car-safe event) 'switch-frame)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1082 nil
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1083 (setq end (event-end event)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1084 end-point (posn-point end))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1085 (cond
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1086 ;; Are we moving within the original window?
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1087 ((and (eq (posn-window end) start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1088 (integer-or-marker-p end-point))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1089 (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
1090 click-count)))
8224
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
1091 (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
1092 (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
1093 (progn
1cc48bdd0c6b (mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents: 8204
diff changeset
1094 (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
1095 (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
1096 (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
1097 (t
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
1098 (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
1099 (cond
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
1100 ((null mouse-row))
4a0b3a63e51e (mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents: 7363
diff changeset
1101 ((< mouse-row top)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
1102 (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
1103 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
1104 ((>= mouse-row bottom)
7932
ac4b606bcfa2 (mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 7901
diff changeset
1105 (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
1106 mouse-secondary-overlay start-point)))))))))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1107
7966
76118755a179 (mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents: 7932
diff changeset
1108 (if (consp event)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1109 (if (marker-position mouse-secondary-start)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1110 (save-window-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1111 (delete-overlay mouse-secondary-overlay)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1112 (x-set-selection 'SECONDARY nil)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1113 (select-window start-window)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1114 (save-excursion
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1115 (goto-char mouse-secondary-start)
16318
86f1da650461 (mouse-drag-secondary): Make sure to return nil
Richard M. Stallman <rms@gnu.org>
parents: 16304
diff changeset
1116 (sit-for 1)
86f1da650461 (mouse-drag-secondary): Make sure to return nil
Richard M. Stallman <rms@gnu.org>
parents: 16304
diff changeset
1117 nil))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1118 (x-set-selection
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1119 'SECONDARY
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1120 (buffer-substring (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1121 (overlay-end mouse-secondary-overlay)))))))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1122
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1123 (defun mouse-yank-secondary (click)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
1124 "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
1125 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
1126 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
1127 regardless of where you click."
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1128 (interactive "e")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
1129 ;; 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
1130 (run-hooks 'mouse-leave-buffer-hook)
5799
13d7ce941848 (mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents: 5280
diff changeset
1131 (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
1132 (insert (x-get-selection 'SECONDARY)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1133
5280
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
1134 (defun mouse-kill-secondary ()
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1135 "Kill the text in the secondary selection.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1136 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
1137 but it can work as either one.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1138
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1139 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
1140 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
1141 is to prevent accidents."
5280
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
1142 (interactive)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
1143 (let* ((keys (this-command-keys))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
1144 (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
1145 (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
1146 (if (listp click)
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
1147 (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
1148 (current-buffer)))
6a260dd9ee05 (mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents: 5198
diff changeset
1149 (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
1150 (let (this-command)
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
1151 (save-excursion
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
1152 (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
1153 (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
1154 (overlay-end mouse-secondary-overlay))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1155 (delete-overlay mouse-secondary-overlay)
10838
6c0dc7a8a07a (mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents: 10790
diff changeset
1156 ;;; (x-set-selection 'SECONDARY nil)
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1157 (setq mouse-secondary-overlay nil))
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1158
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1159 (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
1160 "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
1161 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
1162 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
1163 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
1164 this command deletes the text.
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1165 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
1166 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
1167
7302
1d9c6f42c7ae (mouse-secondary-save-then-kill): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
1168 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
1169 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
1170 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
1171 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
1172 (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
1173 (mouse-minibuffer-check click)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1174 (let ((posn (event-start click))
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1175 (click-posn (posn-point (event-start click)))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1176 ;; 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
1177 ;; prevent setting this-command to kill-region.
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1178 (this-command this-command))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1179 (or (eq (window-buffer (posn-window posn))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1180 (or (and mouse-secondary-overlay
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1181 (overlay-buffer mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1182 (if mouse-secondary-start
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1183 (marker-buffer mouse-secondary-start))))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1184 (error "Wrong buffer"))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1185 (save-excursion
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1186 (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
1187 (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
1188 (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
1189 (equal click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1190 (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
1191 ;; 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
1192 (let* ((range
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1193 (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
1194 mouse-secondary-click-count)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1195 ;; 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
1196 ;; 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
1197 (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
1198 (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
1199 (move-overlay mouse-secondary-overlay (car range)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1200 (overlay-end mouse-secondary-overlay))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1201 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1202 (overlay-start mouse-secondary-overlay)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1203 (nth 1 range)))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1204 ;; 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
1205 ;; Replace it with the extended region.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1206 ;; (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
1207 (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
1208 (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
1209 (overlay-end mouse-secondary-overlay)) t)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1210 ;; 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
1211 (setq mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1212 (list (car kill-ring) (point) click-posn)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1213 ;; 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
1214 ;; that time kill.
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1215 (progn
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1216 (mouse-save-then-kill-delete-region
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1217 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1218 (overlay-end mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1219 (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
1220 (setq mouse-secondary-click-count 0)
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1221 (delete-overlay mouse-secondary-overlay)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1222 (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
1223 mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1224 (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
1225 (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
1226 ;; 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
1227 ;; 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
1228 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1229 (mouse-save-then-kill-delete-region
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1230 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1231 (overlay-end mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1232 (setq mouse-save-then-kill-posn nil)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1233 (delete-overlay mouse-secondary-overlay))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1234 (if (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1235 ;; We have a selection, so adjust it.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1236 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1237 (if (numberp click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1238 (progn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1239 ;; 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
1240 ;; 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
1241 (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
1242 (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
1243 (move-overlay mouse-secondary-overlay click-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1244 (overlay-end mouse-secondary-overlay))
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1245 (move-overlay mouse-secondary-overlay
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1246 (overlay-start mouse-secondary-overlay)
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1247 click-posn))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1248 (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
1249 (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
1250 ;; 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
1251 ;; 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
1252 ;; 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
1253 ;; (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
1254 (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
1255 (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
1256 (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
1257 (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
1258 (overlay-end mouse-secondary-overlay))))
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1259 (if mouse-secondary-start
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1260 ;; 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
1261 ;; so put the other end here.
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1262 (let ((start (+ 0 mouse-secondary-start)))
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1263 (kill-ring-save start click-posn)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1264 (if mouse-secondary-overlay
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1265 (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
1266 (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
1267 (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
1268 (setq mouse-save-then-kill-posn
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1269 (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
1270 (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
1271 (x-set-selection 'SECONDARY
5153
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1272 (buffer-substring
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1273 (overlay-start mouse-secondary-overlay)
27afcc69725a (mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents: 5027
diff changeset
1274 (overlay-end mouse-secondary-overlay)))))))
3808
d852157f581a (mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3712
diff changeset
1275
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
1276 (defcustom mouse-menu-buffer-maxlen 20
13872
e79f2b570509 (mouse-menu-buffer-maxlen): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13870
diff changeset
1277 "*Number of buffers in one pane (submenu) of the buffer menu.
e79f2b570509 (mouse-menu-buffer-maxlen): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13870
diff changeset
1278 If we have lots of buffers, divide them into groups of
17636
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
1279 `mouse-menu-buffer-maxlen' and make a pane (or submenu) for each one."
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
1280 :type 'integer
6a187f72db92 Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17008
diff changeset
1281 :group 'mouse)
13872
e79f2b570509 (mouse-menu-buffer-maxlen): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 13870
diff changeset
1282
16989
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1283 (defvar mouse-buffer-menu-mode-groups
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1284 '(("Info\\|Help\\|Apropos\\|Man" . "Help")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1285 ("\\bVM\\b\\|\\bMH\\b\\|Message\\|Mail\\|Group\\|Score\\|Summary\\|Article"
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1286 . "Mail/News")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1287 ("\\<C\\>" . "C")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1288 ("ObjC" . "C")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1289 ("Text" . "Text")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1290 ("Outline" . "Text")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1291 ("Lisp" . "Lisp"))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1292 "How to group various major modes together in \\[mouse-buffer-menu].
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1293 Each element has the form (REGEXP . GROUPNAME).
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1294 If the major mode's name string matches REGEXP, use GROUPNAME instead.")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1295
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1296 (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
1297 "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
1298 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
1299 and selects that window."
1113
0ffcf74fb8ad entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1100
diff changeset
1300 (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
1301 (mouse-minibuffer-check event)
16989
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1302 (let (buffers alist menu split-by-major-mode sum-of-squares)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1303 (setq buffers (buffer-list))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1304 ;; Make an alist of elements that look like (MENU-ITEM . BUFFER).
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1305 (let ((tail buffers))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1306 (while tail
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1307 ;; Divide all buffers into buckets for various major modes.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1308 ;; Each bucket looks like (MODE NAMESTRING BUFFERS...).
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1309 (with-current-buffer (car tail)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1310 (let* ((adjusted-major-mode major-mode) elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1311 (let ((tail mouse-buffer-menu-mode-groups))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1312 (while tail
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1313 (if (string-match (car (car tail)) mode-name)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1314 (setq adjusted-major-mode (cdr (car tail))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1315 (setq tail (cdr tail))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1316 (setq elt (assoc adjusted-major-mode split-by-major-mode))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1317 (if (null elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1318 (setq elt (list adjusted-major-mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1319 (if (stringp adjusted-major-mode)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1320 adjusted-major-mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1321 mode-name))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1322 split-by-major-mode (cons elt split-by-major-mode)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1323 (or (memq (car tail) (cdr (cdr elt)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1324 (setcdr (cdr elt) (cons (car tail) (cdr (cdr elt)))))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1325 (setq tail (cdr tail))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1326 ;; Compute the sum of squares of sizes of the major-mode buckets.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1327 (let ((tail split-by-major-mode))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1328 (setq sum-of-squares 0)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1329 (while tail
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1330 (setq sum-of-squares
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1331 (+ sum-of-squares
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1332 (* (length (cdr (cdr (car tail))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1333 (length (cdr (cdr (car tail)))))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1334 (setq tail (cdr tail))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1335 (if (< (* sum-of-squares 4) (* (length buffers) (length buffers)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1336 ;; Subdividing by major modes really helps, so let's do it.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1337 (let (subdivided-menus (buffers-left (length buffers)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1338 ;; Sort the list to put the most popular major modes first.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1339 (setq split-by-major-mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1340 (sort split-by-major-mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1341 (function (lambda (elt1 elt2)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1342 (> (length elt1) (length elt2))))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1343 ;; Make a separate submenu for each major mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1344 ;; that has more than one buffer,
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1345 ;; unless all the remaining buffers are less than 1/10 of them.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1346 (while (and split-by-major-mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1347 (and (> (length (car split-by-major-mode)) 3)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1348 (> (* buffers-left 10) (length buffers))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1349 (setq subdivided-menus
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1350 (cons (cons
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1351 (nth 1 (car split-by-major-mode))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1352 (mouse-buffer-menu-alist
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1353 (cdr (cdr (car split-by-major-mode)))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1354 subdivided-menus))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1355 (setq buffers-left
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1356 (- buffers-left (length (cdr (car split-by-major-mode)))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1357 (setq split-by-major-mode (cdr split-by-major-mode)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1358 ;; If any major modes are left over,
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1359 ;; make a single submenu for them.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1360 (if split-by-major-mode
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1361 (setq subdivided-menus
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1362 (cons (cons
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1363 "Others"
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1364 (mouse-buffer-menu-alist
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1365 (apply 'append
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1366 (mapcar 'cdr
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1367 (mapcar 'cdr split-by-major-mode)))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1368 subdivided-menus)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1369 (setq subdivided-menus
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1370 (nreverse subdivided-menus))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1371 (setq menu (cons "Buffer Menu" subdivided-menus)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1372 (progn
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1373 (setq alist (mouse-buffer-menu-alist buffers))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1374 (setq menu (cons "Buffer Menu"
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1375 (mouse-buffer-menu-split "Select Buffer" alist)))))
1728
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1376 (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
1377 (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
1378 (if buf
2a49d509b30d (mouse-buffer-menu): Select the window clicked on.
Richard M. Stallman <rms@gnu.org>
parents: 1421
diff changeset
1379 (progn
3420
08adfe96ca93 (mouse-buffer-menu): Don't select the event's window,
Richard M. Stallman <rms@gnu.org>
parents: 3231
diff changeset
1380 (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
1381 (switch-to-buffer buf))))))
16989
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1382
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1383 (defun mouse-buffer-menu-alist (buffers)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1384 (let (tail
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1385 (maxlen 0)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1386 head)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1387 (setq buffers
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1388 (sort buffers
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1389 (function (lambda (elt1 elt2)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1390 (string< (buffer-name elt1) (buffer-name elt2))))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1391 (setq tail buffers)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1392 (while tail
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1393 (or (eq ?\ (aref (buffer-name (car tail)) 0))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1394 (setq maxlen
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1395 (max maxlen
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1396 (length (buffer-name (car tail))))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1397 (setq tail (cdr tail)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1398 (setq tail buffers)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1399 (while tail
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1400 (let ((elt (car tail)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1401 (if (/= (aref (buffer-name elt) 0) ?\ )
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1402 (setq head
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1403 (cons
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1404 (cons
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1405 (format
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1406 (format "%%%ds %%s%%s %%s" maxlen)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1407 (buffer-name elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1408 (if (buffer-modified-p elt) "*" " ")
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1409 (save-excursion
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1410 (set-buffer elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1411 (if buffer-read-only "%" " "))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1412 (or (buffer-file-name elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1413 (save-excursion
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1414 (set-buffer elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1415 (if list-buffers-directory
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1416 (expand-file-name
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1417 list-buffers-directory)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1418 ""))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1419 elt)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1420 head))))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1421 (setq tail (cdr tail)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1422 ;; Compensate for the reversal that the above loop does.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1423 (nreverse head)))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1424
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1425 (defun mouse-buffer-menu-split (title alist)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1426 ;; If we have lots of buffers, divide them into groups of 20
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1427 ;; and make a pane (or submenu) for each one.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1428 (if (> (length alist) (/ (* mouse-menu-buffer-maxlen 3) 2))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1429 (let ((alist alist) sublists next
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1430 (i 1))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1431 (while alist
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1432 ;; Pull off the next mouse-menu-buffer-maxlen buffers
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1433 ;; and make them the next element of sublist.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1434 (setq next (nthcdr mouse-menu-buffer-maxlen alist))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1435 (if next
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1436 (setcdr (nthcdr (1- mouse-menu-buffer-maxlen) alist)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1437 nil))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1438 (setq sublists (cons (cons (format "Buffers %d" i) alist)
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1439 sublists))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1440 (setq i (1+ i))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1441 (setq alist next))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1442 (nreverse sublists))
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1443 ;; Few buffers--put them all in one pane.
4e31b0ff76a9 (mouse-buffer-menu): Group buffers by major modes if that seems to be useful.
Richard M. Stallman <rms@gnu.org>
parents: 16746
diff changeset
1444 (list (cons title alist))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1446 ;;; These need to be rewritten for the new scroll bar implementation.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1448 ;;;!! ;; Commands for the scroll bar.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1449 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1450 ;;;!! (defun mouse-scroll-down (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1451 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1452 ;;;!! (scroll-down (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1453 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1454 ;;;!! (defun mouse-scroll-up (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1455 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1456 ;;;!! (scroll-up (1+ (cdr (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1457 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1458 ;;;!! (defun mouse-scroll-down-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1459 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1460 ;;;!! (scroll-down nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1461 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1462 ;;;!! (defun mouse-scroll-up-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1463 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1464 ;;;!! (scroll-up nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1465 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1466 ;;;!! (defun mouse-scroll-move-cursor (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1467 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1468 ;;;!! (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
1469 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1470 ;;;!! (defun mouse-scroll-absolute (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1471 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1472 ;;;!! (let* ((pos (car event))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1473 ;;;!! (position (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1474 ;;;!! (length (car (cdr pos))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1475 ;;;!! (if (<= length 0) (setq length 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1476 ;;;!! (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
1477 ;;;!! (newpos (* (/ (* (/ (buffer-size) scale-factor)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1478 ;;;!! position)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1479 ;;;!! length)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1480 ;;;!! scale-factor)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1481 ;;;!! (goto-char newpos)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1482 ;;;!! (recenter '(4)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1483 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1484 ;;;!! (defun mouse-scroll-left (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1485 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1486 ;;;!! (scroll-left (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1487 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1488 ;;;!! (defun mouse-scroll-right (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1489 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1490 ;;;!! (scroll-right (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1491 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1492 ;;;!! (defun mouse-scroll-left-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1493 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1494 ;;;!! (scroll-left nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1495 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1496 ;;;!! (defun mouse-scroll-right-full ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1497 ;;;!! (interactive "@")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1498 ;;;!! (scroll-right nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1499 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1500 ;;;!! (defun mouse-scroll-move-cursor-horizontally (click)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1501 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1502 ;;;!! (move-to-column (1+ (car (mouse-coords click)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1503 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1504 ;;;!! (defun mouse-scroll-absolute-horizontally (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1505 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1506 ;;;!! (let* ((pos (car event))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1507 ;;;!! (position (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1508 ;;;!! (length (car (cdr pos))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1509 ;;;!! (set-window-hscroll (selected-window) 33)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1510 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1511 ;;;!! (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
1512 ;;;!! (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
1513 ;;;!! (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
1514 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1515 ;;;!! (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
1516 ;;;!! (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
1517 ;;;!! (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
1518 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1519 ;;;!! (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
1520 ;;;!! (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
1521 ;;;!! (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
1522 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1523 ;;;!! (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
1524 ;;;!! (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
1525 ;;;!! (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
1526 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1527 ;;;!! (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
1528 ;;;!! (global-set-key [horizontal-scroll-bar mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1529 ;;;!! 'mouse-scroll-absolute-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1530 ;;;!! (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
1531 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1532 ;;;!! (global-set-key [horizontal-slider mouse-1]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1533 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1534 ;;;!! (global-set-key [horizontal-slider mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1535 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1536 ;;;!! (global-set-key [horizontal-slider mouse-3]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1537 ;;;!! 'mouse-scroll-move-cursor-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1538 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1539 ;;;!! (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
1540 ;;;!! (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
1541 ;;;!! (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
1542 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1543 ;;;!! (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
1544 ;;;!! (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
1545 ;;;!! (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
1546 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1547 ;;;!! (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
1548 ;;;!! 'mouse-split-window-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1549 ;;;!! (global-set-key [mode-line S-mouse-2]
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1550 ;;;!! 'mouse-split-window-horizontally)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1551 ;;;!! (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
1552 ;;;!! 'mouse-split-window)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1553
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1554 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1555 ;;;!! ;;;; Here are experimental things being tested. Mouse events
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1556 ;;;!! ;;;; are of the form:
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1557 ;;;!! ;;;; ((x y) window screen-part key-sequence timestamp)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1558 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1559 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1560 ;;;!! ;;;; Dynamically track mouse coordinates
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1561 ;;;!! ;;;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1562 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1563 ;;;!! ;;(defun track-mouse (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1564 ;;;!! ;; "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
1565 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1566 ;;;!! ;; (while mouse-grabbed
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1567 ;;;!! ;; (let* ((pos (read-mouse-position (selected-screen)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1568 ;;;!! ;; (abs-x (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1569 ;;;!! ;; (abs-y (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1570 ;;;!! ;; (relative-coordinate (coordinates-in-window-p
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1571 ;;;!! ;; (list (car pos) (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1572 ;;;!! ;; (selected-window))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1573 ;;;!! ;; (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1574 ;;;!! ;; (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
1575 ;;;!! ;; (car relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1576 ;;;!! ;; (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1577 ;;;!! ;; (message "mouse: [%d %d]" abs-x abs-y)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1578 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1579 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1580 ;;;!! ;; 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
1581 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1582 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1583 ;;;!! ;;(require 'backquote)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1584 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1585 ;;;!! ;;(defun mouse-select-buffer-line (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1586 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1587 ;;;!! ;; (let ((relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1588 ;;;!! ;; (coordinates-in-window-p (car event) (selected-window)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1589 ;;;!! ;; (abs-y (car (cdr (car event)))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1590 ;;;!! ;; (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1591 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1592 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1593 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1594 ;;;!! ;; (x-draw-rectangle
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1595 ;;;!! ;; (selected-screen)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1596 ;;;!! ;; abs-y 0
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1597 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1598 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1599 ;;;!! ;; (end-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1600 ;;;!! ;; (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1601 ;;;!! ;; (beginning-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1602 ;;;!! ;; (- (region-end) (region-beginning))) 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1603 ;;;!! ;; (sit-for 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1604 ;;;!! ;; (x-erase-rectangle (selected-screen))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1605 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1606 ;;;!! ;;(defvar last-line-drawn nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1607 ;;;!! ;;(defvar begin-delim "[^ \t]")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1608 ;;;!! ;;(defvar end-delim "[^ \t]")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1609 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1610 ;;;!! ;;(defun mouse-boxing (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1611 ;;;!! ;; (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1612 ;;;!! ;; (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1613 ;;;!! ;; (let ((screen (selected-screen)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1614 ;;;!! ;; (while (= (x-mouse-events) 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1615 ;;;!! ;; (let* ((pos (read-mouse-position screen))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1616 ;;;!! ;; (abs-x (car pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1617 ;;;!! ;; (abs-y (cdr pos))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1618 ;;;!! ;; (relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1619 ;;;!! ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1620 ;;;!! ;; (selected-window)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1621 ;;;!! ;; (begin-reg nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1622 ;;;!! ;; (end-reg nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1623 ;;;!! ;; (end-column nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1624 ;;;!! ;; (begin-column nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1625 ;;;!! ;; (if (and (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1626 ;;;!! ;; (or (not last-line-drawn)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1627 ;;;!! ;; (not (= last-line-drawn abs-y))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1628 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1629 ;;;!! ;; (move-to-window-line (car (cdr relative-coordinate)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1630 ;;;!! ;; (if (= (following-char) 10)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1631 ;;;!! ;; ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1632 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1633 ;;;!! ;; (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
1634 ;;;!! ;; (setq begin-column (1- (current-column)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1635 ;;;!! ;; (end-of-line)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1636 ;;;!! ;; (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
1637 ;;;!! ;; (setq end-column (1+ (current-column)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1638 ;;;!! ;; (message "%s" (buffer-substring begin-reg end-reg))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1639 ;;;!! ;; (x-draw-rectangle screen
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1640 ;;;!! ;; (setq last-line-drawn abs-y)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1641 ;;;!! ;; begin-column
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1642 ;;;!! ;; (- end-column begin-column) 1))))))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1643 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1644 ;;;!! ;;(defun mouse-erase-box ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1645 ;;;!! ;; (interactive)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1646 ;;;!! ;; (if last-line-drawn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1647 ;;;!! ;; (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1648 ;;;!! ;; (x-erase-rectangle (selected-screen))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1649 ;;;!! ;; (setq last-line-drawn nil))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1650 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1651 ;;;!! ;;; (defun test-x-rectangle ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1652 ;;;!! ;;; (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
1653 ;;;!! ;;; (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
1654 ;;;!! ;;; (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
1655 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1656 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1657 ;;;!! ;; 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
1658 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1659 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1660 ;;;!! (defvar double-start nil)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1661 ;;;!! (defconst double-click-interval 300
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1662 ;;;!! "Max ticks between clicks")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1663 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1664 ;;;!! (defun double-down (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1665 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1666 ;;;!! (if double-start
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1667 ;;;!! (let ((interval (- (nth 4 event) double-start)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1668 ;;;!! (if (< interval double-click-interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1669 ;;;!! (progn
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1670 ;;;!! (backward-up-list 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1671 ;;;!! ;; (message "Interval %d" interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1672 ;;;!! (sleep-for 1)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1673 ;;;!! (setq double-start nil))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1674 ;;;!! (setq double-start (nth 4 event))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1675 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1676 ;;;!! (defun double-up (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1677 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1678 ;;;!! (and double-start
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1679 ;;;!! (> (- (nth 4 event ) double-start) double-click-interval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1680 ;;;!! (setq double-start nil)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1681 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1682 ;;;!! ;;; (defun x-test-doubleclick ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1683 ;;;!! ;;; (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
1684 ;;;!! ;;; (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
1685 ;;;!! ;;; (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
1686 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1687 ;;;!! ;;
1980
263033210413 * mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1688 ;;;!! ;; 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
1689 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1690 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1691 ;;;!! (defvar scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1692 ;;;!! (defconst scroll-speed 1)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1693 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1694 ;;;!! (defun incr-scroll-down (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1695 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1696 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1697 ;;;!! (incremental-scroll scroll-speed))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1698 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1699 ;;;!! (defun incr-scroll-up (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1700 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1701 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1702 ;;;!! (incremental-scroll (- scroll-speed)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1703 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1704 ;;;!! (defun incremental-scroll (n)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1705 ;;;!! (while (= (x-mouse-events) 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1706 ;;;!! (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1707 ;;;!! (scroll-down n)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1708 ;;;!! (sit-for 300 t)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1709 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1710 ;;;!! (defun incr-scroll-stop (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1711 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1712 ;;;!! (message "Scrolled %d lines" scrolled-lines)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1713 ;;;!! (setq scrolled-lines 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1714 ;;;!! (sleep-for 1))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1715 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1716 ;;;!! ;;; (defun x-testing-scroll ()
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1717 ;;;!! ;;; (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
1718 ;;;!! ;;; (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
1719 ;;;!! ;;; (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
1720 ;;;!! ;;; (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
1721 ;;;!! ;;; (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
1722 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1723 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1724 ;;;!! ;; 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
1725 ;;;!! ;;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1726 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1727 ;;;!! (defun mouse-kill-rectangle (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1728 ;;;!! "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
1729 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1730 ;;;!! (let ((point-save (point)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1731 ;;;!! (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1732 ;;;!! (mouse-set-point event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1733 ;;;!! (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1734 ;;;!! (if (> point-save (point))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1735 ;;;!! (kill-rectangle (point) point-save)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1736 ;;;!! (kill-rectangle point-save (point))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1737 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1738 ;;;!! (defun mouse-open-rectangle (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1739 ;;;!! "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
1740 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1741 ;;;!! (let ((point-save (point)))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1742 ;;;!! (save-excursion
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1743 ;;;!! (mouse-set-point event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1744 ;;;!! (push-mark nil t)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1745 ;;;!! (if (> point-save (point))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1746 ;;;!! (open-rectangle (point) point-save)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1747 ;;;!! (open-rectangle point-save (point))))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1748 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1749 ;;;!! ;; Must be a better way to do this.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1750 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1751 ;;;!! (defun mouse-multiple-insert (n char)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1752 ;;;!! (while (> n 0)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1753 ;;;!! (insert char)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1754 ;;;!! (setq n (1- n))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1755 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1756 ;;;!! ;; 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
1757 ;;;!!
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1758 ;;;!! (defun mouse-move-text (event)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1759 ;;;!! "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
1760 ;;;!! (interactive "@e")
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1761 ;;;!! (let* ((relative-coordinate
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1762 ;;;!! (coordinates-in-window-p (car event) (selected-window))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1763 ;;;!! (if (consp relative-coordinate)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1764 ;;;!! (cond ((> (current-column) (car relative-coordinate))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1765 ;;;!! (delete-char
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1766 ;;;!! (- (car relative-coordinate) (current-column))))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1767 ;;;!! ((< (current-column) (car relative-coordinate))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1768 ;;;!! (mouse-multiple-insert
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1769 ;;;!! (- (car relative-coordinate) (current-column)) " "))
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1770 ;;;!! ((= (current-column) (car relative-coordinate)) (ding))))))
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1771
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1772 ;; Choose a completion with the mouse.
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1773
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1774 (defun mouse-choose-completion (event)
4371
fb0e37e7afae (mouse-choose-completion): Actually choose that alternative,
Richard M. Stallman <rms@gnu.org>
parents: 4294
diff changeset
1775 "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
1776 (interactive "e")
10258
0bcc67b3fe66 (mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents: 9936
diff changeset
1777 ;; 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
1778 (run-hooks 'mouse-leave-buffer-hook)
4788
3182c0f7ace4 (mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4751
diff changeset
1779 (let ((buffer (window-buffer))
8477
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1780 choice
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1781 base-size)
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1782 (save-excursion
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1783 (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
1784 (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
1785 (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
1786 (setq base-size completion-base-size)
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1787 (save-excursion
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1788 (goto-char (posn-point (event-start event)))
7593
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1789 (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
1790 (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
1791 (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
1792 (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
1793 (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
1794 (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
1795 (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
1796 (point-max)))
7593
a837cfdcf7c0 (mouse-choose-completion):
Richard M. Stallman <rms@gnu.org>
parents: 7588
diff changeset
1797 (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
1798 (let ((owindow (selected-window)))
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1799 (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
1800 (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
1801 (window-dedicated-p (selected-window)))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1802 ;; 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
1803 (iconify-frame (selected-frame))
10ed4c75936b (mouse-choose-completion): If *Completion* is a special
Richard M. Stallman <rms@gnu.org>
parents: 7637
diff changeset
1804 (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
1805 (bury-buffer)))
6231
c2bb4c368553 (mouse-choose-completion): Bury the completion buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6163
diff changeset
1806 (select-window owindow))
8477
f4aa7a288cb6 (mouse-choose-completion): Pass completion-base-size value
Richard M. Stallman <rms@gnu.org>
parents: 8460
diff changeset
1807 (choose-completion-string choice buffer base-size)))
4081
da352b92ca90 (mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3961
diff changeset
1808
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1809 ;; Font selection.
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1810
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1811 (defun font-menu-add-default ()
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1812 (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
1813 (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
1814 (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
1815 (if (assoc "Default" elt)
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1816 (delete (assoc "Default" elt) elt))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1817 (setcdr elt
4562
477fbf60722b (font-menu-add-default): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 4554
diff changeset
1818 (cons (list "Default"
4294
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1819 (cdr (assq 'font (frame-parameters (selected-frame)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1820 (cdr elt)))))
644e33e3ab38 (font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4274
diff changeset
1821
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1822 (defvar x-fixed-font-alist
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1823 '("Font menu"
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1824 ("Misc"
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1825 ;; 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
1826 ("fixed" "fixed")
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1827 ("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
1828 ("6x12"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1829 "-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
1830 ("6x13"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1831 "-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
1832 ("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
1833 ("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
1834 ("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
1835 ("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
1836 ("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
1837 ("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
1838 ("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
1839 ("")
8487
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1840 ("clean 5x8"
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1841 "-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
1842 ("clean 6x8"
0a77d1dbae03 (x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents: 8477
diff changeset
1843 "-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
1844 ("clean 8x8"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1845 "-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
1846 ("clean 8x10"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1847 "-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
1848 ("clean 8x14"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1849 "-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
1850 ("clean 8x16"
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1851 "-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
1852 ("")
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1853 ("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
1854 ;;; 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
1855 ;;; ("fg-18" "fg-18")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1856 ;;; ("fg-25" "fg-25")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1857 ;;; ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1858 ;;; ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1859 ;;; ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1860 ;;; ("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
1861 ;;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1862 ("Courier"
8460
5fd799a9946e (x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents: 8426
diff changeset
1863 ;; 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
1864 ("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
1865 ("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
1866 ("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
1867 ("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
1868 ("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
1869 ("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
1870 ("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
1871 ("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
1872 ("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
1873 ("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
1874 ("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
1875 ("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
1876 ("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
1877 ("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
1878 ("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
1879 ("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
1880 ("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
1881 ("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
1882 ("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
1883 ("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
1884 ("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
1885 ("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
1886 ("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
1887 ("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
1888 )
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1889 "X fonts suitable for use in Emacs.")
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1890
6867
0f4c8109274a (x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents: 6548
diff changeset
1891 (defun mouse-set-font (&rest fonts)
17008
3a99b530ad9a (mouse-set-font): Handle fontset.
Karl Heuer <kwzh@gnu.org>
parents: 16989
diff changeset
1892 "Select an emacs font from a list of known good fonts and fontsets."
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1893 (interactive
17008
3a99b530ad9a (mouse-set-font): Handle fontset.
Karl Heuer <kwzh@gnu.org>
parents: 16989
diff changeset
1894 (x-popup-menu
3a99b530ad9a (mouse-set-font): Handle fontset.
Karl Heuer <kwzh@gnu.org>
parents: 16989
diff changeset
1895 last-nonmenu-event
3a99b530ad9a (mouse-set-font): Handle fontset.
Karl Heuer <kwzh@gnu.org>
parents: 16989
diff changeset
1896 ;; Append list of fontsets currently defined.
3a99b530ad9a (mouse-set-font): Handle fontset.
Karl Heuer <kwzh@gnu.org>
parents: 16989
diff changeset
1897 (append x-fixed-font-alist (list (generate-fontset-menu)))))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1898 (if fonts
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1899 (let (font)
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1900 (while fonts
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1901 (condition-case nil
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1902 (progn
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1903 (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
1904 (setq font (car fonts))
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1905 (setq fonts nil))
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1906 (error
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1907 (setq fonts (cdr fonts)))))
6914
569c2c6d812f (mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents: 6867
diff changeset
1908 (if (null font)
7021
da5dc735eb50 (mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents: 6923
diff changeset
1909 (error "Font not found")))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1910
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1911 ;;; Bindings for mouse commands.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
1912
2799
93a5aef19835 (mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 2632
diff changeset
1913 (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
1914 (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
1915 (global-set-key [drag-mouse-1] 'mouse-set-region)
1057
d9775f33488d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1056
diff changeset
1916
4738
76a2ea569de5 (mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents: 4592
diff changeset
1917 ;; 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
1918 (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
1919 (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
1920
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1921 (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
1922 (global-set-key [mouse-3] 'mouse-save-then-kill)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
1923
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1765
diff changeset
1924 ;; 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
1925 ;; event to make the selection, saving a click.
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
1926 (global-set-key [C-down-mouse-1] 'mouse-buffer-menu)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
1927 (if (not (eq system-type 'ms-dos))
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
1928 (global-set-key [S-down-mouse-1] 'mouse-set-font))
9753
00144934b449 Put mouse-set-font on C-down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1929 ;; 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
1930 (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
1931
1100
5b3b202a84c8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1064
diff changeset
1932
1056
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1933 ;; Replaced with dragging mouse-1
a7fc54083464 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1039
diff changeset
1934 ;; (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
1935
6090
e7c900a464d3 (help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents: 6003
diff changeset
1936 (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
1937 (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
1938 (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
1939 (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
1940 (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
1941 (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
1942 (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
1943 (global-set-key [vertical-line C-mouse-2] 'mouse-split-window-vertically)
13038
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
1944 (global-set-key [vertical-line down-mouse-1] 'mouse-drag-vertical-line)
d07703594662 (C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents: 12844
diff changeset
1945 (global-set-key [vertical-line mouse-1] 'mouse-select-window)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1946
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1947 (provide 'mouse)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1948
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1949 ;;; mouse.el ends here