Mercurial > emacs
annotate lisp/mouse.el @ 110859:7aa4fdb60d57
shr.el (shr-insert): Don't insert double spaces.
auth.texi (Help for users, GnuPG and EasyPG Assistant Configuration): Update docs.
gnus-registry.el, nnregistry.el: Remove nnregistry refer method auto-install and update docs.
gnus.texi (Finding the Parent, The Gnus Registry, Registry Article Refer Method): Update docs for nnregistry.el.
gnus-demon.el, gnus-group.el, gnus-msg.el, gnus-sum.el, gnus-util.el, gnus.el: Rename `gnus-pull' to `gnus-alist-pull'.
gnus.texi (Article Washing): Add mm-shr.
mm-decode.el (mm-text-html-renderer): Add mm-shr in choice list.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Fri, 08 Oct 2010 23:55:33 +0000 |
parents | 515d80e174ba |
children | b5cc0d963641 |
rev | line source |
---|---|
13337 | 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 |
96062
585941e8f7bc
(buffer-face-mode-invoke): Declare.
Glenn Morris <rgm@gnu.org>
parents:
96043
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
791
diff
changeset
|
5 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
6 ;; Maintainer: FSF |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
7 ;; Keywords: hardware, mouse |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
109965
diff
changeset
|
8 ;; Package: emacs |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
9 |
13337 | 10 ;; This file is part of GNU Emacs. |
66 | 11 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94162
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
13337 | 13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94162
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94162
diff
changeset
|
15 ;; (at your option) any later version. |
66 | 16 |
13337 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
66 | 21 |
13337 | 22 ;; You should have received a copy of the GNU General Public License |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94162
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
66 | 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 | 35 ;;; Utility functions. |
36 | |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
37 ;; Indent track-mouse like progn. |
465 | 38 (put 'track-mouse 'lisp-indent-function 0) |
66 | 39 |
17636 | 40 (defcustom mouse-yank-at-point nil |
100171 | 41 "If non-nil, mouse yank commands yank at point instead of at click." |
17636 | 42 :type 'boolean |
43 :group 'mouse) | |
55260
f547921c38ba
(mouse-drag-copy-region): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
54867
diff
changeset
|
44 |
109398
c9970d4bfd62
Change clipboard/primary selection to X application standards.
Chong Yidong <cyd@stupidchicken.com>
parents:
109322
diff
changeset
|
45 (defcustom mouse-drag-copy-region nil |
110206
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
46 "If non-nil, copy to kill-ring upon mouse adjustments of the region. |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
47 |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
48 This affects `mouse-save-then-kill' (\\[mouse-save-then-kill]) in |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
49 addition to mouse drags." |
55260
f547921c38ba
(mouse-drag-copy-region): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
54867
diff
changeset
|
50 :type 'boolean |
109448
334eb7871775
Change x-select-enable-primary to nil.
Chong Yidong <cyd@stupidchicken.com>
parents:
109398
diff
changeset
|
51 :version "24.1" |
55260
f547921c38ba
(mouse-drag-copy-region): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
54867
diff
changeset
|
52 :group 'mouse) |
f547921c38ba
(mouse-drag-copy-region): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
54867
diff
changeset
|
53 |
61160
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
54 (defcustom mouse-1-click-follows-link 450 |
59036
f1a383c1b9cd
(mouse-1-click-follows-link): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
59016
diff
changeset
|
55 "Non-nil means that clicking Mouse-1 on a link follows the link. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
56 |
59036
f1a383c1b9cd
(mouse-1-click-follows-link): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
59016
diff
changeset
|
57 With the default setting, an ordinary Mouse-1 click on a link |
f1a383c1b9cd
(mouse-1-click-follows-link): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
59016
diff
changeset
|
58 performs the same action as Mouse-2 on that link, while a longer |
66123
e7767b4c6597
(mouse-1-click-follows-link): Doc fix.
Romain Francoise <romain@orebokech.com>
parents:
66085
diff
changeset
|
59 Mouse-1 click \(hold down the Mouse-1 button for more than 450 |
59036
f1a383c1b9cd
(mouse-1-click-follows-link): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
59016
diff
changeset
|
60 milliseconds) performs the original Mouse-1 binding \(which |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
61 typically sets point where you click the mouse). |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
62 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
63 If value is an integer, the time elapsed between pressing and |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
64 releasing the mouse button determines whether to follow the link |
59036
f1a383c1b9cd
(mouse-1-click-follows-link): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
59016
diff
changeset
|
65 or perform the normal Mouse-1 action (typically set point). |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
66 The absolute numeric value specifices the maximum duration of a |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
67 \"short click\" in milliseconds. A positive value means that a |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
68 short click follows the link, and a longer click performs the |
63256
08eb8fe4b5ef
(mouse-1-click-follows-link): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
61767
diff
changeset
|
69 normal action. A negative value gives the opposite behavior. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
70 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
71 If value is `double', a double click follows the link. |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
72 |
59036
f1a383c1b9cd
(mouse-1-click-follows-link): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
59016
diff
changeset
|
73 Otherwise, a single Mouse-1 click unconditionally follows the link. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
74 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
75 Note that dragging the mouse never follows the link. |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
76 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
77 This feature only works in modes that specifically identify |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
78 clickable text as links, so it may not work with some external |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
79 packages. See `mouse-on-link-p' for details." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59526
diff
changeset
|
80 :version "22.1" |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
81 :type '(choice (const :tag "Disabled" nil) |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
82 (const :tag "Double click" double) |
66123
e7767b4c6597
(mouse-1-click-follows-link): Doc fix.
Romain Francoise <romain@orebokech.com>
parents:
66085
diff
changeset
|
83 (number :tag "Single click time limit" :value 450) |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
84 (other :tag "Single click" t)) |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
85 :group 'mouse) |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
86 |
60253
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
87 (defcustom mouse-1-click-in-non-selected-windows t |
100171 | 88 "If non-nil, a Mouse-1 click also follows links in non-selected windows. |
60253
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
89 |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
90 If nil, a Mouse-1 click on a link in a non-selected window performs |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
91 the normal mouse-1 binding, typically selects the window and sets |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
92 point at the click position." |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
93 :type 'boolean |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
94 :version "22.1" |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
95 :group 'mouse) |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
96 |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
97 |
465 | 98 |
9488
114fe3739aa3
(mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents:
9206
diff
changeset
|
99 ;; 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
|
100 |
30312
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
101 (defun popup-menu (menu &optional position prefix) |
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
102 "Popup the given menu and call the selected option. |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
103 MENU can be a keymap, an easymenu-style menu or a list of keymaps as for |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
104 `x-popup-menu'. |
30312
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
105 POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to |
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
106 the current mouse position. |
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
107 PREFIX is the prefix argument (if any) to pass to the command." |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
108 (let* ((map (cond |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
109 ((keymapp menu) menu) |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
110 ((and (listp menu) (keymapp (car menu))) menu) |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
111 (t (let* ((map (easy-menu-create-menu (car menu) (cdr menu))) |
33769
7596dea75d6b
(popup-menu): Stupid typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32327
diff
changeset
|
112 (filter (when (symbolp map) |
7596dea75d6b
(popup-menu): Stupid typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32327
diff
changeset
|
113 (plist-get (get map 'menu-prop) :filter)))) |
7596dea75d6b
(popup-menu): Stupid typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32327
diff
changeset
|
114 (if filter (funcall filter (symbol-function map)) map))))) |
32312
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
115 event cmd) |
31912
83fe15f82f7e
(popup-menu): If POSITION is nil, set it using
Dave Love <fx@gnu.org>
parents:
31390
diff
changeset
|
116 (unless position |
31923 | 117 (let ((mp (mouse-pixel-position))) |
31912
83fe15f82f7e
(popup-menu): If POSITION is nil, set it using
Dave Love <fx@gnu.org>
parents:
31390
diff
changeset
|
118 (setq position (list (list (cadr mp) (cddr mp)) (car mp))))) |
30312
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
119 ;; The looping behavior was taken from lmenu's popup-menu-popup |
30421
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
120 (while (and map (setq event |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
121 ;; map could be a prefix key, in which case |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
122 ;; we need to get its function cell |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
123 ;; definition. |
31923 | 124 (x-popup-menu position (indirect-function map)))) |
30312
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
125 ;; Strangely x-popup-menu returns a list. |
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
126 ;; mouse-major-mode-menu was using a weird: |
a97801b43475
(popup-menu): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30249
diff
changeset
|
127 ;; (key-binding (apply 'vector (append '(menu-bar) menu-prefix events))) |
32312
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
128 (setq cmd |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
129 (if (and (not (keymapp map)) (listp map)) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
130 ;; We were given a list of keymaps. Search them all |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
131 ;; in sequence until a first binding is found. |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
132 (let ((mouse-click (apply 'vector event)) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
133 binding) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
134 (while (and map (null binding)) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
135 (setq binding (lookup-key (car map) mouse-click)) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
136 (if (numberp binding) ; `too long' |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
137 (setq binding nil)) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
138 (setq map (cdr map))) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
139 binding) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
140 ;; We were given a single keymap. |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
141 (lookup-key map (apply 'vector event)))) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
142 ;; Clear out echoing, which perhaps shows a prefix arg. |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
143 (message "") |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
144 ;; Maybe try again but with the submap. |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
145 (setq map (if (keymapp cmd) cmd))) |
40648
a48a4d0806b4
(popup-menu): If the user refuses to select
Richard M. Stallman <rms@gnu.org>
parents:
40379
diff
changeset
|
146 ;; If the user did not cancel by refusing to select, |
a48a4d0806b4
(popup-menu): If the user refuses to select
Richard M. Stallman <rms@gnu.org>
parents:
40379
diff
changeset
|
147 ;; and if the result is a command, run it. |
a48a4d0806b4
(popup-menu): If the user refuses to select
Richard M. Stallman <rms@gnu.org>
parents:
40379
diff
changeset
|
148 (when (and (null map) (commandp cmd)) |
32312
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
149 (setq prefix-arg prefix) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
150 ;; `setup-specified-language-environment', for instance, |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
151 ;; expects this to be set from a menu keymap. |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
152 (setq last-command-event (car (last event))) |
b95ac47063ce
(popup-menu): Move the command call outside the loop
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32269
diff
changeset
|
153 ;; mouse-major-mode-menu was using `command-execute' instead. |
32319
452e7cc818ac
(popup-menu): Balance parens.
Miles Bader <miles@gnu.org>
parents:
32312
diff
changeset
|
154 (call-interactively cmd)))) |
30425
ad577e2e48d3
(popup-menu): Set last-command-event.
Dave Love <fx@gnu.org>
parents:
30421
diff
changeset
|
155 |
85434
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
156 (defun minor-mode-menu-from-indicator (indicator) |
92046
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
157 "Show menu for minor mode specified by INDICATOR. |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
158 Interactively, INDICATOR is read using completion. |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
159 If there is no menu defined for the minor mode, then create one with |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
160 items `Turn Off' and `Help'." |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
161 (interactive |
94162
6832f57d6232
(mouse-major-mode-menu, mouse-popup-menubar, mouse-popup-menubar-stuff):
Juanma Barranquero <lekktu@gmail.com>
parents:
93889
diff
changeset
|
162 (list (completing-read |
92046
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
163 "Minor mode indicator: " |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
164 (describe-minor-mode-completion-table-for-indicator)))) |
105048
1eb4a432a8ae
(minor-mode-menu-from-indicator): Pay attention
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
103950
diff
changeset
|
165 (let* ((minor-mode (lookup-minor-mode-from-indicator indicator)) |
1eb4a432a8ae
(minor-mode-menu-from-indicator): Pay attention
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
103950
diff
changeset
|
166 (mm-fun (or (get minor-mode :minor-mode-function) minor-mode))) |
92046
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
167 (unless minor-mode (error "Cannot find minor mode for `%s'" indicator)) |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
168 (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist))) |
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
169 (menu (and (keymapp map) (lookup-key map [menu-bar])))) |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
170 (setq menu |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
171 (if menu |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
172 (mouse-menu-non-singleton menu) |
92046
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
173 `(keymap |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
174 ,indicator |
105048
1eb4a432a8ae
(minor-mode-menu-from-indicator): Pay attention
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
103950
diff
changeset
|
175 (turn-off menu-item "Turn Off minor mode" ,mm-fun) |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
176 (help menu-item "Help for minor mode" |
94162
6832f57d6232
(mouse-major-mode-menu, mouse-popup-menubar, mouse-popup-menubar-stuff):
Juanma Barranquero <lekktu@gmail.com>
parents:
93889
diff
changeset
|
177 (lambda () (interactive) |
105048
1eb4a432a8ae
(minor-mode-menu-from-indicator): Pay attention
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
103950
diff
changeset
|
178 (describe-function ',mm-fun)))))) |
92046
3831642b30d0
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
Dan Nicolaescu <dann@ics.uci.edu>
parents:
91611
diff
changeset
|
179 (popup-menu menu)))) |
85434
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
180 |
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
181 (defun mouse-minor-mode-menu (event) |
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
182 "Show minor-mode menu for EVENT on minor modes area of the mode line." |
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
183 (interactive "@e") |
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
184 (let ((indicator (car (nth 4 (car (cdr event)))))) |
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
185 (minor-mode-menu-from-indicator indicator))) |
1921151f9249
(mouse-minor-mode-menu, minor-mode-menu-from-indicator):
Glenn Morris <rgm@gnu.org>
parents:
82298
diff
changeset
|
186 |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
187 (defun mouse-menu-major-mode-map () |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
188 (let* (;; Keymap from which to inherit; may be null. |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
189 (ancestor (mouse-menu-non-singleton |
24960
00d2eba70774
(mouse-major-mode-menu): Default to menu-bar-edit-menu
Dave Love <fx@gnu.org>
parents:
23854
diff
changeset
|
190 (and (current-local-map) |
31258
12f2e341ee9c
(mouse-major-mode-menu): Use local-key-binding.
Dave Love <fx@gnu.org>
parents:
30425
diff
changeset
|
191 (local-key-binding [menu-bar])))) |
24960
00d2eba70774
(mouse-major-mode-menu): Default to menu-bar-edit-menu
Dave Love <fx@gnu.org>
parents:
23854
diff
changeset
|
192 ;; Make a keymap in which our last command leads to a menu or |
00d2eba70774
(mouse-major-mode-menu): Default to menu-bar-edit-menu
Dave Love <fx@gnu.org>
parents:
23854
diff
changeset
|
193 ;; default to the edit menu. |
00d2eba70774
(mouse-major-mode-menu): Default to menu-bar-edit-menu
Dave Love <fx@gnu.org>
parents:
23854
diff
changeset
|
194 (newmap (if ancestor |
87567
4c3c683cdff8
* erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87387
diff
changeset
|
195 (make-sparse-keymap (concat (format-mode-line mode-name) |
4c3c683cdff8
* erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87387
diff
changeset
|
196 " Mode")) |
87636
08663683b8a1
(mouse-major-mode-menu): Suppress duplicate menus.
Glenn Morris <rgm@gnu.org>
parents:
87574
diff
changeset
|
197 menu-bar-edit-menu)) |
08663683b8a1
(mouse-major-mode-menu): Suppress duplicate menus.
Glenn Morris <rgm@gnu.org>
parents:
87574
diff
changeset
|
198 uniq) |
24960
00d2eba70774
(mouse-major-mode-menu): Default to menu-bar-edit-menu
Dave Love <fx@gnu.org>
parents:
23854
diff
changeset
|
199 (if ancestor |
93664
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
200 (set-keymap-parent newmap ancestor)) |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
201 newmap)) |
9488
114fe3739aa3
(mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents:
9206
diff
changeset
|
202 |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
203 (defun mouse-menu-non-singleton (menubar) |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
204 "Given menu keymap, |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
205 if it defines exactly one submenu, return just that submenu. |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
206 Otherwise return the whole menu." |
9488
114fe3739aa3
(mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents:
9206
diff
changeset
|
207 (if menubar |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
208 (let (submap) |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
209 (map-keymap |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
210 (lambda (k v) (setq submap (if submap t (cons k v)))) |
93664
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
211 (keymap-canonicalize menubar)) |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
212 (if (eq submap t) |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
213 menubar |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
214 (lookup-key menubar (vector (car submap))))))) |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
215 |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
216 (defun mouse-menu-bar-map () |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
217 "Return a keymap equivalent to the menu bar. |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
218 The contents are the items that would be in the menu bar whether or |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
219 not it is actually displayed." |
30421
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
220 (let* ((local-menu (and (current-local-map) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
221 (lookup-key (current-local-map) [menu-bar]))) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
222 (global-menu (lookup-key global-map [menu-bar])) |
31329
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
223 ;; If a keymap doesn't have a prompt string (a lazy |
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
224 ;; programmer didn't bother to provide one), create it and |
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
225 ;; insert it into the keymap; each keymap gets its own |
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
226 ;; prompt. This is required for non-toolkit versions to |
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
227 ;; display non-empty menu pane names. |
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
228 (minor-mode-menus |
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
229 (mapcar |
93664
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
230 (lambda (menu) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
231 (let* ((minor-mode (car menu)) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
232 (menu (cdr menu)) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
233 (title-or-map (cadr menu))) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
234 (or (stringp title-or-map) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
235 (setq menu |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
236 (cons 'keymap |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
237 (cons (concat |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
238 (capitalize (subst-char-in-string |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
239 ?- ?\s (symbol-name |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
240 minor-mode))) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
241 " Menu") |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
242 (cdr menu))))) |
c7dd307b0ec5
* subr.el (keymap-canonicalize): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93549
diff
changeset
|
243 menu)) |
31329
f329cce08485
(mouse-popup-menubar): Supply the prompt string for
Eli Zaretskii <eliz@gnu.org>
parents:
31258
diff
changeset
|
244 (minor-mode-key-binding [menu-bar]))) |
30421
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
245 (local-title-or-map (and local-menu (cadr local-menu))) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
246 (global-title-or-map (cadr global-menu))) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
247 (or (null local-menu) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
248 (stringp local-title-or-map) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
249 (setq local-menu (cons 'keymap |
87574
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87567
diff
changeset
|
250 (cons (concat (format-mode-line mode-name) |
87567
4c3c683cdff8
* erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87387
diff
changeset
|
251 " Mode Menu") |
30421
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
252 (cdr local-menu))))) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
253 (or (stringp global-title-or-map) |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
254 (setq global-menu (cons 'keymap |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
255 (cons "Global Menu" |
544a9b8ebb8d
(popup-menu): Run the keymap through indirect-function,
Eli Zaretskii <eliz@gnu.org>
parents:
30328
diff
changeset
|
256 (cdr global-menu))))) |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
257 ;; Supplying the list is faster than making a new map. |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
258 ;; FIXME: We have a problem here: we have to use the global/local/minor |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
259 ;; so they're displayed in the expected order, but later on in the command |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
260 ;; loop, they're actually looked up in the opposite order. |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
261 (apply 'append |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
262 global-menu |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
263 local-menu |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
264 minor-mode-menus))) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
265 |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
266 (defun mouse-major-mode-menu (event &optional prefix) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
267 "Pop up a mode-specific menu of mouse commands. |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
268 Default to the Edit menu if the major mode doesn't define a menu." |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
269 (interactive "@e\nP") |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
270 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
271 (popup-menu (mouse-menu-major-mode-map) event prefix)) |
94162
6832f57d6232
(mouse-major-mode-menu, mouse-popup-menubar, mouse-popup-menubar-stuff):
Juanma Barranquero <lekktu@gmail.com>
parents:
93889
diff
changeset
|
272 (make-obsolete 'mouse-major-mode-menu 'mouse-menu-major-mode-map "23.1") |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
273 |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
274 (defun mouse-popup-menubar (event prefix) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
275 "Pop up a menu equivalent to the menu bar for keyboard EVENT with PREFIX. |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
276 The contents are the items that would be in the menu bar whether or |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
277 not it is actually displayed." |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
278 (interactive "@e \nP") |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
279 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
280 (popup-menu (mouse-menu-bar-map) event prefix)) |
94162
6832f57d6232
(mouse-major-mode-menu, mouse-popup-menubar, mouse-popup-menubar-stuff):
Juanma Barranquero <lekktu@gmail.com>
parents:
93889
diff
changeset
|
281 (make-obsolete 'mouse-popup-menubar 'mouse-menu-bar-map "23.1") |
30328
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
282 |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
283 (defun mouse-popup-menubar-stuff (event prefix) |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
284 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'. |
7ce202715b72
(popup-menu): Allow a list of keymaps for menu arg.
Dave Love <fx@gnu.org>
parents:
30312
diff
changeset
|
285 Use the former if the menu bar is showing, otherwise the latter." |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
286 (interactive "@e\nP") |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
287 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
288 (popup-menu |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
289 (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0)) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
290 (mouse-menu-bar-map) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
291 (mouse-menu-major-mode-map)) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
292 event prefix)) |
94162
6832f57d6232
(mouse-major-mode-menu, mouse-popup-menubar, mouse-popup-menubar-stuff):
Juanma Barranquero <lekktu@gmail.com>
parents:
93889
diff
changeset
|
293 (make-obsolete 'mouse-popup-menubar-stuff nil "23.1") |
9488
114fe3739aa3
(mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents:
9206
diff
changeset
|
294 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
295 ;; 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
|
296 |
6266
66c0ed95c03f
(mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents:
6231
diff
changeset
|
297 (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
|
298 (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
|
299 (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
|
300 (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
|
301 (error "Minibuffer window is not active"))) |
0bcc67b3fe66
(mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents:
9936
diff
changeset
|
302 ;; 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
|
303 (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
|
304 |
465 | 305 (defun mouse-delete-window (click) |
1214
467833df795b
(mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents:
1113
diff
changeset
|
306 "Delete the window you click on. |
38763
3cf8f8ea6d0e
(mouse-delete-window): Do nothing if frame has just
Gerd Moellmann <gerd@gnu.org>
parents:
37741
diff
changeset
|
307 Do nothing if the frame has just one window. |
22845
bd706438b50c
(mouse-delete-window): If the frame has just one window,
Richard M. Stallman <rms@gnu.org>
parents:
21953
diff
changeset
|
308 This command must be bound to a mouse click." |
1113 | 309 (interactive "e") |
38763
3cf8f8ea6d0e
(mouse-delete-window): Do nothing if frame has just
Gerd Moellmann <gerd@gnu.org>
parents:
37741
diff
changeset
|
310 (unless (one-window-p t) |
22845
bd706438b50c
(mouse-delete-window): If the frame has just one window,
Richard M. Stallman <rms@gnu.org>
parents:
21953
diff
changeset
|
311 (mouse-minibuffer-check click) |
bd706438b50c
(mouse-delete-window): If the frame has just one window,
Richard M. Stallman <rms@gnu.org>
parents:
21953
diff
changeset
|
312 (delete-window (posn-window (event-start click))))) |
465 | 313 |
6090
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
314 (defun mouse-select-window (click) |
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
315 "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
|
316 (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
|
317 (mouse-minibuffer-check click) |
6090
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
318 (let ((oframe (selected-frame)) |
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
319 (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
|
320 (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
|
321 (raise-frame frame) |
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
322 (select-frame frame) |
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
323 (or (eq frame oframe) |
16087
26b552f014ff
(mouse-select-window): Don't call unfocus-frame.
Richard M. Stallman <rms@gnu.org>
parents:
16016
diff
changeset
|
324 (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
|
325 |
1421
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
326 (defun mouse-tear-off-window (click) |
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
327 "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
|
328 (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
|
329 (mouse-minibuffer-check click) |
1421
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
330 (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
|
331 (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
|
332 (frame (make-frame))) |
1421
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
333 (select-frame frame) |
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
334 (switch-to-buffer buf) |
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
335 (delete-window window))) |
a8378792a31d
* mouse.el (mouse-tear-off-window): New function.
Jim Blandy <jimb@redhat.com>
parents:
1420
diff
changeset
|
336 |
1363
f34d8e4d1d7b
* mouse.el: Begin adapting this to the new event format.
Jim Blandy <jimb@redhat.com>
parents:
1214
diff
changeset
|
337 (defun mouse-delete-other-windows () |
37741
7b449aec29d2
(mouse-delete-other-windows): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents:
36134
diff
changeset
|
338 "Delete all windows 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
|
339 (interactive "@") |
66 | 340 (delete-other-windows)) |
341 | |
465 | 342 (defun mouse-split-window-vertically (click) |
343 "Select Emacs window mouse is on, then split it vertically in half. | |
344 The window is split at the line clicked on. | |
345 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
|
346 (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
|
347 (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
|
348 (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
|
349 (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
|
350 (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
|
351 (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
|
352 (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
|
353 (if (< last-line first-line) |
8426
3abe02e03dc8
Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents:
8381
diff
changeset
|
354 (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
|
355 (split-window-vertically |
263033210413
* mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
356 (min (max new-height first-line) last-line)))))) |
66 | 357 |
1214
467833df795b
(mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents:
1113
diff
changeset
|
358 (defun mouse-split-window-horizontally (click) |
467833df795b
(mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents:
1113
diff
changeset
|
359 "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
|
360 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
|
361 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
|
362 (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
|
363 (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
|
364 (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
|
365 (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
|
366 (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
|
367 (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
|
368 (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
|
369 (if (< last-col first-col) |
8426
3abe02e03dc8
Capitalize some error messages.
Richard M. Stallman <rms@gnu.org>
parents:
8381
diff
changeset
|
370 (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
|
371 (split-window-horizontally |
263033210413
* mouse.el (mouse-split-window-vertically): If the user clicks too
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
372 (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
|
373 |
42399
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
374 (defun mouse-drag-window-above (window) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
375 "Return the (or a) window directly above WINDOW. |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
376 That means one whose bottom edge is at the same height as WINDOW's top edge." |
67954
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
377 (let ((start-top (nth 1 (window-edges window))) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
378 (start-left (nth 0 (window-edges window))) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
379 (start-right (nth 2 (window-edges window))) |
42399
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
380 (start-window window) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
381 above-window) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
382 (setq window (previous-window window 0)) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
383 (while (and (not above-window) (not (eq window start-window))) |
67954
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
384 (let ((left (nth 0 (window-edges window))) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
385 (right (nth 2 (window-edges window)))) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
386 (when (and (= (+ (window-height window) (nth 1 (window-edges window))) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
387 start-top) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
388 (or (and (<= left start-left) (<= start-right right)) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
389 (and (<= start-left left) (<= left start-right)) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
390 (and (<= start-left right) (<= right start-right)))) |
f223df02d351
(mouse-drag-window-above): Verify that the found window overlaps with the
Eli Zaretskii <eliz@gnu.org>
parents:
67870
diff
changeset
|
391 (setq above-window window))) |
42399
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
392 (setq window (previous-window window))) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
393 above-window)) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
394 |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
395 (defun mouse-drag-move-window-bottom (window growth) |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
396 "Move the bottom of WINDOW up or down by GROWTH lines. |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
397 Move it down if GROWTH is positive, or up if GROWTH is negative. |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
398 If this would make WINDOW too short, |
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
399 shrink the window or windows above it to make room." |
67158
2c91c2e7af3a
(mouse-drag-move-window-bottom): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
66669
diff
changeset
|
400 (condition-case nil |
2c91c2e7af3a
(mouse-drag-move-window-bottom): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
66669
diff
changeset
|
401 (adjust-window-trailing-edge window growth nil) |
2c91c2e7af3a
(mouse-drag-move-window-bottom): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
66669
diff
changeset
|
402 (error nil))) |
42399
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
403 |
57569
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
404 (defsubst mouse-drag-move-window-top (window growth) |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
405 "Move the top of WINDOW up or down by GROWTH lines. |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
406 Move it down if GROWTH is positive, or up if GROWTH is negative. |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
407 If this would make WINDOW too short, shrink the window or windows |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
408 above it to make room." |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
409 ;; Moving the top of WINDOW is actually moving the bottom of the |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
410 ;; window above. |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
411 (let ((window-above (mouse-drag-window-above window))) |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
412 (and window-above |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
413 (mouse-drag-move-window-bottom window-above (- growth))))) |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
414 |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
415 (defun mouse-drag-mode-line-1 (start-event mode-line-p) |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
416 "Change the height of a window by dragging on the mode or header line. |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
417 START-EVENT is the starting mouse-event of the drag action. |
42399
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
418 MODE-LINE-P non-nil means dragging a mode line; nil means a header line." |
10258
0bcc67b3fe66
(mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents:
9936
diff
changeset
|
419 ;; 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
|
420 (run-hooks 'mouse-leave-buffer-hook) |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
421 (let* ((done nil) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
422 (echo-keystrokes 0) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
423 (start (event-start start-event)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
424 (start-event-window (posn-window start)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
425 (start-event-frame (window-frame start-event-window)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
426 (start-nwindows (count-windows t)) |
101722
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
427 (on-link (and mouse-1-click-follows-link |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
428 (or mouse-1-click-in-non-selected-windows |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
429 (eq (posn-window start) (selected-window))) |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
430 (mouse-on-link-p start))) |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
431 (minibuffer (frame-parameter nil 'minibuffer)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
432 should-enlarge-minibuffer event mouse y top bot edges wconfig growth) |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
433 (track-mouse |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
434 (progn |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
435 ;; 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
|
436 ;; 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
|
437 (setq should-enlarge-minibuffer |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
438 (and minibuffer |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
439 mode-line-p |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
440 (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
|
441 (= (nth 1 (window-edges minibuffer)) |
76293
91a6d7f7e1a7
(mouse-drag-mode-line-1, mouse-drag-vertical-line):
Richard M. Stallman <rms@gnu.org>
parents:
76155
diff
changeset
|
442 (nth 3 (window-edges start-event-window))))) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
443 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
444 ;; 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
|
445 ;; the mouse. |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
446 (while (not done) |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
447 (setq event (read-event) |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
448 mouse (mouse-position)) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
449 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
450 ;; do nothing if |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
451 ;; - 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
|
452 ;; - 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
|
453 ;; - 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
|
454 ;; drag if |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
455 ;; - 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
|
456 ;; - 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
|
457 ;; (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
|
458 ;; quit if |
78067
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
459 ;; - there is a keyboard event or some other unknown event. |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
460 (cond ((not (consp event)) |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
461 (setq done t)) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
462 |
59470
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
463 ((memq (car event) '(switch-frame select-window)) |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
464 nil) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
465 |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
466 ((not (memq (car event) '(mouse-movement scroll-bar-movement))) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
467 (when (consp event) |
78067
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
468 ;; Do not unread a drag-mouse-1 event since it will cause the |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
469 ;; selection of the window above when dragging the modeline |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
470 ;; above the selected window. |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
471 (unless (eq (car event) 'drag-mouse-1) |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
472 (push event unread-command-events))) |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
473 (setq done t)) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
474 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
475 ((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
|
476 nil) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
477 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
478 ((null (car (cdr mouse))) |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
479 nil) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
480 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
481 (t |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
482 (setq y (cdr (cdr mouse)) |
76293
91a6d7f7e1a7
(mouse-drag-mode-line-1, mouse-drag-vertical-line):
Richard M. Stallman <rms@gnu.org>
parents:
76155
diff
changeset
|
483 edges (window-edges start-event-window) |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
484 top (nth 1 edges) |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
485 bot (nth 3 edges)) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
486 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
487 ;; compute size change needed |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
488 (cond (mode-line-p |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
489 (setq growth (- y bot -1))) |
32269
5bccbf00889a
(mouse-drag-mode-line-1): Fix an off-by-one error in
Eli Zaretskii <eliz@gnu.org>
parents:
32207
diff
changeset
|
490 (t ; header line |
5bccbf00889a
(mouse-drag-mode-line-1): Fix an off-by-one error in
Eli Zaretskii <eliz@gnu.org>
parents:
32207
diff
changeset
|
491 (when (< (- bot y) window-min-height) |
5bccbf00889a
(mouse-drag-mode-line-1): Fix an off-by-one error in
Eli Zaretskii <eliz@gnu.org>
parents:
32207
diff
changeset
|
492 (setq y (- bot window-min-height))) |
5bccbf00889a
(mouse-drag-mode-line-1): Fix an off-by-one error in
Eli Zaretskii <eliz@gnu.org>
parents:
32207
diff
changeset
|
493 ;; The window's top includes the header line! |
5bccbf00889a
(mouse-drag-mode-line-1): Fix an off-by-one error in
Eli Zaretskii <eliz@gnu.org>
parents:
32207
diff
changeset
|
494 (setq growth (- top y)))) |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
495 (setq wconfig (current-window-configuration)) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
496 |
16636
ba78d234fe6c
(mouse-drag-mode-line): Don't get error
Richard M. Stallman <rms@gnu.org>
parents:
16621
diff
changeset
|
497 ;; Check for an error case. |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
498 (when (and (/= growth 0) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
499 (not minibuffer) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
500 (one-window-p t)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
501 (error "Attempt to resize sole window")) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
502 |
101722
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
503 ;; If we ever move, make sure we don't mistakenly treat |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
504 ;; some unexpected `mouse-1' final event as a sign that |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
505 ;; this whole drag was nothing more than a click. |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
506 (if (/= growth 0) (setq on-link nil)) |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
507 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
508 ;; grow/shrink minibuffer? |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
509 (if should-enlarge-minibuffer |
68858
bb38a98ef7ad
(mouse-drag-mode-line-1): Use mouse-drag-move-window-bottom
Richard M. Stallman <rms@gnu.org>
parents:
68734
diff
changeset
|
510 (unless resize-mini-windows |
bb38a98ef7ad
(mouse-drag-mode-line-1): Use mouse-drag-move-window-bottom
Richard M. Stallman <rms@gnu.org>
parents:
68734
diff
changeset
|
511 (mouse-drag-move-window-bottom start-event-window growth)) |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
512 ;; no. grow/shrink the selected window |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
513 ;(message "growth = %d" growth) |
57569
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
514 (if mode-line-p |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
515 (mouse-drag-move-window-bottom start-event-window growth) |
f2e8ab894ad3
(mouse-drag-move-window-top): New function.
David Ponce <david@dponce.com>
parents:
57524
diff
changeset
|
516 (mouse-drag-move-window-top start-event-window growth))) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
517 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
518 ;; 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
|
519 ;; 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
|
520 ;; short, rescind the change. |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
521 ;; |
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
522 ;; 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
|
523 ;; from a window above this one, rescind the |
30249
fb30df0ff4ab
(mouse-major-mode-menu-1): get the submenu with lookup-key.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30122
diff
changeset
|
524 ;; change, but only if we didn't grow/shrink |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
525 ;; 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
|
526 ;; 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
|
527 ;; around it. |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
528 (when (or (/= start-nwindows (count-windows t)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
529 (and (not should-enlarge-minibuffer) |
42399
92c21a38c096
(mouse-drag-mode-line-1): When dragging a mode line upward,
Richard M. Stallman <rms@gnu.org>
parents:
42149
diff
changeset
|
530 (> growth 0) |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
531 mode-line-p |
78067
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
532 (/= top |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
533 (nth 1 (window-edges |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
534 ;; Choose right window. |
b24147eb76bb
(mouse-drag-mode-line-1): Quit mouse tracking when
Martin Rudalics <rudalics@gmx.at>
parents:
76876
diff
changeset
|
535 start-event-window))))) |
101722
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
536 (set-window-configuration wconfig))))) |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
537 |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
538 ;; Presumably if this was just a click, the last event should |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
539 ;; be `mouse-1', whereas if this did move the mouse, it should be |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
540 ;; a `drag-mouse-1'. In any case `on-link' would have been nulled |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
541 ;; above if there had been any significant mouse movement. |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
542 (when (and on-link (eq 'mouse-1 (car-safe event))) |
c65ecdf80c27
(mouse-drag-mode-line-1): Obey mouse-1-click-follows-link.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101581
diff
changeset
|
543 (push (cons 'mouse-2 (cdr event)) unread-command-events)))))) |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
544 |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
545 (defun mouse-drag-mode-line (start-event) |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
546 "Change the height of a window by dragging on the mode line." |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
547 (interactive "e") |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
548 (mouse-drag-mode-line-1 start-event t)) |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
549 |
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
550 (defun mouse-drag-header-line (start-event) |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
551 "Change the height of a window by dragging on the header line. |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
552 Windows whose header-lines are at the top of the frame cannot be |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
553 resized by dragging their header-line." |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
554 (interactive "e") |
32207
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
555 ;; Changing the window's size by dragging its header-line when the |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
556 ;; header-line is at the top of the frame is somewhat strange, |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
557 ;; because the header-line doesn't move, so don't do it. |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
558 (let* ((start (event-start start-event)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
559 (window (posn-window start)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
560 (frame (window-frame window)) |
03dee1b8a506
(mouse-drag-header-line): Don't allow window resizing
Gerd Moellmann <gerd@gnu.org>
parents:
31923
diff
changeset
|
561 (first-window (frame-first-window frame))) |
65349
3607a394b655
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
64762
diff
changeset
|
562 (unless (or (eq window first-window) |
3607a394b655
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
64762
diff
changeset
|
563 (= (nth 1 (window-edges window)) |
3607a394b655
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
64762
diff
changeset
|
564 (nth 1 (window-edges first-window)))) |
3607a394b655
*** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents:
64762
diff
changeset
|
565 (mouse-drag-mode-line-1 start-event nil)))) |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
566 |
8519
7802e26b3bfd
(mouse-drag-mode-line): New function (from mldrag.el,
Richard M. Stallman <rms@gnu.org>
parents:
8487
diff
changeset
|
567 |
71391
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
568 (defun mouse-drag-vertical-line-rightward-window (window) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
569 "Return a window that is immediately to the right of WINDOW, or nil." |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
570 (let ((bottom (nth 3 (window-inside-edges window))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
571 (left (nth 0 (window-inside-edges window))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
572 best best-right |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
573 (try (previous-window window))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
574 (while (not (eq try window)) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
575 (let ((try-top (nth 1 (window-inside-edges try))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
576 (try-bottom (nth 3 (window-inside-edges try))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
577 (try-right (nth 2 (window-inside-edges try)))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
578 (if (and (< try-top bottom) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
579 (>= try-bottom bottom) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
580 (< try-right left) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
581 (or (null best-right) (> try-right best-right))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
582 (setq best-right try-right best try))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
583 (setq try (previous-window try))) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
584 best)) |
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
585 |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
586 (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
|
587 "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
|
588 (interactive "e") |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
589 ;; 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
|
590 (run-hooks 'mouse-leave-buffer-hook) |
20686
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
591 (let* ((done nil) |
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
592 (echo-keystrokes 0) |
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
593 (start-event-frame (window-frame (car (car (cdr start-event))))) |
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
594 (start-event-window (car (car (cdr start-event)))) |
72999
c983ed5a8049
(mouse-on-link-p): Tentatively fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72890
diff
changeset
|
595 event mouse x left right edges growth |
20686
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
596 (which-side |
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
597 (or (cdr (assq 'vertical-scroll-bars (frame-parameters start-event-frame))) |
988d8082f292
(mouse-drag-vertical-line): Properly determine which
Richard M. Stallman <rms@gnu.org>
parents:
20124
diff
changeset
|
598 'right))) |
69514
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
599 (cond |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
600 ((one-window-p t) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
601 (error "Attempt to resize sole ordinary window")) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
602 ((and (eq which-side 'right) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
603 (>= (nth 2 (window-inside-edges start-event-window)) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
604 (frame-width start-event-frame))) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
605 (error "Attempt to drag rightmost scrollbar")) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
606 ((and (eq which-side 'left) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
607 (= (nth 0 (window-inside-edges start-event-window)) 0)) |
4540a0223bcc
* mouse.el (mouse-drag-vertical-line): Use window-inside-edges
Chong Yidong <cyd@stupidchicken.com>
parents:
68858
diff
changeset
|
608 (error "Attempt to drag leftmost scrollbar"))) |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
609 (track-mouse |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
610 (progn |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
611 ;; 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
|
612 ;; the mouse. |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
613 (while (not done) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
614 (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
|
615 mouse (mouse-position)) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
616 ;; do nothing if |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
617 ;; - 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
|
618 ;; - 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
|
619 ;; - 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
|
620 ;; drag if |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
621 ;; - 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
|
622 ;; - 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
|
623 ;; (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
|
624 ;; quit if |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
625 ;; - 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
|
626 ;; unknown event. |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
627 (cond ((integerp event) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
628 (setq done t)) |
59470
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
629 ((memq (car event) '(switch-frame select-window)) |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
630 nil) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
631 ((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
|
632 '(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
|
633 (if (consp event) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
634 (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
|
635 (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
|
636 (setq done t)) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
637 ((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
|
638 nil) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
639 ((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
|
640 nil) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
641 (t |
67524
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
642 (let ((window |
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
643 ;; If the scroll bar is on the window's left, |
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
644 ;; adjust the window on the left. |
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
645 (if (eq which-side 'right) |
76293
91a6d7f7e1a7
(mouse-drag-mode-line-1, mouse-drag-vertical-line):
Richard M. Stallman <rms@gnu.org>
parents:
76155
diff
changeset
|
646 start-event-window |
71391
baf495881cff
(mouse-drag-vertical-line-rightward-window): New function.
Richard M. Stallman <rms@gnu.org>
parents:
69514
diff
changeset
|
647 (mouse-drag-vertical-line-rightward-window |
76293
91a6d7f7e1a7
(mouse-drag-mode-line-1, mouse-drag-vertical-line):
Richard M. Stallman <rms@gnu.org>
parents:
76155
diff
changeset
|
648 start-event-window)))) |
20124
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
649 (setq x (- (car (cdr mouse)) |
23854 | 650 (if (eq which-side 'right) 0 2)) |
67524
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
651 edges (window-edges window) |
20124
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
652 left (nth 0 edges) |
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
653 right (nth 2 edges)) |
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
654 ;; scale back a move that would make the |
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
655 ;; window too thin. |
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
656 (if (< (- x left -1) window-min-width) |
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
657 (setq x (+ left window-min-width -1))) |
ecae234a33bb
(mouse-drag-vertical-line): Handle left-side scroll bars.
Karl Heuer <kwzh@gnu.org>
parents:
18689
diff
changeset
|
658 ;; compute size change needed |
67524
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
659 (setq growth (- x right -1)) |
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
660 (condition-case nil |
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
661 (adjust-window-trailing-edge window growth t) |
9014ad13a926
(mouse-drag-vertical-line): Use adjust-window-trailing-edge.
Richard M. Stallman <rms@gnu.org>
parents:
67158
diff
changeset
|
662 (error nil)))))))))) |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
663 |
4554
cf541ed1fed8
(mouse-set-point): Use event-end, not event-start.
Richard M. Stallman <rms@gnu.org>
parents:
4532
diff
changeset
|
664 (defun mouse-set-point (event) |
465 | 665 "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
|
666 This should be bound to a mouse click event type." |
1113 | 667 (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
|
668 (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
|
669 ;; 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
|
670 ;; If EVENT is a click, event-end and event-start give same value. |
54867
c59162a8d0f8
(mouse-set-point): Use it.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53133
diff
changeset
|
671 (posn-set-point (event-end event))) |
66 | 672 |
10720
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
673 (defvar mouse-last-region-beg nil) |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
674 (defvar mouse-last-region-end nil) |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
675 (defvar mouse-last-region-tick nil) |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
676 |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
677 (defun mouse-region-match () |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
678 "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
|
679 (and (mark t) mark-active |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
680 (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
|
681 (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
|
682 (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
|
683 |
1420
4005f73e5712
(mouse-set-region): New command. Bind drag-mouse-1 to it.
Richard M. Stallman <rms@gnu.org>
parents:
1363
diff
changeset
|
684 (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
|
685 "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
|
686 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
|
687 (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
|
688 (mouse-minibuffer-check click) |
103893
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
689 (select-window (posn-window (event-start click))) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
690 (let ((beg (posn-point (event-start click))) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
691 (end (posn-point (event-end click)))) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
692 (and mouse-drag-copy-region (integerp beg) (integerp end) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
693 ;; Don't set this-command to `kill-region', so a following |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
694 ;; C-w won't double the text in the kill ring. Ignore |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
695 ;; `last-command' so we don't append to a preceding kill. |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
696 (let (this-command last-command deactivate-mark) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
697 (copy-region-as-kill beg end))) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
698 (if (numberp beg) (goto-char beg)) |
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
699 ;; On a text terminal, bounce the cursor. |
12078
eb9f9e9cd522
(mouse-set-region): Don't bounce the cursor on X.
Karl Heuer <kwzh@gnu.org>
parents:
11863
diff
changeset
|
700 (or transient-mark-mode |
103893
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
701 (window-system) |
2799
93a5aef19835
(mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents:
2632
diff
changeset
|
702 (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
|
703 (push-mark) |
2802
02c75b605550
(mouse-set-region): Call set-mark to activate mark.
Richard M. Stallman <rms@gnu.org>
parents:
2799
diff
changeset
|
704 (set-mark (point)) |
103893
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
705 (if (numberp end) (goto-char end)) |
10720
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
706 (mouse-set-region-1))) |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
707 |
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
708 (defun mouse-set-region-1 () |
55803
9070d5f984ea
(mouse-set-region-1): Use temporary transient-mark-mode
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55260
diff
changeset
|
709 ;; Set transient-mark-mode for a little while. |
93549
b615c4d2a14d
(mouse-set-region-1): Save the old value of transient-mark-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
93512
diff
changeset
|
710 (unless (eq (car-safe transient-mark-mode) 'only) |
b615c4d2a14d
(mouse-set-region-1): Save the old value of transient-mark-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
93512
diff
changeset
|
711 (setq transient-mark-mode |
b615c4d2a14d
(mouse-set-region-1): Save the old value of transient-mark-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
93512
diff
changeset
|
712 (cons 'only |
b615c4d2a14d
(mouse-set-region-1): Save the old value of transient-mark-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
93512
diff
changeset
|
713 (unless (eq transient-mark-mode 'lambda) |
b615c4d2a14d
(mouse-set-region-1): Save the old value of transient-mark-mode.
Chong Yidong <cyd@stupidchicken.com>
parents:
93512
diff
changeset
|
714 transient-mark-mode)))) |
10720
4526bdcc806e
(mouse-drag-region): Delete the overlay before
Richard M. Stallman <rms@gnu.org>
parents:
10556
diff
changeset
|
715 (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
|
716 (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
|
717 (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
|
718 |
17636 | 719 (defcustom mouse-scroll-delay 0.25 |
100171 | 720 "The pause between scroll steps caused by mouse drags, in seconds. |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
721 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
|
722 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
|
723 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
|
724 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
|
725 This variable's value may be non-integral. |
17636 | 726 Setting this to zero causes Emacs to scroll as fast as it can." |
727 :type 'number | |
728 :group 'mouse) | |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
729 |
17636 | 730 (defcustom mouse-scroll-min-lines 1 |
100171 | 731 "The minimum number of lines scrolled by dragging mouse out of window. |
13068
9cc4392719e3
[These changes were actually in the previous version.
Richard M. Stallman <rms@gnu.org>
parents:
13038
diff
changeset
|
732 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
|
733 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
|
734 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
|
735 the mouse has moved. However, it always scrolls at least the number |
17636 | 736 of lines specified by this variable." |
737 :type 'integer | |
738 :group 'mouse) | |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
739 |
7932
ac4b606bcfa2
(mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
7901
diff
changeset
|
740 (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
|
741 "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
|
742 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
|
743 the newly visible text. |
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
744 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
|
745 (cond |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
746 ((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
|
747 (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
|
748 ((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
|
749 (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
|
750 (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
|
751 (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
|
752 (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
|
753 (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
|
754 (progn |
76118755a179
(mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
7932
diff
changeset
|
755 (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
|
756 (if (natnump jump) |
21176
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
757 (if (window-end window) |
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
758 (progn |
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
759 (goto-char (window-end window)) |
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
760 ;; window-end doesn't reflect the window's new |
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
761 ;; start position until the next redisplay. |
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
762 (vertical-motion (1- jump) window)) |
c42a2b3bbb21
(mouse-scroll-subr): Handle if window-end returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21148
diff
changeset
|
763 (vertical-motion (- (window-height window) 2))) |
7966
76118755a179
(mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
7932
diff
changeset
|
764 (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
|
765 (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
|
766 (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
|
767 ;; 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
|
768 ;; 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
|
769 ;; 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
|
770 (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
|
771 (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
|
772 (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
|
773 (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
|
774 (goto-char opoint)))) |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
775 |
5027
38980ea73075
(mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents:
5007
diff
changeset
|
776 (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
|
777 |
12436
ffd777dc7d29
(mouse-selection-click-count-buffer): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
12357
diff
changeset
|
778 (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
|
779 |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
780 (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
|
781 "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
|
782 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
|
783 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
|
784 In Transient Mark mode, the highlighting remains as long as the mark |
42806
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
785 remains active. Otherwise, it remains until the next input event. |
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
786 |
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
787 If the click is in the echo area, display the `*Messages*' buffer." |
3566
dc2b64ef30dc
(mouse-drag-region-1): Un-comment-out this function.
Richard M. Stallman <rms@gnu.org>
parents:
3420
diff
changeset
|
788 (interactive "e") |
59470
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
789 (let ((w (posn-window (event-start start-event)))) |
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
790 (if (and (window-minibuffer-p w) |
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
791 (not (minibuffer-window-active-p w))) |
42806
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
792 (save-excursion |
59526 | 793 ;; Swallow the up-event. |
42806
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
794 (read-event) |
66322
e921fbeaaddb
2005-10-23 MIYOSHI Masanori <miyoshi@meadowy.org> (tiny change)
Romain Francoise <romain@orebokech.com>
parents:
66180
diff
changeset
|
795 (set-buffer (get-buffer-create "*Messages*")) |
42806
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
796 (goto-char (point-max)) |
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
797 (display-buffer (current-buffer))) |
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
798 ;; Give temporary modes such as isearch a chance to turn off. |
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
799 (run-hooks 'mouse-leave-buffer-hook) |
67997
217b260efd66
(mouse-drag-track): Renamed, from `mouse-drag-region-1'. Includes
J.D. Smith <jdsmith@as.arizona.edu>
parents:
67965
diff
changeset
|
800 (mouse-drag-track start-event t)))) |
42806
7ec99458ed2e
(mouse-drag-region-1): Renamed from mouse-drag-region.
Richard M. Stallman <rms@gnu.org>
parents:
42399
diff
changeset
|
801 |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
802 |
72890
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
803 (defun mouse-posn-property (pos property) |
73006
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
804 "Look for a property at click position. |
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
805 POS may be either a buffer position or a click position like |
73042
f4f55aa95877
(mouse-posn-property): Fix typo for `event-start' in
David Kastrup <dak@gnu.org>
parents:
73006
diff
changeset
|
806 those returned from `event-start'. If the click position is on |
73006
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
807 a string, the text property PROPERTY is examined. |
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
808 If this is nil or the click is not on a string, then |
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
809 the corresponding buffer position is searched for PROPERTY. |
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
810 If PROPERTY is encountered in one of those places, |
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
811 its value is returned." |
72890
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
812 (if (consp pos) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
813 (let ((w (posn-window pos)) (pt (posn-point pos)) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
814 (str (posn-string pos))) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
815 (or (and str |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
816 (get-text-property (cdr str) property (car str))) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
817 (and pt |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
818 (get-char-property pt property w)))) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
819 (get-char-property pos property))) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
820 |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
821 (defun mouse-on-link-p (pos) |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
822 "Return non-nil if POS is on a link in the current buffer. |
72077
e345212112f0
(mouse-on-link-p): Doc fix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71391
diff
changeset
|
823 POS must be a buffer position in the current buffer or a mouse |
e345212112f0
(mouse-on-link-p): Doc fix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71391
diff
changeset
|
824 event location in the selected window (see `event-start'). |
60253
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
825 However, if `mouse-1-click-in-non-selected-windows' is non-nil, |
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
826 POS may be a mouse event location in any window. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
827 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
828 A clickable link is identified by one of the following methods: |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
829 |
59500 | 830 - If the character at POS has a non-nil `follow-link' text or |
61376
15f4c9e1a9b2
(mouse-on-link-p): Tiny doc fix.
Kim F. Storm <storm@cua.dk>
parents:
61160
diff
changeset
|
831 overlay property, the value of that property determines what to do. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
832 |
59500 | 833 - If there is a local key-binding or a keybinding at position POS |
834 for the `follow-link' event, the binding of that event determines | |
835 what to do. | |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
836 |
59500 | 837 The resulting value determine whether POS is inside a link: |
838 | |
839 - If the value is `mouse-face', POS is inside a link if there | |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
840 is a non-nil `mouse-face' property at POS. Return t in this case. |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
841 |
59500 | 842 - If the value is a function, FUNC, POS is inside a link if |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
843 the call \(FUNC POS) returns non-nil. Return the return value |
72077
e345212112f0
(mouse-on-link-p): Doc fix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
71391
diff
changeset
|
844 from that call. Arg is \(posn-point POS) if POS is a mouse event. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
845 |
59500 | 846 - Otherwise, return the value itself. |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
847 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
848 The return value is interpreted as follows: |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
849 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
850 - If it is a string, the mouse-1 event is translated into the |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
851 first character of the string, i.e. the action of the mouse-1 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
852 click is the local or global binding of that character. |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
853 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
854 - If it is a vector, the mouse-1 event is translated into the |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
855 first element of that vector, i.e. the action of the mouse-1 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
856 click is the local or global binding of that event. |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
857 |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
858 - Otherwise, the mouse-1 event is translated into a mouse-2 event |
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
859 at the same position." |
72890
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
860 (let ((action |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
861 (and (or (not (consp pos)) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
862 mouse-1-click-in-non-selected-windows |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
863 (eq (selected-window) (posn-window pos))) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
864 (or (mouse-posn-property pos 'follow-link) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
865 (key-binding [follow-link] nil t pos))))) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
866 (cond |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
867 ((eq action 'mouse-face) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
868 (and (mouse-posn-property pos 'mouse-face) t)) |
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
869 ((functionp action) |
73006
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
870 ;; FIXME: This seems questionable if the click is not in a buffer. |
72999
c983ed5a8049
(mouse-on-link-p): Tentatively fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72890
diff
changeset
|
871 ;; Should we instead decide that `action' takes a `posn'? |
73006
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
872 (if (consp pos) |
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
873 (with-current-buffer (window-buffer (posn-window pos)) |
73755
ef7b62d477fd
(mouse-set-font): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
73042
diff
changeset
|
874 (funcall action (posn-point pos))) |
73006
17ac31b82912
(mouse-posn-property): Improve doc string.
David Kastrup <dak@gnu.org>
parents:
72999
diff
changeset
|
875 (funcall action pos))) |
72890
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
876 (t action)))) |
60204
074d6632232c
(mouse-on-link-p): If arg POS is a mouse event,
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
877 |
61160
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
878 (defun mouse-fixup-help-message (msg) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
879 "Fix help message MSG for `mouse-1-click-follows-link'." |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
880 (let (mp pos) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
881 (if (and mouse-1-click-follows-link |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
882 (stringp msg) |
109605
bdba5a231521
mouse.el: Match "mouse-2" at the beginning of the string. (Bug#6765)
Juanma Barranquero <lekktu@gmail.com>
parents:
109600
diff
changeset
|
883 (string-match-p "\\`mouse-2" msg) |
61160
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
884 (setq mp (mouse-pixel-position)) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
885 (consp (setq pos (cdr mp))) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
886 (car pos) (>= (car pos) 0) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
887 (cdr pos) (>= (cdr pos) 0) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
888 (setq pos (posn-at-x-y (car pos) (cdr pos) (car mp))) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
889 (windowp (posn-window pos))) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
890 (with-current-buffer (window-buffer (posn-window pos)) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
891 (if (mouse-on-link-p pos) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
892 (setq msg (concat |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
893 (cond |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
894 ((eq mouse-1-click-follows-link 'double) "double-") |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
895 ((and (integerp mouse-1-click-follows-link) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
896 (< mouse-1-click-follows-link 0)) "Long ") |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
897 (t "")) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
898 "mouse-1" (substring msg 7))))))) |
2bc2e06d78aa
(mouse-1-click-follows-link): Increase to 450 ms.
Kim F. Storm <storm@cua.dk>
parents:
60253
diff
changeset
|
899 msg) |
59016
1c959d343308
(mouse-1-click-follows-link): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
58837
diff
changeset
|
900 |
73755
ef7b62d477fd
(mouse-set-font): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
73042
diff
changeset
|
901 (defun mouse-drag-track (start-event &optional |
67997
217b260efd66
(mouse-drag-track): Renamed, from `mouse-drag-region-1'. Includes
J.D. Smith <jdsmith@as.arizona.edu>
parents:
67965
diff
changeset
|
902 do-mouse-drag-region-post-process) |
217b260efd66
(mouse-drag-track): Renamed, from `mouse-drag-region-1'. Includes
J.D. Smith <jdsmith@as.arizona.edu>
parents:
67965
diff
changeset
|
903 "Track mouse drags by highlighting area between point and cursor. |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
904 The region will be defined with mark and point. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
905 DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
906 `mouse-drag-region'." |
6266
66c0ed95c03f
(mouse-minibuffer-check): New function to disallow mouse events in an inactive
Karl Heuer <kwzh@gnu.org>
parents:
6231
diff
changeset
|
907 (mouse-minibuffer-check start-event) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
908 (setq mouse-selection-click-count-buffer (current-buffer)) |
103947
37177e1f2fcb
* w32-fns.el (x-selection-owner-p): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
103893
diff
changeset
|
909 (deactivate-mark) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
910 (let* ((original-window (selected-window)) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
911 ;; We've recorded what we needed from the current buffer and |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
912 ;; window, now let's jump to the place of the event, where things |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
913 ;; are happening. |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
914 (_ (mouse-set-point start-event)) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
915 (echo-keystrokes 0) |
14179
7db5b89b78b6
(mouse-drag-region, mouse-drag-secondary): Bind echo-keystrokes to 0.
Richard M. Stallman <rms@gnu.org>
parents:
13872
diff
changeset
|
916 (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
|
917 (start-point (posn-point start-posn)) |
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
918 (start-window (posn-window start-posn)) |
41034
edd3baa8e385
(mouse-drag-region): Don't run the up-event
Richard M. Stallman <rms@gnu.org>
parents:
41033
diff
changeset
|
919 (start-window-start (window-start start-window)) |
28075
7421de9165d2
(mouse-drag-region): Don't run up-event handler
Gerd Moellmann <gerd@gnu.org>
parents:
27834
diff
changeset
|
920 (start-hscroll (window-hscroll start-window)) |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
921 (bounds (window-edges start-window)) |
58194
00222ee714ca
(mouse-drag-copy-region): Add :version.
Kim F. Storm <storm@cua.dk>
parents:
57927
diff
changeset
|
922 (make-cursor-line-fully-visible nil) |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
923 (top (nth 1 bounds)) |
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
924 (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
|
925 (nth 3 bounds) |
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
926 ;; 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
|
927 (1- (nth 3 bounds)))) |
60204
074d6632232c
(mouse-on-link-p): If arg POS is a mouse event,
Kim F. Storm <storm@cua.dk>
parents:
59996
diff
changeset
|
928 (on-link (and mouse-1-click-follows-link |
60253
6452fdddef8f
(mouse-1-click-in-non-selected-windows): New defcustom.
Kim F. Storm <storm@cua.dk>
parents:
60204
diff
changeset
|
929 (or mouse-1-click-in-non-selected-windows |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
930 (eq start-window original-window)) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
931 ;; Use start-point before the intangibility |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
932 ;; treatment, in case we click on a link inside an |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
933 ;; intangible text. |
72890
5ba1cd1da822
* mouse-sel.el (mouse-sel-follow-link-p): Use event position
David Kastrup <dak@gnu.org>
parents:
72427
diff
changeset
|
934 (mouse-on-link-p start-posn))) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
935 (click-count (1- (event-click-count start-event))) |
109719
472b3dda3de7
Fix 2010-07-03 change to mouse-drag-track.
Chong Yidong <cyd@stupidchicken.com>
parents:
109678
diff
changeset
|
936 (remap-double-click (and on-link |
472b3dda3de7
Fix 2010-07-03 change to mouse-drag-track.
Chong Yidong <cyd@stupidchicken.com>
parents:
109678
diff
changeset
|
937 (eq mouse-1-click-follows-link 'double) |
472b3dda3de7
Fix 2010-07-03 change to mouse-drag-track.
Chong Yidong <cyd@stupidchicken.com>
parents:
109678
diff
changeset
|
938 (= click-count 1))) |
74367
a3192cfa5e41
(mouse-drag-track): Suppress automatic hscrolling for initial down
Chong Yidong <cyd@stupidchicken.com>
parents:
74238
diff
changeset
|
939 ;; Suppress automatic hscrolling, because that is a nuisance |
a3192cfa5e41
(mouse-drag-track): Suppress automatic hscrolling for initial down
Chong Yidong <cyd@stupidchicken.com>
parents:
74238
diff
changeset
|
940 ;; when setting point near the right fringe (but see below). |
a3192cfa5e41
(mouse-drag-track): Suppress automatic hscrolling for initial down
Chong Yidong <cyd@stupidchicken.com>
parents:
74238
diff
changeset
|
941 (automatic-hscrolling-saved automatic-hscrolling) |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
942 (automatic-hscrolling nil) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
943 event end end-point) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
944 |
4751
c63ce262aa4d
(mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents:
4738
diff
changeset
|
945 (setq mouse-selection-click-count click-count) |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
946 ;; 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
|
947 ;; 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
|
948 (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
|
949 (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
|
950 (setq start-point (point)) |
109719
472b3dda3de7
Fix 2010-07-03 change to mouse-drag-track.
Chong Yidong <cyd@stupidchicken.com>
parents:
109678
diff
changeset
|
951 (if remap-double-click |
472b3dda3de7
Fix 2010-07-03 change to mouse-drag-track.
Chong Yidong <cyd@stupidchicken.com>
parents:
109678
diff
changeset
|
952 (setq click-count 0)) |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
953 |
109146
6b22e0739484
Fix multi-click selection behavior (Bug#6565).
Chong Yidong <cyd@stupidchicken.com>
parents:
109112
diff
changeset
|
954 ;; Activate the region, using `mouse-start-end' to determine where |
6b22e0739484
Fix multi-click selection behavior (Bug#6565).
Chong Yidong <cyd@stupidchicken.com>
parents:
109112
diff
changeset
|
955 ;; to put point and mark (e.g., double-click will select a word). |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
956 (setq transient-mark-mode |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
957 (if (eq transient-mark-mode 'lambda) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
958 '(only) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
959 (cons 'only transient-mark-mode))) |
109678
14830418f9fc
Change `select-active-region' mechanics.
Chong Yidong <cyd@stupidchicken.com>
parents:
109605
diff
changeset
|
960 (let ((range (mouse-start-end start-point start-point click-count))) |
109801
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
961 (push-mark (nth 0 range) t t) |
109146
6b22e0739484
Fix multi-click selection behavior (Bug#6565).
Chong Yidong <cyd@stupidchicken.com>
parents:
109112
diff
changeset
|
962 (goto-char (nth 1 range))) |
3961
e828d5f28ca2
* mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents:
3928
diff
changeset
|
963 |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
964 ;; Track the mouse until we get a non-movement event. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
965 (track-mouse |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
966 (while (progn |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
967 (setq event (read-event)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
968 (or (mouse-movement-p event) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
969 (memq (car-safe event) '(switch-frame select-window)))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
970 (unless (memq (car-safe event) '(switch-frame select-window)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
971 ;; Automatic hscrolling did not occur during the call to |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
972 ;; `read-event'; but if the user subsequently drags the |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
973 ;; mouse, go ahead and hscroll. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
974 (let ((automatic-hscrolling automatic-hscrolling-saved)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
975 (redisplay)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
976 (setq end (event-end event) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
977 end-point (posn-point end)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
978 (if (and (eq (posn-window end) start-window) |
3961
e828d5f28ca2
* mouse.el (mouse-drag-region): Correctly handle drags which enter
Jim Blandy <jimb@redhat.com>
parents:
3928
diff
changeset
|
979 (integer-or-marker-p end-point)) |
109801
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
980 (mouse--drag-set-mark-and-point start-point |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
981 end-point click-count) |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
982 (let ((mouse-row (cdr (cdr (mouse-position))))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
983 (cond |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
984 ((null mouse-row)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
985 ((< mouse-row top) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
986 (mouse-scroll-subr start-window (- mouse-row top) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
987 nil start-point)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
988 ((>= mouse-row bottom) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
989 (mouse-scroll-subr start-window (1+ (- mouse-row bottom)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
990 nil start-point)))))))) |
23611
4c8718a0fb85
(mouse-drag-region): Fake up a mouse-motion event
Richard M. Stallman <rms@gnu.org>
parents:
22852
diff
changeset
|
991 |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
992 ;; Handle the terminating event if possible. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
993 (when (consp event) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
994 ;; Ensure that point is on the end of the last event. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
995 (when (and (setq end-point (posn-point (event-end event))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
996 (eq (posn-window end) start-window) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
997 (integer-or-marker-p end-point) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
998 (/= start-point end-point)) |
109801
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
999 (mouse--drag-set-mark-and-point start-point |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1000 end-point click-count)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1001 |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1002 ;; Find its binding. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1003 (let* ((fun (key-binding (vector (car event)))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1004 (do-multi-click (and (> (event-click-count event) 0) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1005 (functionp fun) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1006 (not (memq fun '(mouse-set-point |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1007 mouse-set-region)))))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1008 (if (and (/= (mark) (point)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1009 (not do-multi-click)) |
109322
02b388bb2a4b
* mouse.el (mouse-drag-track): Handle select-active-regions (Bug#6612).
Chong Yidong <cyd@stupidchicken.com>
parents:
109302
diff
changeset
|
1010 |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1011 ;; If point has moved, finish the drag. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1012 (let* (last-command this-command) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1013 (and mouse-drag-copy-region |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1014 do-mouse-drag-region-post-process |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1015 (let (deactivate-mark) |
109678
14830418f9fc
Change `select-active-region' mechanics.
Chong Yidong <cyd@stupidchicken.com>
parents:
109605
diff
changeset
|
1016 (copy-region-as-kill (mark) (point))))) |
109322
02b388bb2a4b
* mouse.el (mouse-drag-track): Handle select-active-regions (Bug#6612).
Chong Yidong <cyd@stupidchicken.com>
parents:
109302
diff
changeset
|
1017 |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1018 ;; If point hasn't moved, run the binding of the |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1019 ;; terminating up-event. |
109146
6b22e0739484
Fix multi-click selection behavior (Bug#6565).
Chong Yidong <cyd@stupidchicken.com>
parents:
109112
diff
changeset
|
1020 (if do-multi-click |
6b22e0739484
Fix multi-click selection behavior (Bug#6565).
Chong Yidong <cyd@stupidchicken.com>
parents:
109112
diff
changeset
|
1021 (goto-char start-point) |
109678
14830418f9fc
Change `select-active-region' mechanics.
Chong Yidong <cyd@stupidchicken.com>
parents:
109605
diff
changeset
|
1022 (deactivate-mark)) |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1023 (when (and (functionp fun) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1024 (= start-hscroll (window-hscroll start-window)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1025 ;; Don't run the up-event handler if the window |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1026 ;; start changed in a redisplay after the |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1027 ;; mouse-set-point for the down-mouse event at |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1028 ;; the beginning of this function. When the |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1029 ;; window start has changed, the up-mouse event |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1030 ;; contains a different position due to the new |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1031 ;; window contents, and point is set again. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1032 (or end-point |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1033 (= (window-start start-window) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1034 start-window-start))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1035 (when (and on-link |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1036 (= start-point (point)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1037 (mouse--remap-link-click-p start-event event)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1038 ;; If we rebind to mouse-2, reselect previous selected |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1039 ;; window, so that the mouse-2 event runs in the same |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1040 ;; situation as if user had clicked it directly. Fixes |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1041 ;; the bug reported by juri@jurta.org on 2005-12-27. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1042 (if (or (vectorp on-link) (stringp on-link)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1043 (setq event (aref on-link 0)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1044 (select-window original-window) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1045 (setcar event 'mouse-2) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1046 ;; If this mouse click has never been done by the |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1047 ;; user, it doesn't have the necessary property to be |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1048 ;; interpreted correctly. |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1049 (put 'mouse-2 'event-kind 'mouse-click))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1050 (push event unread-command-events))))))) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1051 |
109801
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1052 (defun mouse--drag-set-mark-and-point (start click click-count) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1053 (let* ((range (mouse-start-end start click click-count)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1054 (beg (nth 0 range)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1055 (end (nth 1 range))) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1056 (cond ((eq (mark) beg) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1057 (goto-char end)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1058 ((eq (mark) end) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1059 (goto-char beg)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1060 ((< click (mark)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1061 (set-mark end) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1062 (goto-char beg)) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1063 (t |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1064 (set-mark beg) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1065 (goto-char end))))) |
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1066 |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1067 (defun mouse--remap-link-click-p (start-event end-event) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1068 (or (and (eq mouse-1-click-follows-link 'double) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1069 (= (event-click-count start-event) 2)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1070 (and |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1071 (not (eq mouse-1-click-follows-link 'double)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1072 (= (event-click-count start-event) 1) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1073 (= (event-click-count end-event) 1) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1074 (or (not (integerp mouse-1-click-follows-link)) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1075 (let ((t0 (posn-timestamp (event-start start-event))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1076 (t1 (posn-timestamp (event-end end-event)))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1077 (and (integerp t0) (integerp t1) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1078 (if (> mouse-1-click-follows-link 0) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1079 (<= (- t1 t0) mouse-1-click-follows-link) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1080 (< (- t0 t1) mouse-1-click-follows-link)))))))) |
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1081 |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1082 |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1083 ;; 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
|
1084 (defun mouse-skip-word (dir) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1085 "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
|
1086 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
|
1087 (let* ((char (following-char)) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1088 (syntax (char-to-string (char-syntax char)))) |
22852
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1089 (cond ((string= syntax "w") |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1090 ;; Here, we can't use skip-syntax-forward/backward because |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1091 ;; they don't pay attention to word-separating-categories, |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1092 ;; and thus they will skip over a true word boundary. So, |
96376
c3309dba6542
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
96375
diff
changeset
|
1093 ;; we simulate the original behavior by using forward-word. |
22852
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1094 (if (< dir 0) |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1095 (if (not (looking-at "\\<")) |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1096 (forward-word -1)) |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1097 (if (or (looking-at "\\<") (not (looking-at "\\>"))) |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1098 (forward-word 1)))) |
dfb255fb91c8
(mouse-skip-word): If point is at word constituent
Kenichi Handa <handa@m17n.org>
parents:
22845
diff
changeset
|
1099 ((string= syntax " ") |
13038
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1100 (if (< dir 0) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1101 (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
|
1102 (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
|
1103 ((string= syntax "_") |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1104 (if (< dir 0) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1105 (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
|
1106 (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
|
1107 ((< dir 0) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1108 (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
|
1109 (forward-char -1))) |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1110 (t |
d07703594662
(C-down-mouse-1): Use buffer menu, not font menu.
Richard M. Stallman <rms@gnu.org>
parents:
12844
diff
changeset
|
1111 (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
|
1112 (forward-char 1)))))) |
3928
c5f9d7f928a7
* mouse.el (mouse-drag-region-1): Commented out.
Jim Blandy <jimb@redhat.com>
parents:
3899
diff
changeset
|
1113 |
4751
c63ce262aa4d
(mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents:
4738
diff
changeset
|
1114 (defun mouse-start-end (start end mode) |
66669
550c8e306cb5
Fix special handling of DEL after dragging a region:
Richard M. Stallman <rms@gnu.org>
parents:
66322
diff
changeset
|
1115 "Return a list of region bounds based on START and END according to MODE. |
52405
970694efa9b5
(mouse-popup-menubar, mouse-skip-word): Doc fix.
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
1116 If MODE is 0 then set point to (min START END), mark to (max START END). |
970694efa9b5
(mouse-popup-menubar, mouse-skip-word): Doc fix.
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
1117 If MODE is 1 then set point to start of word at (min START END), |
970694efa9b5
(mouse-popup-menubar, mouse-skip-word): Doc fix.
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
1118 mark to end of word at (max START END). |
970694efa9b5
(mouse-popup-menubar, mouse-skip-word): Doc fix.
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
1119 If MODE is 2 then do the same for lines." |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1120 (if (> start end) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1121 (let ((temp start)) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1122 (setq start end |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1123 end temp))) |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1124 (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
|
1125 (cond ((= mode 0) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1126 (list start end)) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1127 ((and (= mode 1) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1128 (= 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
|
1129 (char-after start) |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1130 (= (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
|
1131 (list start |
66aadd6ba5e6
(mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents:
5869
diff
changeset
|
1132 (save-excursion |
66aadd6ba5e6
(mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents:
5869
diff
changeset
|
1133 (goto-char start) |
66aadd6ba5e6
(mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents:
5869
diff
changeset
|
1134 (forward-sexp 1) |
66aadd6ba5e6
(mouse-start-end): For double click with START on openparen,
Richard M. Stallman <rms@gnu.org>
parents:
5869
diff
changeset
|
1135 (point)))) |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1136 ((and (= mode 1) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1137 (= 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
|
1138 (char-after start) |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1139 (= (char-syntax (char-after start)) ?\))) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
1140 (list (save-excursion |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1141 (goto-char (1+ start)) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1142 (backward-sexp 1) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1143 (point)) |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1144 (1+ start))) |
15561
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1145 ((and (= mode 1) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1146 (= start end) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1147 (char-after start) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1148 (= (char-syntax (char-after start)) ?\")) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1149 (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
|
1150 (save-excursion |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1151 (goto-char (- start 1)) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1152 (looking-at "\\s(\\|\\s \\|\\s>"))))) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1153 (if open |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1154 (list start |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1155 (save-excursion |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1156 (condition-case nil |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
1157 (progn |
15561
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1158 (goto-char start) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1159 (forward-sexp 1) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1160 (point)) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1161 (error end)))) |
16746
9d2a854bac89
(mouse-start-end): Put values in proper order,
Richard M. Stallman <rms@gnu.org>
parents:
16636
diff
changeset
|
1162 (list (save-excursion |
15561
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1163 (condition-case nil |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1164 (progn |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1165 (goto-char (1+ start)) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1166 (backward-sexp 1) |
6f50026fd1e6
(mouse-start-end): Support selecting strings by double
Richard M. Stallman <rms@gnu.org>
parents:
15476
diff
changeset
|
1167 (point)) |
16746
9d2a854bac89
(mouse-start-end): Put values in proper order,
Richard M. Stallman <rms@gnu.org>
parents:
16636
diff
changeset
|
1168 (error end))) |
9d2a854bac89
(mouse-start-end): Put values in proper order,
Richard M. Stallman <rms@gnu.org>
parents:
16636
diff
changeset
|
1169 (1+ start))))) |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1170 ((= mode 1) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1171 (list (save-excursion |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1172 (goto-char start) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1173 (mouse-skip-word -1) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1174 (point)) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1175 (save-excursion |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1176 (goto-char end) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1177 (mouse-skip-word 1) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1178 (point)))) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1179 ((= mode 2) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1180 (list (save-excursion |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1181 (goto-char start) |
109801
f4192807d8a6
Fix mouse dragging of words and lines (Bug#6840).
Chong Yidong <cyd@stupidchicken.com>
parents:
109781
diff
changeset
|
1182 (line-beginning-position 1)) |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1183 (save-excursion |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1184 (goto-char end) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1185 (forward-line 1) |
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
1186 (point)))))) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1187 |
3712
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1188 ;; Subroutine: set the mark where CLICK happened, |
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1189 ;; but don't do anything else. |
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1190 (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
|
1191 (mouse-minibuffer-check click) |
3712
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1192 (let ((posn (event-start click))) |
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1193 (select-window (posn-window posn)) |
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1194 (if (numberp (posn-point posn)) |
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1195 (push-mark (posn-point posn) t t)))) |
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1196 |
15613
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1197 (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
|
1198 (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
|
1199 (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
|
1200 (event (car last)) |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1201 (basic (event-basic-type event)) |
17983
56f88318699c
(mouse-undouble-last-event): Return nil if the event
Richard M. Stallman <rms@gnu.org>
parents:
17636
diff
changeset
|
1202 (old-modifiers (event-modifiers event)) |
56f88318699c
(mouse-undouble-last-event): Return nil if the event
Richard M. Stallman <rms@gnu.org>
parents:
17636
diff
changeset
|
1203 (modifiers (delq 'double (delq 'triple (copy-sequence old-modifiers)))) |
15613
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1204 (new |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1205 (if (consp event) |
18503
828ca7cea30f
(mouse-undouble-last-event): Use reverse, not nreverse.
Richard M. Stallman <rms@gnu.org>
parents:
18459
diff
changeset
|
1206 ;; Use reverse, not nreverse, since event-modifiers |
828ca7cea30f
(mouse-undouble-last-event): Use reverse, not nreverse.
Richard M. Stallman <rms@gnu.org>
parents:
18459
diff
changeset
|
1207 ;; does not copy the list it returns. |
18689
d11c2164a6af
(mouse-undouble-last-event): Fix gross bugs:
Richard M. Stallman <rms@gnu.org>
parents:
18675
diff
changeset
|
1208 (cons (event-convert-list (reverse (cons basic modifiers))) |
15613
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1209 (cdr event)) |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1210 event))) |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1211 (setcar last new) |
17983
56f88318699c
(mouse-undouble-last-event): Return nil if the event
Richard M. Stallman <rms@gnu.org>
parents:
17636
diff
changeset
|
1212 (if (and (not (equal modifiers old-modifiers)) |
56f88318699c
(mouse-undouble-last-event): Return nil if the event
Richard M. Stallman <rms@gnu.org>
parents:
17636
diff
changeset
|
1213 (key-binding (apply 'vector events))) |
15613
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1214 t |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1215 (setcar last event) |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1216 nil))) |
4c646bed64d0
(mouse-show-mark): In transient mark mode, delete mouse-drag-overlay.
Miles Bader <miles@gnu.org>
parents:
15561
diff
changeset
|
1217 |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
1218 ;; 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
|
1219 |
465 | 1220 (defun mouse-set-mark (click) |
1221 "Set mark at the position clicked on with the mouse. | |
1222 Display cursor at that position for a second. | |
1223 This must be bound to a mouse click." | |
1113 | 1224 (interactive "e") |
8534
a446d13c46ea
(mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents:
8519
diff
changeset
|
1225 (mouse-minibuffer-check click) |
a446d13c46ea
(mouse-set-mark): Select the window before saving point.
Richard M. Stallman <rms@gnu.org>
parents:
8519
diff
changeset
|
1226 (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
|
1227 ;; We don't use save-excursion because that preserves the mark too. |
66 | 1228 (let ((point-save (point))) |
1229 (unwind-protect | |
465 | 1230 (progn (mouse-set-point click) |
3119
0d4886af9262
(mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
2802
diff
changeset
|
1231 (push-mark nil t t) |
0d4886af9262
(mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
2802
diff
changeset
|
1232 (or transient-mark-mode |
0d4886af9262
(mouse-set-mark): Activate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
2802
diff
changeset
|
1233 (sit-for 1))) |
66 | 1234 (goto-char point-save)))) |
1235 | |
465 | 1236 (defun mouse-kill (click) |
1237 "Kill the region between point and the mouse click. | |
1238 The text is saved in the kill ring, as with \\[kill-region]." | |
1113 | 1239 (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
|
1240 (mouse-minibuffer-check click) |
6301
80e3ee8d618d
(mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents:
6266
diff
changeset
|
1241 (let* ((posn (event-start click)) |
80e3ee8d618d
(mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents:
6266
diff
changeset
|
1242 (click-posn (posn-point posn))) |
80e3ee8d618d
(mouse-kill): Select the clicked window first.
Karl Heuer <kwzh@gnu.org>
parents:
6266
diff
changeset
|
1243 (select-window (posn-window posn)) |
1039 | 1244 (if (numberp click-posn) |
1245 (kill-region (min (point) click-posn) | |
1246 (max (point) click-posn))))) | |
66 | 1247 |
705 | 1248 (defun mouse-yank-at-click (click arg) |
1249 "Insert the last stretch of killed text at the position clicked on. | |
28922
c0732e5c1f58
(mouse-yank-at-click): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents:
28075
diff
changeset
|
1250 Also move point to one end of the text thus inserted (normally the end), |
42149 | 1251 and set mark at the beginning. |
5799
13d7ce941848
(mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents:
5280
diff
changeset
|
1252 Prefix arguments are interpreted as with \\[yank]. |
13d7ce941848
(mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents:
5280
diff
changeset
|
1253 If `mouse-yank-at-point' is non-nil, insert at point |
109678
14830418f9fc
Change `select-active-region' mechanics.
Chong Yidong <cyd@stupidchicken.com>
parents:
109605
diff
changeset
|
1254 regardless of where you click." |
57843
e91b3798021f
(mouse-yank-at-click, mouse-yank-secondary): Revert
Jan Djärv <jan.h.d@swipnet.se>
parents:
57785
diff
changeset
|
1255 (interactive "e\nP") |
10258
0bcc67b3fe66
(mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents:
9936
diff
changeset
|
1256 ;; 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
|
1257 (run-hooks 'mouse-leave-buffer-hook) |
103947
37177e1f2fcb
* w32-fns.el (x-selection-owner-p): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
103893
diff
changeset
|
1258 (when select-active-regions |
37177e1f2fcb
* w32-fns.el (x-selection-owner-p): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
103893
diff
changeset
|
1259 ;; Without this, confusing things happen upon e.g. inserting into |
37177e1f2fcb
* w32-fns.el (x-selection-owner-p): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
103893
diff
changeset
|
1260 ;; the middle of an active region. |
103950 | 1261 (deactivate-mark)) |
5799
13d7ce941848
(mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents:
5280
diff
changeset
|
1262 (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
|
1263 (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
|
1264 (setq mouse-selection-click-count 0) |
705 | 1265 (yank arg)) |
1266 | |
87387
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1267 (defun mouse-yank-primary (click) |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1268 "Insert the primary selection at the position clicked on. |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1269 Move point to the end of the inserted text. |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1270 If `mouse-yank-at-point' is non-nil, insert at point |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1271 regardless of where you click." |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1272 (interactive "e") |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1273 ;; Give temporary modes such as isearch a chance to turn off. |
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1274 (run-hooks 'mouse-leave-buffer-hook) |
109965
aa6b00b4471c
Avoid clobbering primary selection when switching frames (Bug#6872).
Chong Yidong <cyd@stupidchicken.com>
parents:
109904
diff
changeset
|
1275 ;; Without this, confusing things happen upon e.g. inserting into |
aa6b00b4471c
Avoid clobbering primary selection when switching frames (Bug#6872).
Chong Yidong <cyd@stupidchicken.com>
parents:
109904
diff
changeset
|
1276 ;; the middle of an active region. |
103949
d7999ea3bbc2
* mouse.el (mouse-yank-primary): If select-active-regions is non-nil,
Chong Yidong <cyd@stupidchicken.com>
parents:
103947
diff
changeset
|
1277 (when select-active-regions |
109965
aa6b00b4471c
Avoid clobbering primary selection when switching frames (Bug#6872).
Chong Yidong <cyd@stupidchicken.com>
parents:
109904
diff
changeset
|
1278 (let (select-active-regions) |
aa6b00b4471c
Avoid clobbering primary selection when switching frames (Bug#6872).
Chong Yidong <cyd@stupidchicken.com>
parents:
109904
diff
changeset
|
1279 (deactivate-mark))) |
87387
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1280 (or mouse-yank-at-point (mouse-set-point click)) |
109781
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1281 (let ((primary |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1282 (cond |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1283 ((fboundp 'x-get-selection-value) ; MS-DOS and MS-Windows |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1284 (or (x-get-selection-value) |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1285 (x-get-selection 'PRIMARY))) |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1286 ;; FIXME: What about xterm-mouse-mode etc.? |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1287 (t |
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1288 (x-get-selection 'PRIMARY))))) |
87387
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1289 (if primary |
109552
9eac3b0c2884
* lisp/mouse.el (mouse-yank-primary, mouse-yank-secondary):
Sam Steingold <sds@gnu.org>
parents:
109456
diff
changeset
|
1290 (insert primary) |
109781
c89afd5304b0
Fix bug #6689 with mouse-2 pasting on Windows.
Eli Zaretskii <eliz@gnu.org>
parents:
109719
diff
changeset
|
1291 (error "No selection is available")))) |
87387
e73e483c5735
(mouse-yank-primary): New function (almost same as mouse-yank-secondary).
Richard M. Stallman <rms@gnu.org>
parents:
87301
diff
changeset
|
1292 |
705 | 1293 (defun mouse-kill-ring-save (click) |
465 | 1294 "Copy the region between point and the mouse click in the kill ring. |
1295 This does not delete the region; it acts like \\[kill-ring-save]." | |
1113 | 1296 (interactive "e") |
3712
9e0f49a8f967
(mouse-set-mark-fast): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3566
diff
changeset
|
1297 (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
|
1298 (let (this-command last-command) |
109112
a46a2b77a8b1
Simplify mouse-dragging implementation.
Chong Yidong <cyd@stupidchicken.com>
parents:
109062
diff
changeset
|
1299 (kill-ring-save (point) (mark t)))) |
66 | 1300 |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1301 ;; This function used to delete the text between point and the mouse |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1302 ;; whenever it was equal to the front of the kill ring, but some |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1303 ;; people found that confusing. |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1765
diff
changeset
|
1304 |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1305 ;; The position of the last invocation of `mouse-save-then-kill'. |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1765
diff
changeset
|
1306 (defvar mouse-save-then-kill-posn nil) |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1765
diff
changeset
|
1307 |
5007
8ed435ca9650
(mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents:
4906
diff
changeset
|
1308 (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
|
1309 ;; We must make our own undo boundaries |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1310 ;; 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
|
1311 (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
|
1312 (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
|
1313 ;; 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
|
1314 ;; just delete. |
38980ea73075
(mouse-save-then-kill-delete-region): Take args BEG and END.
Richard M. Stallman <rms@gnu.org>
parents:
5007
diff
changeset
|
1315 (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
|
1316 ;; 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
|
1317 ;; 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
|
1318 ;; for the first time, the undo list records that fact. |
29344
2f44841e5506
(mouse-save-then-kill-delete-region): Don't bind
Dave Love <fx@gnu.org>
parents:
28922
diff
changeset
|
1319 (let (before-change-functions after-change-functions) |
7866
44680acb5d14
(mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents:
7794
diff
changeset
|
1320 (delete-region beg |
44680acb5d14
(mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents:
7794
diff
changeset
|
1321 (+ 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
|
1322 (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
|
1323 ;; Undo that deletion--but don't change the undo list! |
29344
2f44841e5506
(mouse-save-then-kill-delete-region): Don't bind
Dave Love <fx@gnu.org>
parents:
28922
diff
changeset
|
1324 (let (before-change-functions after-change-functions) |
7866
44680acb5d14
(mouse-save-then-kill-delete-region): Turn off change hooks
Richard M. Stallman <rms@gnu.org>
parents:
7794
diff
changeset
|
1325 (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
|
1326 ;; 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
|
1327 ;; 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
|
1328 (setq buffer-undo-list t) |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1329 (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
|
1330 (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
|
1331 (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
|
1332 (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
|
1333 ;; 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
|
1334 ;; 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
|
1335 (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
|
1336 (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
|
1337 ;; 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
|
1338 (and tail |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1339 (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
|
1340 (undo-boundary)) |
4751
c63ce262aa4d
(mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents:
4738
diff
changeset
|
1341 |
1214
467833df795b
(mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents:
1113
diff
changeset
|
1342 (defun mouse-save-then-kill (click) |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1343 "Set the region according to CLICK; the second time, kill it. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1344 CLICK should be a mouse click event. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1345 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1346 If the region is inactive, activate it temporarily. Set mark at |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1347 the original point, and move point to the position of CLICK. |
4751
c63ce262aa4d
(mouse-save-then-kill): If follows a multi-click selection,
Richard M. Stallman <rms@gnu.org>
parents:
4738
diff
changeset
|
1348 |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1349 If the region is already active, adjust it. Normally, do this by |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1350 moving point or mark, whichever is closer, to CLICK. But if you |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1351 have selected whole words or lines, move point or mark to the |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1352 word or line boundary closest to CLICK instead. |
109600
52a2d97e28e4
Adapt mouse-3 behavior to recent selection changes (Bug#6701).
Chong Yidong <cyd@stupidchicken.com>
parents:
109552
diff
changeset
|
1353 |
110206
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1354 If `mouse-drag-copy-region' is non-nil, this command also saves the |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1355 new region to the kill ring (replacing the previous kill if the |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1356 previous region was just saved to the kill ring). |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1357 |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1358 If this command is called a second consecutive time with the same |
110206
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1359 CLICK position, kill the region (or delete it |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1360 if `mouse-drag-copy-region' is non-nil)" |
1214
467833df795b
(mouse-split-window-vertically): Use @.
Richard M. Stallman <rms@gnu.org>
parents:
1113
diff
changeset
|
1361 (interactive "e") |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1362 (mouse-minibuffer-check click) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1363 (let* ((posn (event-start click)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1364 (click-pt (posn-point posn)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1365 (window (posn-window posn)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1366 (buf (window-buffer window)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1367 ;; Don't let a subsequent kill command append to this one. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1368 (this-command this-command) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1369 ;; Check if the user has multi-clicked to select words/lines. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1370 (click-count |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1371 (if (and (eq mouse-selection-click-count-buffer buf) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1372 (with-current-buffer buf (mark t))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1373 mouse-selection-click-count |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1374 0))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1375 (cond |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1376 ((not (numberp click-pt)) nil) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1377 ;; If the user clicked without moving point, kill the region. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1378 ;; This also resets `mouse-selection-click-count'. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1379 ((and (eq last-command 'mouse-save-then-kill) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1380 (eq click-pt mouse-save-then-kill-posn) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1381 (eq window (selected-window))) |
110206
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1382 (if mouse-drag-copy-region |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1383 ;; Region already saved in the previous click; |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1384 ;; don't make a duplicate entry, just delete. |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1385 (delete-region (mark t) (point)) |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1386 (kill-region (mark t) (point))) |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1387 (setq mouse-selection-click-count 0) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1388 (setq mouse-save-then-kill-posn nil)) |
109600
52a2d97e28e4
Adapt mouse-3 behavior to recent selection changes (Bug#6701).
Chong Yidong <cyd@stupidchicken.com>
parents:
109552
diff
changeset
|
1389 |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1390 ;; Otherwise, if there is a suitable region, adjust it by moving |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1391 ;; one end (whichever is closer) to CLICK-PT. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1392 ((or (with-current-buffer buf (region-active-p)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1393 (and (eq window (selected-window)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1394 (mark t) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1395 (or (and (eq last-command 'mouse-save-then-kill) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1396 mouse-save-then-kill-posn) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1397 (and (memq last-command '(mouse-drag-region |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1398 mouse-set-region)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1399 (or mark-even-if-inactive |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1400 (not transient-mark-mode)))))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1401 (select-window window) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1402 (let* ((range (mouse-start-end click-pt click-pt click-count))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1403 (if (< (abs (- click-pt (mark t))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1404 (abs (- click-pt (point)))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1405 (set-mark (car range)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1406 (goto-char (nth 1 range))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1407 (setq deactivate-mark nil) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1408 (mouse-set-region-1) |
110206
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1409 (when mouse-drag-copy-region |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1410 ;; Region already copied to kill-ring once, so replace. |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1411 (kill-new (filter-buffer-substring (mark t) (point)) t)) |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1412 ;; Arrange for a repeated mouse-3 to kill the region. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1413 (setq mouse-save-then-kill-posn click-pt))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1414 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1415 ;; Otherwise, set the mark where point is and move to CLICK-PT. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1416 (t |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1417 (select-window window) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1418 (mouse-set-mark-fast click) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1419 (let ((before-scroll (with-current-buffer buf point-before-scroll))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1420 (if before-scroll (goto-char before-scroll))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1421 (exchange-point-and-mark) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1422 (mouse-set-region-1) |
110206
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1423 (when mouse-drag-copy-region |
d6519fa0a5a7
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
David De La Harpe Golden <david@harpegolden.net>
parents:
110015
diff
changeset
|
1424 (kill-new (filter-buffer-substring (mark t) (point)))) |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1425 (setq mouse-save-then-kill-posn click-pt))))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1426 |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1427 |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1428 (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
|
1429 (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
|
1430 (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
|
1431 (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
|
1432 (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
|
1433 |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1434 (defconst mouse-secondary-overlay |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1435 (let ((ol (make-overlay (point-min) (point-min)))) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1436 (delete-overlay ol) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1437 (overlay-put ol 'face 'secondary-selection) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1438 ol) |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1439 "An overlay which records the current secondary selection. |
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1440 It is deleted when there is no secondary selection.") |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1441 |
9206
06864fef4ec3
(mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8765
diff
changeset
|
1442 (defvar mouse-secondary-click-count 0) |
06864fef4ec3
(mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8765
diff
changeset
|
1443 |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1444 ;; 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
|
1445 ;; May be nil. |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1446 (defvar mouse-secondary-start nil) |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1447 |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1448 (defun mouse-start-secondary (click) |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1449 "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
|
1450 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
|
1451 and complete the secondary selection." |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1452 (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
|
1453 (mouse-minibuffer-check click) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1454 (let ((posn (event-start click))) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1455 (with-current-buffer (window-buffer (posn-window posn)) |
3823
7747dabf897f
(mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents:
3808
diff
changeset
|
1456 ;; Cancel any preexisting secondary selection. |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1457 (delete-overlay mouse-secondary-overlay) |
3823
7747dabf897f
(mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents:
3808
diff
changeset
|
1458 (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
|
1459 (progn |
7747dabf897f
(mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents:
3808
diff
changeset
|
1460 (or mouse-secondary-start |
7747dabf897f
(mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents:
3808
diff
changeset
|
1461 (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
|
1462 (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
|
1463 |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1464 (defun mouse-set-secondary (click) |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1465 "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
|
1466 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
|
1467 (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
|
1468 (mouse-minibuffer-check click) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1469 (let ((posn (event-start click)) |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1470 beg |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1471 (end (event-end click))) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1472 (with-current-buffer (window-buffer (posn-window posn)) |
3823
7747dabf897f
(mouse-secondary-save-then-kill): Don't switch windows.
Richard M. Stallman <rms@gnu.org>
parents:
3808
diff
changeset
|
1473 (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
|
1474 (setq beg (posn-point posn))) |
76876
e3994020ab84
(mouse-set-secondary): Update mouse-secondary-overlay.
Chong Yidong <cyd@stupidchicken.com>
parents:
76575
diff
changeset
|
1475 (move-overlay mouse-secondary-overlay beg (posn-point end)) |
e3994020ab84
(mouse-set-secondary): Update mouse-secondary-overlay.
Chong Yidong <cyd@stupidchicken.com>
parents:
76575
diff
changeset
|
1476 (x-set-selection |
e3994020ab84
(mouse-set-secondary): Update mouse-secondary-overlay.
Chong Yidong <cyd@stupidchicken.com>
parents:
76575
diff
changeset
|
1477 'SECONDARY |
e3994020ab84
(mouse-set-secondary): Update mouse-secondary-overlay.
Chong Yidong <cyd@stupidchicken.com>
parents:
76575
diff
changeset
|
1478 (buffer-substring (overlay-start mouse-secondary-overlay) |
e3994020ab84
(mouse-set-secondary): Update mouse-secondary-overlay.
Chong Yidong <cyd@stupidchicken.com>
parents:
76575
diff
changeset
|
1479 (overlay-end mouse-secondary-overlay)))))) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1480 |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1481 (defun mouse-drag-secondary (start-event) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1482 "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
|
1483 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
|
1484 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
|
1485 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
|
1486 (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
|
1487 (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
|
1488 (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
|
1489 (start-posn (event-start start-event)) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1490 (start-point (posn-point start-posn)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1491 (start-window (posn-window start-posn)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1492 (bounds (window-edges start-window)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1493 (top (nth 1 bounds)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1494 (bottom (if (window-minibuffer-p start-window) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1495 (nth 3 bounds) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1496 ;; Don't count the mode line. |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1497 (1- (nth 3 bounds)))) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1498 (click-count (1- (event-click-count start-event)))) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1499 (with-current-buffer (window-buffer start-window) |
9206
06864fef4ec3
(mouse-secondary-click-count): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8765
diff
changeset
|
1500 (setq mouse-secondary-click-count click-count) |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1501 (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
|
1502 ;; 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
|
1503 ;; of one word or line. |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1504 (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
|
1505 (set-marker mouse-secondary-start nil) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1506 (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
|
1507 (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
|
1508 ;; 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
|
1509 (or mouse-secondary-start |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1510 (setq mouse-secondary-start (make-marker))) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1511 (set-marker mouse-secondary-start start-point) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1512 (delete-overlay mouse-secondary-overlay)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1513 (let (event end end-point) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1514 (track-mouse |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1515 (while (progn |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1516 (setq event (read-event)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1517 (or (mouse-movement-p event) |
59470
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
1518 (memq (car-safe event) '(switch-frame select-window)))) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1519 |
59470
f009f3970cd9
(mouse-drag-mode-line-1, mouse-drag-vertical-line, mouse-drag-region)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59128
diff
changeset
|
1520 (if (memq (car-safe event) '(switch-frame select-window)) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1521 nil |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1522 (setq end (event-end event) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1523 end-point (posn-point end)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1524 (cond |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1525 ;; Are we moving within the original window? |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1526 ((and (eq (posn-window end) start-window) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1527 (integer-or-marker-p end-point)) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1528 (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
|
1529 click-count))) |
8224
1cc48bdd0c6b
(mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents:
8204
diff
changeset
|
1530 (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
|
1531 (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
|
1532 (progn |
1cc48bdd0c6b
(mouse-drag-secondary): Don't start making an overlay
Richard M. Stallman <rms@gnu.org>
parents:
8204
diff
changeset
|
1533 (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
|
1534 (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
|
1535 (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
|
1536 (t |
4a0b3a63e51e
(mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents:
7363
diff
changeset
|
1537 (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
|
1538 (cond |
4a0b3a63e51e
(mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents:
7363
diff
changeset
|
1539 ((null mouse-row)) |
4a0b3a63e51e
(mouse-drag-secondary): Handle mouse motion out of window
Richard M. Stallman <rms@gnu.org>
parents:
7363
diff
changeset
|
1540 ((< mouse-row top) |
7932
ac4b606bcfa2
(mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
7901
diff
changeset
|
1541 (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
|
1542 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
|
1543 ((>= mouse-row bottom) |
7932
ac4b606bcfa2
(mouse-scroll-subr): New arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
7901
diff
changeset
|
1544 (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
|
1545 mouse-secondary-overlay start-point))))))))) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1546 |
7966
76118755a179
(mouse-scroll-subr): Preserve point if WINDOW's not the selected window.
Richard M. Stallman <rms@gnu.org>
parents:
7932
diff
changeset
|
1547 (if (consp event) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1548 (if (marker-position mouse-secondary-start) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1549 (save-window-excursion |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1550 (delete-overlay mouse-secondary-overlay) |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1551 (x-set-selection 'SECONDARY nil) |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1552 (select-window start-window) |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1553 (save-excursion |
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1554 (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
|
1555 (sit-for 1) |
86f1da650461
(mouse-drag-secondary): Make sure to return nil
Richard M. Stallman <rms@gnu.org>
parents:
16304
diff
changeset
|
1556 nil)) |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1557 (x-set-selection |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1558 'SECONDARY |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1559 (buffer-substring (overlay-start mouse-secondary-overlay) |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1560 (overlay-end mouse-secondary-overlay))))))))) |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1561 |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1562 (defun mouse-yank-secondary (click) |
5799
13d7ce941848
(mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents:
5280
diff
changeset
|
1563 "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
|
1564 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
|
1565 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
|
1566 regardless of where you click." |
57843
e91b3798021f
(mouse-yank-at-click, mouse-yank-secondary): Revert
Jan Djärv <jan.h.d@swipnet.se>
parents:
57785
diff
changeset
|
1567 (interactive "e") |
10258
0bcc67b3fe66
(mouse-minibuffer-check, mouse-drag-mode-line)
Richard M. Stallman <rms@gnu.org>
parents:
9936
diff
changeset
|
1568 ;; 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
|
1569 (run-hooks 'mouse-leave-buffer-hook) |
5799
13d7ce941848
(mouse-yank-secondary): Do move point.
Richard M. Stallman <rms@gnu.org>
parents:
5280
diff
changeset
|
1570 (or mouse-yank-at-point (mouse-set-point click)) |
81903
3bdde0e93c76
(mouse-yank-secondary): Better error message if no secondary selection.
Richard M. Stallman <rms@gnu.org>
parents:
78126
diff
changeset
|
1571 (let ((secondary (x-get-selection 'SECONDARY))) |
3bdde0e93c76
(mouse-yank-secondary): Better error message if no secondary selection.
Richard M. Stallman <rms@gnu.org>
parents:
78126
diff
changeset
|
1572 (if secondary |
109552
9eac3b0c2884
* lisp/mouse.el (mouse-yank-primary, mouse-yank-secondary):
Sam Steingold <sds@gnu.org>
parents:
109456
diff
changeset
|
1573 (insert secondary) |
81903
3bdde0e93c76
(mouse-yank-secondary): Better error message if no secondary selection.
Richard M. Stallman <rms@gnu.org>
parents:
78126
diff
changeset
|
1574 (error "No secondary selection")))) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1575 |
5280
6a260dd9ee05
(mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents:
5198
diff
changeset
|
1576 (defun mouse-kill-secondary () |
5153
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1577 "Kill the text in the secondary selection. |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1578 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
|
1579 but it can work as either one. |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1580 |
27afcc69725a
(mouse-save-then-kill-delete-region):
Richard M. Stallman <rms@gnu.org>
parents:
5027
diff
changeset
|
1581 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
|
1582 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
|
1583 is to prevent accidents." |
5280
6a260dd9ee05
(mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents:
5198
diff
changeset
|
1584 (interactive) |
6a260dd9ee05
(mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents:
5198
diff
changeset
|
1585 (let* ((keys (this-command-keys)) |
6a260dd9ee05
(mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents:
5198
diff
changeset
|
1586 (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
|
1587 (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
|
1588 (if (listp click) |
6a260dd9ee05
(mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents:
5198
diff
changeset
|
1589 (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
|
1590 (current-buffer))) |
6a260dd9ee05
(mouse-kill-secondary): Get rid of CLICK argument.
Richard M. Stallman <rms@gnu.org>
parents:
5198
diff
changeset
|
1591 (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
|
1592 (let (this-command) |
65640
906677409870
(mouse-move-drag-overlay): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65623
diff
changeset
|
1593 (with-current-buffer (overlay-buffer mouse-secondary-overlay) |
10838
6c0dc7a8a07a
(mouse-kill-secondary): Avoid changing this-command.
Richard M. Stallman <rms@gnu.org>
parents:
10790
diff
changeset
|
1594 (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
|
1595 (overlay-end mouse-secondary-overlay)))) |
103893
c75839749e65
* simple.el (deactivate-mark): Optional argument FORCE.
Chong Yidong <cyd@stupidchicken.com>
parents:
101722
diff
changeset
|
1596 (delete-overlay mouse-secondary-overlay)) |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1597 |
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1598 (defun mouse-secondary-save-then-kill (click) |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1599 "Set the secondary selection and save it to the kill ring. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1600 The second time, kill it. CLICK should be a mouse click event. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1601 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1602 If you have not called `mouse-start-secondary' in the clicked |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1603 buffer, activate the secondary selection and set it between point |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1604 and the click position CLICK. |
4788
3182c0f7ace4
(mouse-delete-max-match): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4751
diff
changeset
|
1605 |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1606 Otherwise, adjust the bounds of the secondary selection. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1607 Normally, do this by moving its beginning or end, whichever is |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1608 closer, to CLICK. But if you have selected whole words or lines, |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1609 adjust to the word or line boundary closest to CLICK instead. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1610 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1611 If this command is called a second consecutive time with the same |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1612 CLICK position, kill the secondary selection." |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1613 (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
|
1614 (mouse-minibuffer-check click) |
109904
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1615 (let* ((posn (event-start click)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1616 (click-pt (posn-point posn)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1617 (window (posn-window posn)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1618 (buf (window-buffer window)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1619 ;; Don't let a subsequent kill command append to this one. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1620 (this-command this-command) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1621 ;; Check if the user has multi-clicked to select words/lines. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1622 (click-count |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1623 (if (eq (overlay-buffer mouse-secondary-overlay) buf) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1624 mouse-secondary-click-count |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1625 0)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1626 (beg (overlay-start mouse-secondary-overlay)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1627 (end (overlay-end mouse-secondary-overlay))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1628 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1629 (cond |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1630 ((not (numberp click-pt)) nil) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1631 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1632 ;; If the secondary selection is not active in BUF, activate it. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1633 ((not (eq buf (or (overlay-buffer mouse-secondary-overlay) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1634 (if mouse-secondary-start |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1635 (marker-buffer mouse-secondary-start))))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1636 (select-window window) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1637 (setq mouse-secondary-start (make-marker)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1638 (move-marker mouse-secondary-start (point)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1639 (move-overlay mouse-secondary-overlay (point) click-pt buf) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1640 (kill-ring-save (point) click-pt)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1641 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1642 ;; If the user clicked without moving point, delete the secondary |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1643 ;; selection. This also resets `mouse-secondary-click-count'. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1644 ((and (eq last-command 'mouse-secondary-save-then-kill) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1645 (eq click-pt mouse-save-then-kill-posn) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1646 (eq window (selected-window))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1647 (mouse-save-then-kill-delete-region beg end) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1648 (delete-overlay mouse-secondary-overlay) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1649 (setq mouse-secondary-click-count 0) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1650 (setq mouse-save-then-kill-posn nil)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1651 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1652 ;; Otherwise, if there is a suitable secondary selection overlay, |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1653 ;; adjust it by moving one end (whichever is closer) to CLICK-PT. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1654 ((and beg (eq buf (overlay-buffer mouse-secondary-overlay))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1655 (let* ((range (mouse-start-end click-pt click-pt click-count))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1656 (if (< (abs (- click-pt beg)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1657 (abs (- click-pt end))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1658 (move-overlay mouse-secondary-overlay (car range) end) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1659 (move-overlay mouse-secondary-overlay beg (nth 1 range)))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1660 (setq deactivate-mark nil) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1661 (if (eq last-command 'mouse-secondary-save-then-kill) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1662 ;; If the front of the kill ring comes from an immediately |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1663 ;; previous use of this command, replace the entry. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1664 (kill-new |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1665 (buffer-substring (overlay-start mouse-secondary-overlay) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1666 (overlay-end mouse-secondary-overlay)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1667 t) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1668 (let (deactivate-mark) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1669 (copy-region-as-kill (overlay-start mouse-secondary-overlay) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1670 (overlay-end mouse-secondary-overlay)))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1671 (setq mouse-save-then-kill-posn click-pt)) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1672 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1673 ;; Otherwise, set the secondary selection overlay. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1674 (t |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1675 (select-window window) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1676 (if mouse-secondary-start |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1677 ;; All we have is one end of a selection, so put the other |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1678 ;; end here. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1679 (let ((start (+ 0 mouse-secondary-start))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1680 (kill-ring-save start click-pt) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1681 (move-overlay mouse-secondary-overlay start click-pt))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1682 (setq mouse-save-then-kill-posn click-pt)))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1683 |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1684 ;; Finally, set the window system's secondary selection. |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1685 (let (str) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1686 (and (overlay-buffer mouse-secondary-overlay) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1687 (setq str (buffer-substring (overlay-start mouse-secondary-overlay) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1688 (overlay-end mouse-secondary-overlay))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1689 (> (length str) 0) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1690 (x-set-selection 'SECONDARY str)))) |
bb6ea55bfdc0
Cleanups and fixes for mouse-save-then-kill and mouse-secondary-save-then-kill.
Chong Yidong <cyd@stupidchicken.com>
parents:
109801
diff
changeset
|
1691 |
3808
d852157f581a
(mouse-start-secondary): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3712
diff
changeset
|
1692 |
21148
bbbd345f54de
(mouse-buffer-menu-maxlen): Renamed from mouse-menu-buffer-maxlen.
Richard M. Stallman <rms@gnu.org>
parents:
20686
diff
changeset
|
1693 (defcustom mouse-buffer-menu-maxlen 20 |
100171 | 1694 "Number of buffers in one pane (submenu) of the buffer menu. |
13872
e79f2b570509
(mouse-menu-buffer-maxlen): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13870
diff
changeset
|
1695 If we have lots of buffers, divide them into groups of |
21148
bbbd345f54de
(mouse-buffer-menu-maxlen): Renamed from mouse-menu-buffer-maxlen.
Richard M. Stallman <rms@gnu.org>
parents:
20686
diff
changeset
|
1696 `mouse-buffer-menu-maxlen' and make a pane (or submenu) for each one." |
17636 | 1697 :type 'integer |
1698 :group 'mouse) | |
13872
e79f2b570509
(mouse-menu-buffer-maxlen): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13870
diff
changeset
|
1699 |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1700 (defcustom mouse-buffer-menu-mode-mult 4 |
100171 | 1701 "Group the buffers by the major mode groups on \\[mouse-buffer-menu]? |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1702 This number which determines (in a hairy way) whether \\[mouse-buffer-menu] |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1703 will split the buffer menu by the major modes (see |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1704 `mouse-buffer-menu-mode-groups') or just by menu length. |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1705 Set to 1 (or even 0!) if you want to group by major mode always, and to |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1706 a large number if you prefer a mixed multitude. The default is 4." |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1707 :type 'integer |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1708 :group 'mouse |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1709 :version "20.3") |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1710 |
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
|
1711 (defvar mouse-buffer-menu-mode-groups |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1712 (mapcar (lambda (arg) (cons (purecopy (car arg)) (purecopy (cdr arg)))) |
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
|
1713 '(("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
|
1714 ("\\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
|
1715 . "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
|
1716 ("\\<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
|
1717 ("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
|
1718 ("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
|
1719 ("Outline" . "Text") |
40379
00827567d7bd
(mouse-buffer-menu-mode-groups): added SGML group
Sam Steingold <sds@gnu.org>
parents:
40268
diff
changeset
|
1720 ("\\(HT\\|SG\\|X\\|XHT\\)ML" . "SGML") |
99491
0424deda6873
(mouse-buffer-menu-mode-groups): Place "Annotate" into
Sam Steingold <sds@gnu.org>
parents:
98483
diff
changeset
|
1721 ("log\\|diff\\|vc\\|cvs\\|Annotate" . "Version Control") ; "Change Management"? |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1722 ("Lisp" . "Lisp"))) |
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
|
1723 "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
|
1724 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
|
1725 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
|
1726 |
1056
a7fc54083464
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1039
diff
changeset
|
1727 (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
|
1728 "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
|
1729 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
|
1730 and selects that window." |
1113 | 1731 (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
|
1732 (mouse-minibuffer-check event) |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1733 (let ((buffers (buffer-list)) alist menu split-by-major-mode sum-of-squares) |
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
|
1734 ;; Make an alist of elements that look like (MENU-ITEM . BUFFER). |
82298
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1735 (dolist (buf buffers) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1736 ;; Divide all buffers into buckets for various major modes. |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1737 ;; Each bucket looks like (MODE NAMESTRING BUFFERS...). |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1738 (with-current-buffer buf |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1739 (let* ((adjusted-major-mode major-mode) elt) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1740 (dolist (group mouse-buffer-menu-mode-groups) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1741 (when (string-match (car group) (format-mode-line mode-name)) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1742 (setq adjusted-major-mode (cdr group)))) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1743 (setq elt (assoc adjusted-major-mode split-by-major-mode)) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1744 (unless elt |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1745 (setq elt (list adjusted-major-mode |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1746 (if (stringp adjusted-major-mode) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1747 adjusted-major-mode |
87567
4c3c683cdff8
* erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87387
diff
changeset
|
1748 (format-mode-line mode-name nil nil buf))) |
82298
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1749 split-by-major-mode (cons elt split-by-major-mode))) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1750 (or (memq buf (cdr (cdr elt))) |
0b0e460b400a
(mouse-buffer-menu): Pass mode-name through format-mode-line because it
Sam Steingold <sds@gnu.org>
parents:
82140
diff
changeset
|
1751 (setcdr (cdr elt) (cons buf (cdr (cdr elt)))))))) |
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
|
1752 ;; 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
|
1753 (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
|
1754 (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
|
1755 (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
|
1756 (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
|
1757 (+ sum-of-squares |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1758 (let ((len (length (cdr (cdr (car tail)))))) (* len len)))) |
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
|
1759 (setq tail (cdr tail)))) |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1760 (if (< (* sum-of-squares mouse-buffer-menu-mode-mult) |
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1761 (* (length buffers) (length buffers))) |
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
|
1762 ;; 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
|
1763 (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
|
1764 ;; 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
|
1765 (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
|
1766 (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
|
1767 (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
|
1768 (> (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
|
1769 ;; 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
|
1770 ;; 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
|
1771 ;; 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
|
1772 (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
|
1773 (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
|
1774 (> (* buffers-left 10) (length buffers)))) |
38982
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1775 (let ((this-mode-list (mouse-buffer-menu-alist |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1776 (cdr (cdr (car split-by-major-mode)))))) |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1777 (and this-mode-list |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1778 (setq subdivided-menus |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1779 (cons (cons |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1780 (nth 1 (car split-by-major-mode)) |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1781 this-mode-list) |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1782 subdivided-menus)))) |
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
|
1783 (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
|
1784 (- 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
|
1785 (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
|
1786 ;; 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
|
1787 ;; 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
|
1788 (if split-by-major-mode |
38982
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1789 (let ((others-list |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1790 (mouse-buffer-menu-alist |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1791 ;; we don't need split-by-major-mode any more, |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1792 ;; so we can ditch it with nconc. |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1793 (apply 'nconc (mapcar 'cddr split-by-major-mode))))) |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1794 (and others-list |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1795 (setq subdivided-menus |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1796 (cons (cons "Others" others-list) |
f12d1ec614e9
(mouse-buffer-menu): If the buffer menu is split by
Eli Zaretskii <eliz@gnu.org>
parents:
38763
diff
changeset
|
1797 subdivided-menus))))) |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1798 (setq menu (cons "Buffer Menu" (nreverse subdivided-menus)))) |
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
|
1799 (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
|
1800 (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
|
1801 (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
|
1802 (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
|
1803 (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
|
1804 (window (posn-window (event-start event)))) |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1805 (when buf |
41033
0701d564260d
(mouse-show-mark): Either move point to the mark
Richard M. Stallman <rms@gnu.org>
parents:
40648
diff
changeset
|
1806 (select-window |
0701d564260d
(mouse-show-mark): Either move point to the mark
Richard M. Stallman <rms@gnu.org>
parents:
40648
diff
changeset
|
1807 (if (framep window) (frame-selected-window window) |
0701d564260d
(mouse-show-mark): Either move point to the mark
Richard M. Stallman <rms@gnu.org>
parents:
40648
diff
changeset
|
1808 window)) |
21685
b0ae6e29c252
(mouse-buffer-menu-mode-mult): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21426
diff
changeset
|
1809 (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
|
1810 |
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
|
1811 (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
|
1812 (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
|
1813 (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
|
1814 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
|
1815 (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
|
1816 (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
|
1817 (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
|
1818 (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
|
1819 (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
|
1820 (while tail |
63849
91ca3ff1b216
(mouse-buffer-menu-alist): Change space constants followed by a sexp to "?\s ".
Juanma Barranquero <lekktu@gmail.com>
parents:
63256
diff
changeset
|
1821 (or (eq ?\s (aref (buffer-name (car tail)) 0)) |
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
|
1822 (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
|
1823 (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
|
1824 (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
|
1825 (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
|
1826 (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
|
1827 (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
|
1828 (let ((elt (car tail))) |
74238
1901989292d8
(mouse-popup-menubar, mouse-buffer-menu-alist): "?\ " -> "?\s".
Juanma Barranquero <lekktu@gmail.com>
parents:
74024
diff
changeset
|
1829 (if (/= (aref (buffer-name elt) 0) ?\s) |
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
|
1830 (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
|
1831 (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
|
1832 (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
|
1833 (format |
79542
2a2eddb0058b
(mouse-buffer-menu-alist): Keep buffer names left aligned.
Jason Rumney <jasonr@gnu.org>
parents:
78236
diff
changeset
|
1834 (format "%%-%ds %%s%%s %%s" maxlen) |
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
|
1835 (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
|
1836 (if (buffer-modified-p elt) "*" " ") |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1837 (with-current-buffer elt |
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
|
1838 (if buffer-read-only "%" " ")) |
40268
3b6c70f1fe6c
(mouse-buffer-menu-mode-groups): Added "Version Control" group.
Sam Steingold <sds@gnu.org>
parents:
38982
diff
changeset
|
1839 (or (buffer-file-name elt) |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1840 (with-current-buffer elt |
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
|
1841 (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
|
1842 (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
|
1843 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
|
1844 "")) |
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
|
1845 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
|
1846 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
|
1847 (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
|
1848 ;; 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
|
1849 (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
|
1850 |
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
|
1851 (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
|
1852 ;; 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
|
1853 ;; and make a pane (or submenu) for each one. |
21148
bbbd345f54de
(mouse-buffer-menu-maxlen): Renamed from mouse-menu-buffer-maxlen.
Richard M. Stallman <rms@gnu.org>
parents:
20686
diff
changeset
|
1854 (if (> (length alist) (/ (* mouse-buffer-menu-maxlen 3) 2)) |
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
|
1855 (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
|
1856 (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
|
1857 (while alist |
21148
bbbd345f54de
(mouse-buffer-menu-maxlen): Renamed from mouse-menu-buffer-maxlen.
Richard M. Stallman <rms@gnu.org>
parents:
20686
diff
changeset
|
1858 ;; Pull off the next mouse-buffer-menu-maxlen buffers |
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
|
1859 ;; and make them the next element of sublist. |
21148
bbbd345f54de
(mouse-buffer-menu-maxlen): Renamed from mouse-menu-buffer-maxlen.
Richard M. Stallman <rms@gnu.org>
parents:
20686
diff
changeset
|
1860 (setq next (nthcdr mouse-buffer-menu-maxlen alist)) |
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
|
1861 (if next |
21148
bbbd345f54de
(mouse-buffer-menu-maxlen): Renamed from mouse-menu-buffer-maxlen.
Richard M. Stallman <rms@gnu.org>
parents:
20686
diff
changeset
|
1862 (setcdr (nthcdr (1- mouse-buffer-menu-maxlen) alist) |
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
|
1863 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
|
1864 (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
|
1865 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
|
1866 (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
|
1867 (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
|
1868 (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
|
1869 ;; 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
|
1870 (list (cons title alist)))) |
66 | 1871 |
105601
68686d39c93a
Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105372
diff
changeset
|
1872 (define-obsolete-function-alias |
68686d39c93a
Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105372
diff
changeset
|
1873 'mouse-choose-completion 'choose-completion "23.2") |
4081
da352b92ca90
(mouse-choose-completion): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3961
diff
changeset
|
1874 |
1100
5b3b202a84c8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1064
diff
changeset
|
1875 ;; Font selection. |
465 | 1876 |
4294
644e33e3ab38
(font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4274
diff
changeset
|
1877 (defun font-menu-add-default () |
644e33e3ab38
(font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4274
diff
changeset
|
1878 (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
|
1879 (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
|
1880 (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
|
1881 (if (assoc "Default" elt) |
644e33e3ab38
(font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4274
diff
changeset
|
1882 (delete (assoc "Default" elt) elt)) |
644e33e3ab38
(font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4274
diff
changeset
|
1883 (setcdr elt |
25547
2992a7953ac4
(font-menu-add-default): Simplify code.
Richard M. Stallman <rms@gnu.org>
parents:
25288
diff
changeset
|
1884 (cons (list "Default" default) |
4294
644e33e3ab38
(font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4274
diff
changeset
|
1885 (cdr elt))))) |
644e33e3ab38
(font-menu-add-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
4274
diff
changeset
|
1886 |
1100
5b3b202a84c8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1064
diff
changeset
|
1887 (defvar x-fixed-font-alist |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1888 (list |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1889 (purecopy "Font Menu") |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1890 (cons |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1891 (purecopy "Misc") |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1892 (mapcar |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1893 (lambda (arg) (cons (purecopy (car arg)) (purecopy (cdr arg)))) |
8460
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1894 ;; For these, we specify the pixel height and width. |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1895 '(("fixed" "fixed") |
8460
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1896 ("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
|
1897 ("6x12" |
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1898 "-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
|
1899 ("6x13" |
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1900 "-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
|
1901 ("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
|
1902 ("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
|
1903 ("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
|
1904 ("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
|
1905 ("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
|
1906 ("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
|
1907 ("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
|
1908 ("") |
8487
0a77d1dbae03
(x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents:
8477
diff
changeset
|
1909 ("clean 5x8" |
0a77d1dbae03
(x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents:
8477
diff
changeset
|
1910 "-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
|
1911 ("clean 6x8" |
0a77d1dbae03
(x-fixed-font-alist): Add clean 5x8 and clean 6x8.
Richard M. Stallman <rms@gnu.org>
parents:
8477
diff
changeset
|
1912 "-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
|
1913 ("clean 8x8" |
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1914 "-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
|
1915 ("clean 8x10" |
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1916 "-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
|
1917 ("clean 8x14" |
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1918 "-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
|
1919 ("clean 8x16" |
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1920 "-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
|
1921 ("") |
25097
65612dade7f5
(x-fixed-font-alist): Add lucidasanstypewriter.
Dave Love <fx@gnu.org>
parents:
24962
diff
changeset
|
1922 ("sony 8x16" "-sony-fixed-medium-r-normal--16-*-*-*-c-80-iso8859-1") |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1923 ;; We don't seem to have these; who knows what they are. |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1924 ;; ("fg-18" "fg-18") |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1925 ;; ("fg-25" "fg-25") |
25097
65612dade7f5
(x-fixed-font-alist): Add lucidasanstypewriter.
Dave Love <fx@gnu.org>
parents:
24962
diff
changeset
|
1926 ("lucidasanstypewriter-12" "-b&h-lucidatypewriter-medium-r-normal-sans-*-120-*-*-*-*-iso8859-1") |
65612dade7f5
(x-fixed-font-alist): Add lucidasanstypewriter.
Dave Love <fx@gnu.org>
parents:
24962
diff
changeset
|
1927 ("lucidasanstypewriter-bold-14" "-b&h-lucidatypewriter-bold-r-normal-sans-*-140-*-*-*-*-iso8859-1") |
65612dade7f5
(x-fixed-font-alist): Add lucidasanstypewriter.
Dave Love <fx@gnu.org>
parents:
24962
diff
changeset
|
1928 ("lucidasanstypewriter-bold-24" |
65612dade7f5
(x-fixed-font-alist): Add lucidasanstypewriter.
Dave Love <fx@gnu.org>
parents:
24962
diff
changeset
|
1929 "-b&h-lucidatypewriter-bold-r-normal-sans-*-240-*-*-*-*-iso8859-1") |
93512
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1930 ;; ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1") |
425b4f72a3dc
(mouse-major-mode-menu-prefix): Remove. Remove uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92046
diff
changeset
|
1931 ;; ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*") |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1932 ))) |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1933 |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1934 (cons |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1935 (purecopy "Courier") |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1936 (mapcar |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1937 (lambda (arg) (cons (purecopy (car arg)) (purecopy (cdr arg)))) |
8460
5fd799a9946e
(x-fixed-font-alist): Regularize how fonts are specified.
Richard M. Stallman <rms@gnu.org>
parents:
8426
diff
changeset
|
1938 ;; For these, we specify the point height. |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1939 '(("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1") |
3231
fb322590dda0
(x-fixed-font-alist): Specify field 7, not field 6.
Richard M. Stallman <rms@gnu.org>
parents:
3119
diff
changeset
|
1940 ("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
|
1941 ("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
|
1942 ("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
|
1943 ("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
|
1944 ("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
|
1945 ("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
|
1946 ("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
|
1947 ("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
|
1948 ("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
|
1949 ("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
|
1950 ("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
|
1951 ("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
|
1952 ("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
|
1953 ("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
|
1954 ("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
|
1955 ("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
|
1956 ("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
|
1957 ("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
|
1958 ("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
|
1959 ("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
|
1960 ("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
|
1961 ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1") |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1962 ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1") |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105601
diff
changeset
|
1963 )))) |
1100
5b3b202a84c8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1064
diff
changeset
|
1964 "X fonts suitable for use in Emacs.") |
5b3b202a84c8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1064
diff
changeset
|
1965 |
95841
b4e36ff621b3
Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents:
95788
diff
changeset
|
1966 (declare-function generate-fontset-menu "fontset" ()) |
b4e36ff621b3
Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents:
95788
diff
changeset
|
1967 |
95788
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1968 (defun mouse-select-font () |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1969 "Prompt for a font name, using `x-popup-menu', and return it." |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1970 (interactive) |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1971 (unless (display-multi-font-p) |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1972 (error "Cannot change fonts on this display")) |
101581
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1973 (car |
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1974 (x-popup-menu |
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1975 (if (listp last-nonmenu-event) |
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1976 last-nonmenu-event |
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1977 (list '(0 0) (selected-window))) |
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1978 (append x-fixed-font-alist |
c78f51452913
(mouse-select-font): Return a string instead of a list.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
1979 (list (generate-fontset-menu)))))) |
95788
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1980 |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
1981 (declare-function text-scale-mode "face-remap") |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
1982 |
6867
0f4c8109274a
(x-fixed-font-alist): Give multiple names for try for certain fonts.
Richard M. Stallman <rms@gnu.org>
parents:
6548
diff
changeset
|
1983 (defun mouse-set-font (&rest fonts) |
95788
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1984 "Set the default font for the selected frame. |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1985 The argument FONTS is a list of font names; the first valid font |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1986 in this list is used. |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1987 |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1988 When called interactively, pop up a menu and allow the user to |
4542b29082c9
(mouse-select-font): New function.
Chong Yidong <cyd@stupidchicken.com>
parents:
94678
diff
changeset
|
1989 choose a font." |
1100
5b3b202a84c8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1064
diff
changeset
|
1990 (interactive |
45570
1739a350f81c
(mouse-set-font): Avoid misleading error message if user makes no selection.
Richard M. Stallman <rms@gnu.org>
parents:
44474
diff
changeset
|
1991 (progn (unless (display-multi-font-p) |
1739a350f81c
(mouse-set-font): Avoid misleading error message if user makes no selection.
Richard M. Stallman <rms@gnu.org>
parents:
44474
diff
changeset
|
1992 (error "Cannot change fonts on this display")) |
1739a350f81c
(mouse-set-font): Avoid misleading error message if user makes no selection.
Richard M. Stallman <rms@gnu.org>
parents:
44474
diff
changeset
|
1993 (x-popup-menu |
58837
e3c6ff0922c2
(mouse-set-font): Handle the case where the command was not invoked
Luc Teirlinck <teirllm@auburn.edu>
parents:
58194
diff
changeset
|
1994 (if (listp last-nonmenu-event) |
e3c6ff0922c2
(mouse-set-font): Handle the case where the command was not invoked
Luc Teirlinck <teirllm@auburn.edu>
parents:
58194
diff
changeset
|
1995 last-nonmenu-event |
e3c6ff0922c2
(mouse-set-font): Handle the case where the command was not invoked
Luc Teirlinck <teirllm@auburn.edu>
parents:
58194
diff
changeset
|
1996 (list '(0 0) (selected-window))) |
45570
1739a350f81c
(mouse-set-font): Avoid misleading error message if user makes no selection.
Richard M. Stallman <rms@gnu.org>
parents:
44474
diff
changeset
|
1997 ;; Append list of fontsets currently defined. |
1739a350f81c
(mouse-set-font): Avoid misleading error message if user makes no selection.
Richard M. Stallman <rms@gnu.org>
parents:
44474
diff
changeset
|
1998 (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
|
1999 (if fonts |
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2000 (let (font) |
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2001 (while fonts |
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2002 (condition-case nil |
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2003 (progn |
98483
82020c1ee454
(mouse-set-font): Use set-frame-font.
Glenn Morris <rgm@gnu.org>
parents:
97422
diff
changeset
|
2004 (set-frame-font (car fonts)) |
6914
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2005 (setq font (car fonts)) |
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2006 (setq fonts nil)) |
7021
da5dc735eb50
(mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents:
6923
diff
changeset
|
2007 (error |
da5dc735eb50
(mouse-set-font): Simply call set-default-font.
Richard M. Stallman <rms@gnu.org>
parents:
6923
diff
changeset
|
2008 (setq fonts (cdr fonts))))) |
6914
569c2c6d812f
(mouse-set-font): Don't error if no selection.
Karl Heuer <kwzh@gnu.org>
parents:
6867
diff
changeset
|
2009 (if (null font) |
45570
1739a350f81c
(mouse-set-font): Avoid misleading error message if user makes no selection.
Richard M. Stallman <rms@gnu.org>
parents:
44474
diff
changeset
|
2010 (error "Font not found"))))) |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2011 |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2012 (defvar mouse-appearance-menu-map nil) |
96033 | 2013 (declare-function x-select-font "xfns.c" (&optional frame ignored)) ; USE_GTK |
96062
585941e8f7bc
(buffer-face-mode-invoke): Declare.
Glenn Morris <rgm@gnu.org>
parents:
96043
diff
changeset
|
2014 (declare-function buffer-face-mode-invoke "face-remap" |
585941e8f7bc
(buffer-face-mode-invoke): Declare.
Glenn Morris <rgm@gnu.org>
parents:
96043
diff
changeset
|
2015 (face arg &optional interactive)) |
97422
6e551caf98f6
Add declarations for builds without X.
Glenn Morris <rgm@gnu.org>
parents:
97043
diff
changeset
|
2016 (declare-function font-face-attributes "font.c" (font &optional frame)) |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2017 |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2018 (defun mouse-appearance-menu (event) |
109298
c145957f7705
Minor fix to describe-key, and a docstring.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
2019 "Show a menu for changing the default face in the current buffer." |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2020 (interactive "@e") |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2021 (require 'face-remap) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2022 (when (display-multi-font-p) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2023 (with-selected-window (car (event-start event)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2024 (if mouse-appearance-menu-map |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2025 nil ; regenerate new fonts |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2026 ;; Initialize mouse-appearance-menu-map |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2027 (setq mouse-appearance-menu-map |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2028 (make-sparse-keymap "Change Default Buffer Face")) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2029 (define-key mouse-appearance-menu-map [face-remap-reset-base] |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2030 '(menu-item "Reset to Default" face-remap-reset-base)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2031 (define-key mouse-appearance-menu-map [text-scale-decrease] |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2032 '(menu-item "Decrease Buffer Text Size" text-scale-decrease)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2033 (define-key mouse-appearance-menu-map [text-scale-increase] |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2034 '(menu-item "Increase Buffer Text Size" text-scale-increase)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2035 ;; Font selector |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2036 (if (functionp 'x-select-font) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2037 (define-key mouse-appearance-menu-map [x-select-font] |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2038 '(menu-item "Change Buffer Font..." x-select-font)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2039 ;; If the select-font is unavailable, construct a menu. |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2040 (let ((font-submenu (make-sparse-keymap "Change Text Font")) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2041 (font-alist (cdr (append x-fixed-font-alist |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2042 (list (generate-fontset-menu)))))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2043 (dolist (family font-alist) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2044 (let* ((submenu-name (car family)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2045 (submenu-map (make-sparse-keymap submenu-name))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2046 (dolist (font (cdr family)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2047 (let ((font-name (car font)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2048 font-symbol) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2049 (if (string= font-name "") |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2050 (define-key submenu-map [space] |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2051 '("--")) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2052 (setq font-symbol (intern (cadr font))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2053 (define-key submenu-map (vector font-symbol) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2054 (list 'menu-item (car font) font-symbol))))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2055 (define-key font-submenu (vector (intern submenu-name)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2056 (list 'menu-item submenu-name submenu-map)))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2057 (define-key mouse-appearance-menu-map [font-submenu] |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2058 (list 'menu-item "Change Text Font" font-submenu))))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2059 (let ((choice (x-popup-menu event mouse-appearance-menu-map))) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2060 (setq choice (nth (1- (length choice)) choice)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2061 (cond ((eq choice 'text-scale-increase) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2062 (text-scale-increase 1)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2063 ((eq choice 'text-scale-decrease) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2064 (text-scale-increase -1)) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2065 ((eq choice 'face-remap-reset-base) |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2066 (text-scale-mode 0) |
96043
a678c02d0c40
Use buffer-face-mode for mouse font menu
Miles Bader <miles@gnu.org>
parents:
96033
diff
changeset
|
2067 (buffer-face-mode 0)) |
96218
15fc1f3d8664
Handle void selection in mouse-appearance-menu
Miles Bader <miles@gnu.org>
parents:
96062
diff
changeset
|
2068 (choice |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2069 ;; Either choice == 'x-select-font, or choice is a |
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2070 ;; symbol whose name is a font. |
96043
a678c02d0c40
Use buffer-face-mode for mouse font menu
Miles Bader <miles@gnu.org>
parents:
96033
diff
changeset
|
2071 (buffer-face-mode-invoke (font-face-attributes |
a678c02d0c40
Use buffer-face-mode for mouse font menu
Miles Bader <miles@gnu.org>
parents:
96033
diff
changeset
|
2072 (if (eq choice 'x-select-font) |
a678c02d0c40
Use buffer-face-mode for mouse font menu
Miles Bader <miles@gnu.org>
parents:
96033
diff
changeset
|
2073 (x-select-font) |
a678c02d0c40
Use buffer-face-mode for mouse font menu
Miles Bader <miles@gnu.org>
parents:
96033
diff
changeset
|
2074 (symbol-name choice))) |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
105048
diff
changeset
|
2075 t |
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
105048
diff
changeset
|
2076 (called-interactively-p 'interactive)))))))) |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2077 |
465 | 2078 |
2079 ;;; Bindings for mouse commands. | |
2080 | |
2799
93a5aef19835
(mouse-drag-region): New command, on down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents:
2632
diff
changeset
|
2081 (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
|
2082 (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
|
2083 (global-set-key [drag-mouse-1] 'mouse-set-region) |
1057
d9775f33488d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1056
diff
changeset
|
2084 |
4738
76a2ea569de5
(mouse-set-region): Put region in kill ring.
Richard M. Stallman <rms@gnu.org>
parents:
4592
diff
changeset
|
2085 ;; 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
|
2086 (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
|
2087 (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
|
2088 |
53133
50717ae10f39
Bind mouse-1 on left-fringe and right-fringe to mouse-set-point so
Kim F. Storm <storm@cua.dk>
parents:
52405
diff
changeset
|
2089 ;; Clicking on the fringes causes hscrolling: |
50717ae10f39
Bind mouse-1 on left-fringe and right-fringe to mouse-set-point so
Kim F. Storm <storm@cua.dk>
parents:
52405
diff
changeset
|
2090 (global-set-key [left-fringe mouse-1] 'mouse-set-point) |
50717ae10f39
Bind mouse-1 on left-fringe and right-fringe to mouse-set-point so
Kim F. Storm <storm@cua.dk>
parents:
52405
diff
changeset
|
2091 (global-set-key [right-fringe mouse-1] 'mouse-set-point) |
50717ae10f39
Bind mouse-1 on left-fringe and right-fringe to mouse-set-point so
Kim F. Storm <storm@cua.dk>
parents:
52405
diff
changeset
|
2092 |
109398
c9970d4bfd62
Change clipboard/primary selection to X application standards.
Chong Yidong <cyd@stupidchicken.com>
parents:
109322
diff
changeset
|
2093 (global-set-key [mouse-2] 'mouse-yank-primary) |
72427
3fc22ce89bd1
(global-map): Allow yanking with mouse-2 at a spot whose
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72077
diff
changeset
|
2094 ;; Allow yanking also when the corresponding cursor is "in the fringe". |
74024
fbcf2e3cbf22
(global-map): Change 2006-08-16 fix to call mouse-yank-at-click
Chong Yidong <cyd@stupidchicken.com>
parents:
73755
diff
changeset
|
2095 (global-set-key [right-fringe mouse-2] 'mouse-yank-at-click) |
75610
e50186bf86ca
<left-fringe mouse-2, right-fringe mouse-3, left-fringe mouse-3>: New bindings.
Eli Zaretskii <eliz@gnu.org>
parents:
75430
diff
changeset
|
2096 (global-set-key [left-fringe mouse-2] 'mouse-yank-at-click) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1765
diff
changeset
|
2097 (global-set-key [mouse-3] 'mouse-save-then-kill) |
75610
e50186bf86ca
<left-fringe mouse-2, right-fringe mouse-3, left-fringe mouse-3>: New bindings.
Eli Zaretskii <eliz@gnu.org>
parents:
75430
diff
changeset
|
2098 (global-set-key [right-fringe mouse-3] 'mouse-save-then-kill) |
e50186bf86ca
<left-fringe mouse-2, right-fringe mouse-3, left-fringe mouse-3>: New bindings.
Eli Zaretskii <eliz@gnu.org>
parents:
75430
diff
changeset
|
2099 (global-set-key [left-fringe mouse-3] 'mouse-save-then-kill) |
705 | 2100 |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1765
diff
changeset
|
2101 ;; 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
|
2102 ;; 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
|
2103 (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
|
2104 (if (not (eq system-type 'ms-dos)) |
95977
d76373886395
(mouse-appearance-menu-map): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
95841
diff
changeset
|
2105 (global-set-key [S-down-mouse-1] 'mouse-appearance-menu)) |
9753
00144934b449
Put mouse-set-font on C-down-mouse-1.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2106 ;; C-down-mouse-2 is bound in facemenu.el. |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
2107 (global-set-key [C-down-mouse-3] |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105765
diff
changeset
|
2108 `(menu-item ,(purecopy "Menu Bar") ignore |
93889
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
2109 :filter (lambda (_) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
2110 (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0)) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
2111 (mouse-menu-bar-map) |
a22fbbd18c59
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93664
diff
changeset
|
2112 (mouse-menu-major-mode-map))))) |
9488
114fe3739aa3
(mouse-major-mode-menu): Use minor-mode-map-alist
Richard M. Stallman <rms@gnu.org>
parents:
9206
diff
changeset
|
2113 |
32327
140165e85530
([header-line mouse-1]): Bind to mouse-select-window.
Eli Zaretskii <eliz@gnu.org>
parents:
32319
diff
changeset
|
2114 ;; Binding mouse-1 to mouse-select-window when on mode-, header-, or |
140165e85530
([header-line mouse-1]): Bind to mouse-select-window.
Eli Zaretskii <eliz@gnu.org>
parents:
32319
diff
changeset
|
2115 ;; vertical-line prevents Emacs from signaling an error when the mouse |
140165e85530
([header-line mouse-1]): Bind to mouse-select-window.
Eli Zaretskii <eliz@gnu.org>
parents:
32319
diff
changeset
|
2116 ;; button is released after dragging these lines, on non-toolkit |
140165e85530
([header-line mouse-1]): Bind to mouse-select-window.
Eli Zaretskii <eliz@gnu.org>
parents:
32319
diff
changeset
|
2117 ;; versions. |
6090
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
2118 (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
|
2119 (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
|
2120 (global-set-key [mode-line down-mouse-1] 'mouse-drag-mode-line) |
25618
ed0f7bf2cfc7
(mouse-drag-mode-line-1): Extension of former
Gerd Moellmann <gerd@gnu.org>
parents:
25547
diff
changeset
|
2121 (global-set-key [header-line down-mouse-1] 'mouse-drag-header-line) |
32327
140165e85530
([header-line mouse-1]): Bind to mouse-select-window.
Eli Zaretskii <eliz@gnu.org>
parents:
32319
diff
changeset
|
2122 (global-set-key [header-line mouse-1] 'mouse-select-window) |
6090
e7c900a464d3
(help-menu-map): Variable deleted, and its binding.
Richard M. Stallman <rms@gnu.org>
parents:
6003
diff
changeset
|
2123 (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
|
2124 (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
|
2125 (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
|
2126 (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
|
2127 (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
|
2128 (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
|
2129 (global-set-key [vertical-line mouse-1] 'mouse-select-window) |
584 | 2130 |
2131 (provide 'mouse) | |
2132 | |
65623
fcbaf6135d19
(mouse-drag-mode-line-1, mouse-drag-vertical-line):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65498
diff
changeset
|
2133 ;; arch-tag: 9a710ce1-914a-4923-9b81-697f7bf82ab3 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2134 ;;; mouse.el ends here |