Mercurial > emacs
annotate lisp/obsolete/sun-fns.el @ 71163:b1bc5d576c4c
(EMACS): Remove quotes from the Emacs executable file name.
(emacs): Enclose the value of $(EMACS) in quotes.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 02 Jun 2006 09:48:28 +0000 |
parents | e8a3fb527b77 |
children | f7702c5f335d c5406394f567 |
rev | line source |
---|---|
39022 | 1 ;;; sun-fns.el --- subroutines of Mouse handling for Sun windows |
2 | |
68640
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65185
diff
changeset
|
3 ;; Copyright (C) 1987, 2002, 2003, 2004, 2005, |
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65185
diff
changeset
|
4 ;; 2006 Free Software Foundation, Inc. |
39022 | 5 |
6 ;; Author: Jeff Peck <peck@sun.com> | |
7 ;; Maintainer: none | |
8 ;; Keywords: hardware | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
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. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
39022 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;; Submitted Mar. 1987, Jeff Peck | |
30 ;; Sun Microsystems Inc. <peck@sun.com> | |
31 ;; Conceived Nov. 1986, Stan Jefferson, | |
32 ;; Computer Science Lab, SRI International. | |
33 ;; GoodIdeas Feb. 1987, Steve Greenbaum | |
34 ;; & UpClicks Reasoning Systems, Inc. | |
35 ;; | |
36 ;; | |
37 ;; Functions for manipulating via the mouse and mouse-map definitions | |
38 ;; for accessing them. Also definitions of mouse menus. | |
39 ;; This file you should freely modify to reflect you personal tastes. | |
40 ;; | |
41 ;; First half of file defines functions to implement mouse commands, | |
42 ;; Don't delete any of those, just add what ever else you need. | |
43 ;; Second half of file defines mouse bindings, do whatever you want there. | |
44 | |
45 ;; | |
46 ;; Mouse Functions. | |
47 ;; | |
48 ;; These functions follow the sun-mouse-handler convention of being called | |
49 ;; with three arguments: (window x-pos y-pos) | |
50 ;; This makes it easy for a mouse executed command to know where the mouse is. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
51 ;; Use the macro "eval-in-window" to execute a function |
39022 | 52 ;; in a temporarily selected window. |
53 ;; | |
54 ;; If you have a function that must be called with other arguments | |
55 ;; bind the mouse button to an s-exp that contains the necessary parameters. | |
56 ;; See "minibuffer" bindings for examples. | |
57 ;; | |
58 | |
59 ;;; Code: | |
60 | |
61 (require 'term/sun-mouse) | |
62 | |
63 (defconst cursor-pause-milliseconds 300 | |
64 "*Number of milliseconds to display alternate cursor (usually the mark)") | |
65 | |
66 (defun indicate-region (&optional pause) | |
67 "Bounce cursor to mark for cursor-pause-milliseconds and back again" | |
68 (or pause (setq pause cursor-pause-milliseconds)) | |
69 (let ((point (point))) | |
70 (goto-char (mark)) | |
71 (sit-for-millisecs pause) | |
72 ;(update-display) | |
73 ;(sleep-for-millisecs pause) | |
74 (goto-char point))) | |
75 | |
76 | |
77 ;;; | |
78 ;;; Text buffer operations | |
79 ;;; | |
80 (defun mouse-move-point (window x y) | |
81 "Move point to mouse cursor." | |
82 (select-window window) | |
83 (move-to-loc x y) | |
84 (if (memq last-command ; support the mouse-copy/delete/yank | |
85 '(mouse-copy mouse-delete mouse-yank-move)) | |
86 (setq this-command 'mouse-yank-move)) | |
87 ) | |
88 | |
65185
7d1da711be4c
(mouse-select-or-drag-move-point): Don't pass X and Y (they are ignored anyway).
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
89 (defun mouse-set-mark (&optional window x y) |
39022 | 90 "Set mark at mouse cursor." |
91 (eval-in-window window ;; use this to get the unwind protect | |
92 (let ((point (point))) | |
93 (move-to-loc x y) | |
94 (set-mark (point)) | |
95 (goto-char point) | |
96 (indicate-region))) | |
97 ) | |
98 | |
99 (defun mouse-set-mark-and-select (window x y) | |
100 "Set mark at mouse cursor, and select that window." | |
101 (select-window window) | |
102 (mouse-set-mark window x y) | |
103 ) | |
104 | |
105 (defun mouse-set-mark-and-stuff (w x y) | |
106 "Set mark at mouse cursor, and put region in stuff buffer." | |
107 (mouse-set-mark-and-select w x y) | |
108 (sun-select-region (region-beginning) (region-end))) | |
109 | |
110 ;;; | |
111 ;;; Simple mouse dragging stuff: marking with button up | |
112 ;;; | |
113 | |
114 (defvar *mouse-drag-window* nil) | |
115 (defvar *mouse-drag-x* -1) | |
116 (defvar *mouse-drag-y* -1) | |
117 | |
118 (defun mouse-drag-move-point (window x y) | |
119 "Move point to mouse cursor, and allow dragging." | |
120 (mouse-move-point window x y) | |
121 (setq *mouse-drag-window* window | |
122 *mouse-drag-x* x | |
123 *mouse-drag-y* y)) | |
124 | |
125 (defun mouse-drag-set-mark-stuff (window x y) | |
126 "The up click handler that goes with mouse-drag-move-point. | |
127 If mouse is in same WINDOW but at different X or Y than when | |
128 mouse-drag-move-point was last executed, set the mark at mouse | |
129 and put the region in the stuff buffer." | |
130 (if (and (eq *mouse-drag-window* window) | |
131 (not (and (equal *mouse-drag-x* x) | |
132 (equal *mouse-drag-y* y)))) | |
133 (mouse-set-mark-and-stuff window x y) | |
134 (setq this-command last-command)) ; this was just an upclick no-op. | |
135 ) | |
136 | |
137 (defun mouse-select-or-drag-move-point (window x y) | |
138 "Select window if not selected, otherwise do mouse-drag-move-point." | |
139 (if (eq (selected-window) window) | |
140 (mouse-drag-move-point window x y) | |
65185
7d1da711be4c
(mouse-select-or-drag-move-point): Don't pass X and Y (they are ignored anyway).
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
141 (mouse-select-window window))) |
39022 | 142 |
143 ;;; | |
144 ;;; esoterica: | |
145 ;;; | |
146 (defun mouse-exch-pt-and-mark (window x y) | |
147 "Exchange point and mark." | |
148 (select-window window) | |
149 (exchange-point-and-mark) | |
150 ) | |
151 | |
152 (defun mouse-call-kbd-macro (window x y) | |
153 "Invokes last keyboard macro at mouse cursor." | |
154 (mouse-move-point window x y) | |
155 (call-last-kbd-macro) | |
156 ) | |
157 | |
158 (defun mouse-mark-thing (window x y) | |
159 "Set point and mark to text object using syntax table. | |
160 The resulting region is put in the sun-window stuff buffer. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
161 Left or right Paren syntax marks an s-expression. |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
162 Clicking at the end of a line marks the line including a trailing newline. |
39022 | 163 If it doesn't recognize one of these it marks the character at point." |
164 (mouse-move-point window x y) | |
165 (if (eobp) (open-line 1)) | |
166 (let* ((char (char-after (point))) | |
167 (syntax (char-syntax char))) | |
168 (cond | |
169 ((eq syntax ?w) ; word. | |
170 (forward-word 1) | |
171 (set-mark (point)) | |
172 (forward-word -1)) | |
173 ;; try to include a single following whitespace (is this a good idea?) | |
174 ;; No, not a good idea since inconsistent. | |
175 ;;(if (eq (char-syntax (char-after (mark))) ?\ ) | |
176 ;; (set-mark (1+ (mark)))) | |
177 ((eq syntax ?\( ) ; open paren. | |
178 (mark-sexp 1)) | |
179 ((eq syntax ?\) ) ; close paren. | |
180 (forward-char 1) | |
181 (mark-sexp -1) | |
182 (exchange-point-and-mark)) | |
183 ((eolp) ; mark line if at end. | |
184 (set-mark (1+ (point))) | |
185 (beginning-of-line 1)) | |
186 (t ; mark character | |
187 (set-mark (1+ (point))))) | |
188 (indicate-region)) ; display region boundary. | |
189 (sun-select-region (region-beginning) (region-end)) | |
190 ) | |
191 | |
192 (defun mouse-kill-thing (window x y) | |
193 "Kill thing at mouse, and put point there." | |
194 (mouse-mark-thing window x y) | |
195 (kill-region-and-unmark (region-beginning) (region-end)) | |
196 ) | |
197 | |
198 (defun mouse-kill-thing-there (window x y) | |
199 "Kill thing at mouse, leave point where it was. | |
200 See mouse-mark-thing for a description of the objects recognized." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
201 (eval-in-window window |
39022 | 202 (save-excursion |
203 (mouse-mark-thing window x y) | |
204 (kill-region (region-beginning) (region-end)))) | |
205 ) | |
206 | |
207 (defun mouse-save-thing (window x y &optional quiet) | |
208 "Put thing at mouse in kill ring. | |
209 See mouse-mark-thing for a description of the objects recognized." | |
210 (mouse-mark-thing window x y) | |
211 (copy-region-as-kill (region-beginning) (region-end)) | |
212 (if (not quiet) (message "Thing saved")) | |
213 ) | |
214 | |
215 (defun mouse-save-thing-there (window x y &optional quiet) | |
216 "Put thing at mouse in kill ring, leave point as is. | |
217 See mouse-mark-thing for a description of the objects recognized." | |
218 (eval-in-window window | |
219 (save-excursion | |
220 (mouse-save-thing window x y quiet)))) | |
221 | |
222 ;;; | |
223 ;;; Mouse yanking... | |
224 ;;; | |
225 (defun mouse-copy-thing (window x y) | |
226 "Put thing at mouse in kill ring, yank to point. | |
227 See mouse-mark-thing for a description of the objects recognized." | |
228 (setq last-command 'not-kill) ;Avoids appending to previous kills. | |
229 (mouse-save-thing-there window x y t) | |
230 (yank) | |
231 (setq this-command 'yank)) | |
232 | |
233 (defun mouse-move-thing (window x y) | |
234 "Kill thing at mouse, yank it to point. | |
235 See mouse-mark-thing for a description of the objects recognized." | |
236 (setq last-command 'not-kill) ;Avoids appending to previous kills. | |
237 (mouse-kill-thing-there window x y) | |
238 (yank) | |
239 (setq this-command 'yank)) | |
240 | |
241 (defun mouse-yank-at-point (&optional window x y) | |
242 "Yank from kill-ring at point; then cycle thru kill ring." | |
243 (if (eq last-command 'yank) | |
244 (let ((before (< (point) (mark)))) | |
245 (delete-region (point) (mark)) | |
246 (insert (current-kill 1)) | |
247 (if before (exchange-point-and-mark))) | |
248 (yank)) | |
249 (setq this-command 'yank)) | |
250 | |
251 (defun mouse-yank-at-mouse (window x y) | |
252 "Yank from kill-ring at mouse; then cycle thru kill ring." | |
253 (mouse-move-point window x y) | |
254 (mouse-yank-at-point window x y)) | |
255 | |
256 (defun mouse-save/delete/yank (&optional window x y) | |
257 "Context sensitive save/delete/yank. | |
258 Consecutive clicks perform as follows: | |
259 * first click saves region to kill ring, | |
260 * second click kills region, | |
261 * third click yanks from kill ring, | |
262 * subsequent clicks cycle thru kill ring. | |
263 If mouse-move-point is performed after the first or second click, | |
264 the next click will do a yank, etc. Except for a possible mouse-move-point, | |
265 this command is insensitive to mouse location." | |
266 (cond | |
267 ((memq last-command '(mouse-delete yank mouse-yank-move)) ; third+ click | |
268 (mouse-yank-at-point)) | |
269 ((eq last-command 'mouse-copy) ; second click | |
270 (kill-region (region-beginning) (region-end)) | |
271 (setq this-command 'mouse-delete)) | |
272 (t ; first click | |
273 (copy-region-as-kill (region-beginning) (region-end)) | |
274 (message "Region saved") | |
275 (setq this-command 'mouse-copy)) | |
276 )) | |
277 | |
278 | |
279 (defun mouse-split-horizontally (window x y) | |
280 "Splits the window horizontally at mouse cursor." | |
281 (eval-in-window window (split-window-horizontally (1+ x)))) | |
282 | |
283 (defun mouse-split-vertically (window x y) | |
284 "Split the window vertically at the mouse cursor." | |
285 (eval-in-window window (split-window-vertically (1+ y)))) | |
286 | |
65185
7d1da711be4c
(mouse-select-or-drag-move-point): Don't pass X and Y (they are ignored anyway).
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
287 (defun mouse-select-window (&optional window x y) |
39022 | 288 "Selects the window, restoring point." |
289 (select-window window)) | |
290 | |
65185
7d1da711be4c
(mouse-select-or-drag-move-point): Don't pass X and Y (they are ignored anyway).
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
291 (defun mouse-delete-other-windows (&optional window x y) |
39022 | 292 "Deletes all windows except the one mouse is in." |
293 (delete-other-windows window)) | |
294 | |
65185
7d1da711be4c
(mouse-select-or-drag-move-point): Don't pass X and Y (they are ignored anyway).
Juanma Barranquero <lekktu@gmail.com>
parents:
64751
diff
changeset
|
295 (defun mouse-delete-window (window &optional x y) |
39022 | 296 "Deletes the window mouse is in." |
297 (delete-window window)) | |
298 | |
299 (defun mouse-undo (window x y) | |
300 "Invokes undo in the window mouse is in." | |
301 (eval-in-window window (undo))) | |
302 | |
303 ;;; | |
304 ;;; Scroll operations | |
305 ;;; | |
306 | |
307 ;;; The move-to-window-line is used below because otherwise | |
308 ;;; scrolling a non-selected process window with the mouse, after | |
309 ;;; the process has written text past the bottom of the window, | |
310 ;;; gives an "End of buffer" error, and then scrolls. The | |
311 ;;; move-to-window-line seems to force recomputing where things are. | |
312 (defun mouse-scroll-up (window x y) | |
313 "Scrolls the window upward." | |
314 (eval-in-window window (move-to-window-line 1) (scroll-up nil))) | |
315 | |
316 (defun mouse-scroll-down (window x y) | |
317 "Scrolls the window downward." | |
318 (eval-in-window window (scroll-down nil))) | |
319 | |
320 (defun mouse-scroll-proportional (window x y) | |
321 "Scrolls the window proportionally corresponding to window | |
322 relative X divided by window width." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
323 (eval-in-window window |
39022 | 324 (if (>= x (1- (window-width))) |
325 ;; When x is maximum (equal to or 1 less than window width), | |
326 ;; goto end of buffer. We check for this special case | |
327 ;; because the calculated goto-char often goes short of the | |
328 ;; end due to roundoff error, and we often really want to go | |
329 ;; to the end. | |
330 (goto-char (point-max)) | |
331 (progn | |
332 (goto-char (+ (point-min) ; For narrowed regions. | |
333 (* x (/ (- (point-max) (point-min)) | |
334 (1- (window-width)))))) | |
335 (beginning-of-line)) | |
336 ) | |
337 (what-cursor-position) ; Report position. | |
338 )) | |
339 | |
340 (defun mouse-line-to-top (window x y) | |
341 "Scrolls the line at the mouse cursor up to the top." | |
342 (eval-in-window window (scroll-up y))) | |
343 | |
344 (defun mouse-top-to-line (window x y) | |
345 "Scrolls the top line down to the mouse cursor." | |
346 (eval-in-window window (scroll-down y))) | |
347 | |
348 (defun mouse-line-to-bottom (window x y) | |
349 "Scrolls the line at the mouse cursor to the bottom." | |
350 (eval-in-window window (scroll-up (+ y (- 2 (window-height)))))) | |
351 | |
352 (defun mouse-bottom-to-line (window x y) | |
353 "Scrolls the bottom line up to the mouse cursor." | |
354 (eval-in-window window (scroll-down (+ y (- 2 (window-height)))))) | |
355 | |
356 (defun mouse-line-to-middle (window x y) | |
357 "Scrolls the line at the mouse cursor to the middle." | |
358 (eval-in-window window (scroll-up (- y -1 (/ (window-height) 2))))) | |
359 | |
360 (defun mouse-middle-to-line (window x y) | |
361 "Scrolls the line at the middle to the mouse cursor." | |
362 (eval-in-window window (scroll-up (- (/ (window-height) 2) y 1)))) | |
363 | |
364 | |
365 ;;; | |
366 ;;; main emacs menu. | |
367 ;;; | |
368 (defmenu expand-menu | |
369 ("Vertically" mouse-expand-vertically *menu-window*) | |
370 ("Horizontally" mouse-expand-horizontally *menu-window*)) | |
371 | |
372 (defmenu delete-window-menu | |
373 ("This One" delete-window *menu-window*) | |
374 ("All Others" delete-other-windows *menu-window*)) | |
375 | |
376 (defmenu mouse-help-menu | |
377 ("Text Region" | |
378 mouse-help-region *menu-window* *menu-x* *menu-y* 'text) | |
379 ("Scrollbar" | |
380 mouse-help-region *menu-window* *menu-x* *menu-y* 'scrollbar) | |
381 ("Modeline" | |
382 mouse-help-region *menu-window* *menu-x* *menu-y* 'modeline) | |
383 ("Minibuffer" | |
384 mouse-help-region *menu-window* *menu-x* *menu-y* 'minibuffer) | |
385 ) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
386 |
39022 | 387 (defmenu emacs-quit-menu |
388 ("Suspend" suspend-emacstool) | |
389 ("Quit" save-buffers-kill-emacs)) | |
390 | |
391 (defmenu emacs-menu | |
392 ("Emacs Menu") | |
393 ("Stuff Selection" sun-yank-selection) | |
394 ("Expand" . expand-menu) | |
395 ("Delete Window" . delete-window-menu) | |
396 ("Previous Buffer" mouse-select-previous-buffer *menu-window*) | |
397 ("Save Buffers" save-some-buffers) | |
398 ("List Directory" list-directory nil) | |
399 ("Dired" dired nil) | |
400 ("Mouse Help" . mouse-help-menu) | |
401 ("Quit" . emacs-quit-menu)) | |
402 | |
403 (defun emacs-menu-eval (window x y) | |
404 "Pop-up menu of editor commands." | |
405 (sun-menu-evaluate window (1+ x) (1- y) 'emacs-menu)) | |
406 | |
407 (defun mouse-expand-horizontally (window) | |
408 (eval-in-window window | |
409 (enlarge-window 4 t) | |
410 (update-display) ; Try to redisplay, since can get confused. | |
411 )) | |
412 | |
413 (defun mouse-expand-vertically (window) | |
414 (eval-in-window window (enlarge-window 4))) | |
415 | |
416 (defun mouse-select-previous-buffer (window) | |
417 "Switch buffer in mouse window to most recently selected buffer." | |
418 (eval-in-window window (switch-to-buffer (other-buffer)))) | |
419 | |
420 ;;; | |
421 ;;; minibuffer menu | |
422 ;;; | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
423 (defmenu minibuffer-menu |
39022 | 424 ("Minibuffer" message "Just some miscellaneous minibuffer commands") |
425 ("Stuff" sun-yank-selection) | |
426 ("Do-It" exit-minibuffer) | |
427 ("Abort" abort-recursive-edit) | |
428 ("Suspend" suspend-emacs)) | |
429 | |
430 (defun minibuffer-menu-eval (window x y) | |
431 "Pop-up menu of commands." | |
432 (sun-menu-evaluate window x (1- y) 'minibuffer-menu)) | |
433 | |
434 (defun mini-move-point (window x y) | |
435 ;; -6 is good for most common cases | |
436 (mouse-move-point window (- x 6) 0)) | |
437 | |
438 (defun mini-set-mark-and-stuff (window x y) | |
439 ;; -6 is good for most common cases | |
440 (mouse-set-mark-and-stuff window (- x 6) 0)) | |
441 | |
442 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
443 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
39022 | 444 ;;; Buffer-mode Mouse commands |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
445 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
39022 | 446 |
447 (defun Buffer-at-mouse (w x y) | |
448 "Calls Buffer-menu-buffer from mouse click." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
449 (save-window-excursion |
39022 | 450 (mouse-move-point w x y) |
451 (beginning-of-line) | |
452 (Buffer-menu-buffer t))) | |
453 | |
454 (defun mouse-buffer-bury (w x y) | |
455 "Bury the indicated buffer." | |
456 (bury-buffer (Buffer-at-mouse w x y)) | |
457 ) | |
458 | |
459 (defun mouse-buffer-select (w x y) | |
460 "Put the indicated buffer in selected window." | |
461 (switch-to-buffer (Buffer-at-mouse w x y)) | |
462 (list-buffers) | |
463 ) | |
464 | |
465 (defun mouse-buffer-delete (w x y) | |
466 "mark indicated buffer for delete" | |
467 (save-window-excursion | |
468 (mouse-move-point w x y) | |
469 (Buffer-menu-delete) | |
470 )) | |
471 | |
472 (defun mouse-buffer-execute (w x y) | |
473 "execute buffer-menu selections" | |
474 (save-window-excursion | |
475 (mouse-move-point w x y) | |
476 (Buffer-menu-execute) | |
477 )) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
478 |
39022 | 479 (defun enable-mouse-in-buffer-list () |
480 "Call this to enable mouse selections in *Buffer List* | |
481 LEFT puts the indicated buffer in the selected window. | |
482 MIDDLE buries the indicated buffer. | |
483 RIGHT marks the indicated buffer for deletion. | |
484 MIDDLE-RIGHT deletes the marked buffers. | |
485 To unmark a buffer marked for deletion, select it with LEFT." | |
486 (save-window-excursion | |
487 (list-buffers) ; Initialize *Buffer List* | |
488 (set-buffer "*Buffer List*") | |
489 (local-set-mouse '(text middle) 'mouse-buffer-bury) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
490 (local-set-mouse '(text left) 'mouse-buffer-select) |
39022 | 491 (local-set-mouse '(text right) 'mouse-buffer-delete) |
492 (local-set-mouse '(text middle right) 'mouse-buffer-execute) | |
493 ) | |
494 ) | |
495 | |
496 | |
497 ;;;******************************************************************* | |
498 ;;; | |
499 ;;; Global Mouse Bindings. | |
500 ;;; | |
501 ;;; There is some sense to this mouse binding madness: | |
502 ;;; LEFT and RIGHT scrolls are inverses. | |
503 ;;; SHIFT makes an opposite meaning in the scroll bar. | |
504 ;;; SHIFT is an alternative to DOUBLE (but double chords do not exist). | |
505 ;;; META makes the scrollbar functions work in the text region. | |
506 ;;; MIDDLE operates the mark | |
507 ;;; LEFT operates at point | |
508 | |
509 ;;; META commands are generally non-destructive, | |
510 ;;; SHIFT is a little more dangerous. | |
511 ;;; CONTROL is for the really complicated ones. | |
512 | |
513 ;;; CONTROL-META-SHIFT-RIGHT gives help on that region. | |
514 | |
515 ;;; | |
516 ;;; Text Region mousemap | |
517 ;;; | |
518 ;; The basics: Point, Mark, Menu, Sun-Select: | |
519 (global-set-mouse '(text left) 'mouse-drag-move-point) | |
520 (global-set-mouse '(text up left) 'mouse-drag-set-mark-stuff) | |
521 (global-set-mouse '(text shift left) 'mouse-exch-pt-and-mark) | |
522 (global-set-mouse '(text double left) 'mouse-exch-pt-and-mark) | |
523 | |
524 (global-set-mouse '(text middle) 'mouse-set-mark-and-stuff) | |
525 | |
526 (global-set-mouse '(text right) 'emacs-menu-eval) | |
527 (global-set-mouse '(text shift right) '(sun-yank-selection)) | |
528 (global-set-mouse '(text double right) '(sun-yank-selection)) | |
529 | |
530 ;; The Slymoblics multi-command for Save, Kill, Copy, Move: | |
531 (global-set-mouse '(text shift middle) 'mouse-save/delete/yank) | |
532 (global-set-mouse '(text double middle) 'mouse-save/delete/yank) | |
533 | |
534 ;; Save, Kill, Copy, Move Things: | |
535 ;; control-left composes with control middle/right to produce copy/move | |
536 (global-set-mouse '(text control middle ) 'mouse-save-thing-there) | |
537 (global-set-mouse '(text control right ) 'mouse-kill-thing-there) | |
538 (global-set-mouse '(text control left) 'mouse-yank-at-point) | |
539 (global-set-mouse '(text control middle left) 'mouse-copy-thing) | |
540 (global-set-mouse '(text control right left) 'mouse-move-thing) | |
541 (global-set-mouse '(text control right middle) 'mouse-mark-thing) | |
542 | |
543 ;; The Universal mouse help command (press all buttons): | |
544 (global-set-mouse '(text shift control meta right) 'mouse-help-region) | |
545 (global-set-mouse '(text double control meta right) 'mouse-help-region) | |
546 | |
547 ;;; Meta in Text Region is like meta version in scrollbar: | |
548 (global-set-mouse '(text meta left) 'mouse-line-to-top) | |
549 (global-set-mouse '(text meta shift left) 'mouse-line-to-bottom) | |
550 (global-set-mouse '(text meta double left) 'mouse-line-to-bottom) | |
551 (global-set-mouse '(text meta middle) 'mouse-line-to-middle) | |
552 (global-set-mouse '(text meta shift middle) 'mouse-middle-to-line) | |
553 (global-set-mouse '(text meta double middle) 'mouse-middle-to-line) | |
554 (global-set-mouse '(text meta control middle) 'mouse-split-vertically) | |
555 (global-set-mouse '(text meta right) 'mouse-top-to-line) | |
556 (global-set-mouse '(text meta shift right) 'mouse-bottom-to-line) | |
557 (global-set-mouse '(text meta double right) 'mouse-bottom-to-line) | |
558 | |
559 ;; Miscellaneous: | |
560 (global-set-mouse '(text meta control left) 'mouse-call-kbd-macro) | |
561 (global-set-mouse '(text meta control right) 'mouse-undo) | |
562 | |
563 ;;; | |
564 ;;; Scrollbar mousemap. | |
565 ;;; Are available in the Scrollbar Region, or with Meta Text (or Meta Scrollbar) | |
566 ;;; | |
567 (global-set-mouse '(scrollbar left) 'mouse-line-to-top) | |
568 (global-set-mouse '(scrollbar shift left) 'mouse-line-to-bottom) | |
569 (global-set-mouse '(scrollbar double left) 'mouse-line-to-bottom) | |
570 | |
571 (global-set-mouse '(scrollbar middle) 'mouse-line-to-middle) | |
572 (global-set-mouse '(scrollbar shift middle) 'mouse-middle-to-line) | |
573 (global-set-mouse '(scrollbar double middle) 'mouse-middle-to-line) | |
574 (global-set-mouse '(scrollbar control middle) 'mouse-split-vertically) | |
575 | |
576 (global-set-mouse '(scrollbar right) 'mouse-top-to-line) | |
577 (global-set-mouse '(scrollbar shift right) 'mouse-bottom-to-line) | |
578 (global-set-mouse '(scrollbar double right) 'mouse-bottom-to-line) | |
579 | |
580 (global-set-mouse '(scrollbar meta left) 'mouse-line-to-top) | |
581 (global-set-mouse '(scrollbar meta shift left) 'mouse-line-to-bottom) | |
582 (global-set-mouse '(scrollbar meta double left) 'mouse-line-to-bottom) | |
583 (global-set-mouse '(scrollbar meta middle) 'mouse-line-to-middle) | |
584 (global-set-mouse '(scrollbar meta shift middle) 'mouse-middle-to-line) | |
585 (global-set-mouse '(scrollbar meta double middle) 'mouse-middle-to-line) | |
586 (global-set-mouse '(scrollbar meta control middle) 'mouse-split-vertically) | |
587 (global-set-mouse '(scrollbar meta right) 'mouse-top-to-line) | |
588 (global-set-mouse '(scrollbar meta shift right) 'mouse-bottom-to-line) | |
589 (global-set-mouse '(scrollbar meta double right) 'mouse-bottom-to-line) | |
590 | |
591 ;; And the help menu: | |
592 (global-set-mouse '(scrollbar shift control meta right) 'mouse-help-region) | |
593 (global-set-mouse '(scrollbar double control meta right) 'mouse-help-region) | |
594 | |
595 ;;; | |
596 ;;; Modeline mousemap. | |
597 ;;; | |
598 ;;; Note: meta of any single button selects window. | |
599 | |
600 (global-set-mouse '(modeline left) 'mouse-scroll-up) | |
601 (global-set-mouse '(modeline meta left) 'mouse-select-window) | |
602 | |
603 (global-set-mouse '(modeline middle) 'mouse-scroll-proportional) | |
604 (global-set-mouse '(modeline meta middle) 'mouse-select-window) | |
605 (global-set-mouse '(modeline control middle) 'mouse-split-horizontally) | |
606 | |
607 (global-set-mouse '(modeline right) 'mouse-scroll-down) | |
608 (global-set-mouse '(modeline meta right) 'mouse-select-window) | |
609 | |
610 ;;; control-left selects this window, control-right deletes it. | |
611 (global-set-mouse '(modeline control left) 'mouse-delete-other-windows) | |
612 (global-set-mouse '(modeline control right) 'mouse-delete-window) | |
613 | |
614 ;; in case of confusion, just select it: | |
615 (global-set-mouse '(modeline control left right)'mouse-select-window) | |
616 | |
617 ;; even without confusion (and without the keyboard) select it: | |
618 (global-set-mouse '(modeline left right) 'mouse-select-window) | |
619 | |
620 ;; And the help menu: | |
621 (global-set-mouse '(modeline shift control meta right) 'mouse-help-region) | |
622 (global-set-mouse '(modeline double control meta right) 'mouse-help-region) | |
623 | |
624 ;;; | |
625 ;;; Minibuffer Mousemap | |
626 ;;; Demonstrating some variety: | |
627 ;;; | |
628 (global-set-mouse '(minibuffer left) 'mini-move-point) | |
629 | |
630 (global-set-mouse '(minibuffer middle) 'mini-set-mark-and-stuff) | |
631 | |
632 (global-set-mouse '(minibuffer shift middle) '(select-previous-complex-command)) | |
633 (global-set-mouse '(minibuffer double middle) '(select-previous-complex-command)) | |
634 (global-set-mouse '(minibuffer control middle) '(next-complex-command 1)) | |
635 (global-set-mouse '(minibuffer meta middle) '(previous-complex-command 1)) | |
636 | |
637 (global-set-mouse '(minibuffer right) 'minibuffer-menu-eval) | |
638 | |
639 (global-set-mouse '(minibuffer shift control meta right) 'mouse-help-region) | |
640 (global-set-mouse '(minibuffer double control meta right) 'mouse-help-region) | |
641 | |
642 (provide 'sun-fns) | |
643 | |
52401 | 644 ;;; arch-tag: 1c4c1192-f71d-4d5f-b883-ae659c28e132 |
39022 | 645 ;;; sun-fns.el ends here |