sun-mouse-fns.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. ;; Subroutines of Mouse handling for Sun windows
  2. ;; Copyright (C) 1987 Free Software Foundation, Inc.
  3. ;; This file is part of GNU Emacs.
  4. ;; GNU Emacs is distributed in the hope that it will be useful,
  5. ;; but WITHOUT ANY WARRANTY. No author or distributor
  6. ;; accepts responsibility to anyone for the consequences of using it
  7. ;; or for whether it serves any particular purpose or works at all,
  8. ;; unless he says so in writing. Refer to the GNU Emacs General Public
  9. ;; License for full details.
  10. ;; Everyone is granted permission to copy, modify and redistribute
  11. ;; GNU Emacs, but only under the conditions described in the
  12. ;; GNU Emacs General Public License. A copy of this license is
  13. ;; supposed to have been given to you along with GNU Emacs so you
  14. ;; can know your rights and responsibilities. It should be in a
  15. ;; file named COPYING. Among other things, the copyright notice
  16. ;; and this notice must be preserved on all copies.
  17. ;;; Submitted Mar. 1987, Jeff Peck
  18. ;;; Sun Microsystems Inc. <peck@sun.com>
  19. ;;; Conceived Nov. 1986, Stan Jefferson,
  20. ;;; Computer Science Lab, SRI International.
  21. ;;; GoodIdeas Feb. 1987, Steve Greenbaum
  22. ;;; & UpClicks Reasoning Systems, Inc.
  23. ;;;
  24. (provide 'sun-mouse-fns)
  25. (require 'sun-mouse)
  26. ;;;
  27. ;;; Functions for manipulating via the mouse and mouse-map definitions
  28. ;;; for accessing them. Also definitons of mouse menus.
  29. ;;; This file you should freely modify to reflect you personal tastes.
  30. ;;;
  31. ;;; First half of file defines functions to implement mouse commands,
  32. ;;; Don't delete any of those, just add what ever else you need.
  33. ;;; Second half of file defines mouse bindings, do whatever you want there.
  34. ;;;
  35. ;;; Mouse Functions.
  36. ;;;
  37. ;;; These functions follow the sun-mouse-handler convention of being called
  38. ;;; with three arguements: (window x-pos y-pos)
  39. ;;; This makes it easy for a mouse executed command to know where the mouse is.
  40. ;;; Use the macro "eval-in-window" to execute a function
  41. ;;; in a temporarily selected window.
  42. ;;;
  43. ;;; If you have a function that must be called with other arguments
  44. ;;; bind the mouse button to an s-exp that contains the necessary parameters.
  45. ;;; See "minibuffer" bindings for examples.
  46. ;;;
  47. (defconst cursor-pause-milliseconds 300
  48. "*Number of milliseconds to display alternate cursor (usually the mark)")
  49. (defun indicate-region (&optional pause)
  50. "Bounce cursor to mark for cursor-pause-milliseconds and back again"
  51. (or pause (setq pause cursor-pause-milliseconds))
  52. (let ((point (point)))
  53. (goto-char (mark))
  54. (sit-for-millisecs pause)
  55. ;(update-display)
  56. ;(sleep-for-millisecs pause)
  57. (goto-char point)))
  58. ;;;
  59. ;;; Text buffer operations
  60. ;;;
  61. (defun mouse-move-point (window x y)
  62. "Move point to mouse cursor."
  63. (select-window window)
  64. (move-to-loc x y)
  65. (if (memq last-command ; support the mouse-copy/delete/yank
  66. '(mouse-copy mouse-delete mouse-yank-move))
  67. (setq this-command 'mouse-yank-move))
  68. )
  69. (defun mouse-set-mark (window x y)
  70. "Set mark at mouse cursor."
  71. (eval-in-window window ;; use this to get the unwind protect
  72. (let ((point (point)))
  73. (move-to-loc x y)
  74. (set-mark (point))
  75. (goto-char point)
  76. (indicate-region)))
  77. )
  78. (defun mouse-set-mark-and-select (window x y)
  79. "Set mark at mouse cursor, and select that window."
  80. (select-window window)
  81. (mouse-set-mark window x y)
  82. )
  83. (defun mouse-set-mark-and-stuff (w x y)
  84. "Set mark at mouse cursor, and put region in stuff buffer."
  85. (mouse-set-mark-and-select w x y)
  86. (sun-select-region (region-beginning) (region-end)))
  87. ;;;
  88. ;;; Simple mouse dragging stuff: marking with button up
  89. ;;;
  90. (defvar *mouse-drag-window* nil)
  91. (defvar *mouse-drag-x* -1)
  92. (defvar *mouse-drag-y* -1)
  93. (defun mouse-drag-move-point (window x y)
  94. "Move point to mouse cursor, and allow dragging."
  95. (mouse-move-point window x y)
  96. (setq *mouse-drag-window* window
  97. *mouse-drag-x* x
  98. *mouse-drag-y* y))
  99. (defun mouse-drag-set-mark-stuff (window x y)
  100. "The up click handler that goes with mouse-drag-move-point.
  101. If mouse is in same WINDOW but at different X or Y than when
  102. mouse-drag-move-point was last executed, set the mark at mouse
  103. and put the region in the stuff buffer."
  104. (if (and (eq *mouse-drag-window* window)
  105. (not (and (equal *mouse-drag-x* x)
  106. (equal *mouse-drag-y* y))))
  107. (mouse-set-mark-and-stuff window x y)
  108. (setq this-command last-command)) ; this was just an upclick no-op.
  109. )
  110. (defun mouse-select-or-drag-move-point (window x y)
  111. "Select window if not selected, otherwise do mouse-drag-move-point."
  112. (if (eq (selected-window) window)
  113. (mouse-drag-move-point window x y)
  114. (mouse-select-window window x y)))
  115. ;;;
  116. ;;; esoteria:
  117. ;;;
  118. (defun mouse-exch-pt-and-mark (window x y)
  119. "Exchange point and mark."
  120. (select-window window)
  121. (exchange-point-and-mark)
  122. )
  123. (defun mouse-call-kbd-macro (window x y)
  124. "Invokes last keyboard macro at mouse cursor."
  125. (mouse-move-point window x y)
  126. (call-last-kbd-macro)
  127. )
  128. (defun mouse-mark-thing (window x y)
  129. "Set point and mark to text object using syntax table.
  130. The resulting region is put in the sun-window stuff buffer.
  131. Left or right Paren syntax marks an s-expression.
  132. Clicking at the end of a line marks the line including a trailing newline.
  133. If it doesn't recognize one of these it marks the character at point."
  134. (mouse-move-point window x y)
  135. (if (eobp) (open-line 1))
  136. (let* ((char (char-after (point)))
  137. (syntax (char-syntax char)))
  138. (cond
  139. ((eq syntax ?w) ; word.
  140. (forward-word 1)
  141. (set-mark (point))
  142. (forward-word -1))
  143. ;; try to include a single following whitespace (is this a good idea?)
  144. ;; No, not a good idea since inconsistent.
  145. ;;(if (eq (char-syntax (char-after (mark))) ?\ )
  146. ;; (set-mark (1+ (mark))))
  147. ((eq syntax ?\( ) ; open paren.
  148. (mark-sexp 1))
  149. ((eq syntax ?\) ) ; close paren.
  150. (forward-char 1)
  151. (mark-sexp -1)
  152. (exchange-point-and-mark))
  153. ((eolp) ; mark line if at end.
  154. (set-mark (1+ (point)))
  155. (beginning-of-line 1))
  156. (t ; mark character
  157. (set-mark (1+ (point)))))
  158. (indicate-region)) ; display region boundary.
  159. (sun-select-region (region-beginning) (region-end))
  160. )
  161. (defun mouse-kill-thing (window x y)
  162. "Kill thing at mouse, and put point there."
  163. (mouse-mark-thing window x y)
  164. (kill-region-and-unmark (region-beginning) (region-end))
  165. )
  166. (defun mouse-kill-thing-there (window x y)
  167. "Kill thing at mouse, leave point where it was.
  168. See mouse-mark-thing for a description of the objects recognized."
  169. (eval-in-window window
  170. (save-excursion
  171. (mouse-mark-thing window x y)
  172. (kill-region (region-beginning) (region-end))))
  173. )
  174. (defun mouse-save-thing (window x y &optional quiet)
  175. "Put thing at mouse in kill ring.
  176. See mouse-mark-thing for a description of the objects recognized."
  177. (mouse-mark-thing window x y)
  178. (copy-region-as-kill (region-beginning) (region-end))
  179. (if (not quiet) (message "Thing saved"))
  180. )
  181. (defun mouse-save-thing-there (window x y &optional quiet)
  182. "Put thing at mouse in kill ring, leave point as is.
  183. See mouse-mark-thing for a description of the objects recognized."
  184. (eval-in-window window
  185. (save-excursion
  186. (mouse-save-thing window x y quiet))))
  187. ;;;
  188. ;;; Mouse yanking...
  189. ;;;
  190. (defun mouse-copy-thing (window x y)
  191. "Put thing at mouse in kill ring, yank to point.
  192. See mouse-mark-thing for a description of the objects recognized."
  193. (setq last-command 'not-kill) ;Avoids appending to previous kills.
  194. (mouse-save-thing-there window x y t)
  195. (yank)
  196. (setq this-command 'yank))
  197. (defun mouse-move-thing (window x y)
  198. "Kill thing at mouse, yank it to point.
  199. See mouse-mark-thing for a description of the objects recognized."
  200. (setq last-command 'not-kill) ;Avoids appending to previous kills.
  201. (mouse-kill-thing-there window x y)
  202. (yank)
  203. (setq this-command 'yank))
  204. (defun mouse-yank-at-point (&optional window x y)
  205. "Yank from kill-ring at point; then cycle thru kill ring."
  206. (if (eq last-command 'yank)
  207. (let ((before (< (point) (mark))))
  208. (delete-region (point) (mark))
  209. (rotate-yank-pointer 1)
  210. (insert (car kill-ring-yank-pointer))
  211. (if before (exchange-point-and-mark)))
  212. (yank))
  213. (setq this-command 'yank))
  214. (defun mouse-yank-at-mouse (window x y)
  215. "Yank from kill-ring at mouse; then cycle thru kill ring."
  216. (mouse-move-point window x y)
  217. (mouse-yank-at-point window x y))
  218. (defun mouse-save/delete/yank (&optional window x y)
  219. "Context sensitive save/delete/yank.
  220. Consecutive clicks perform as follows:
  221. * first click saves region to kill ring,
  222. * second click kills region,
  223. * third click yanks from kill ring,
  224. * subsequent clicks cycle thru kill ring.
  225. If mouse-move-point is performed after the first or second click,
  226. the next click will do a yank, etc. Except for a possible mouse-move-point,
  227. this command is insensitive to mouse location."
  228. (cond
  229. ((memq last-command '(mouse-delete yank mouse-yank-move)) ; third+ click
  230. (mouse-yank-at-point))
  231. ((eq last-command 'mouse-copy) ; second click
  232. (kill-region (region-beginning) (region-end))
  233. (setq this-command 'mouse-delete))
  234. (t ; first click
  235. (copy-region-as-kill (region-beginning) (region-end))
  236. (message "Region saved")
  237. (setq this-command 'mouse-copy))
  238. ))
  239. (defun mouse-split-horizontally (window x y)
  240. "Splits the window horizontally at mouse cursor."
  241. (eval-in-window window (split-window-horizontally (1+ x))))
  242. (defun mouse-split-vertically (window x y)
  243. "Split the window vertically at the mouse cursor."
  244. (eval-in-window window (split-window-vertically (1+ y))))
  245. (defun mouse-select-window (window x y)
  246. "Selects the window, restoring point."
  247. (select-window window))
  248. (defun mouse-delete-other-windows (window x y)
  249. "Deletes all windows except the one mouse is in."
  250. (delete-other-windows window))
  251. (defun mouse-delete-window (window x y)
  252. "Deletes the window mouse is in."
  253. (delete-window window))
  254. (defun mouse-undo (window x y)
  255. "Invokes undo in the window mouse is in."
  256. (eval-in-window window (undo)))
  257. ;;;
  258. ;;; Scroll operations
  259. ;;;
  260. ;;; The move-to-window-line is used below because otherwise
  261. ;;; scrolling a non-selected process window with the mouse, after
  262. ;;; the process has written text past the bottom of the window,
  263. ;;; gives an "End of buffer" error, and then scrolls. The
  264. ;;; move-to-window-line seems to force recomputing where things are.
  265. (defun mouse-scroll-up (window x y)
  266. "Scrolls the window upward."
  267. (eval-in-window window (move-to-window-line 1) (scroll-up nil)))
  268. (defun mouse-scroll-down (window x y)
  269. "Scrolls the window downward."
  270. (eval-in-window window (scroll-down nil)))
  271. (defun mouse-scroll-proportional (window x y)
  272. "Scrolls the window proportionally corresponding to window
  273. relative X divided by window width."
  274. (eval-in-window window
  275. (if (>= x (1- (window-width)))
  276. ;; When x is maximun (equal to or 1 less than window width),
  277. ;; goto end of buffer. We check for this special case
  278. ;; becuase the calculated goto-char often goes short of the
  279. ;; end due to roundoff error, and we often really want to go
  280. ;; to the end.
  281. (goto-char (point-max))
  282. (progn
  283. (goto-char (* x (/ (- (point-max) (point-min))
  284. (1- (window-width)))))
  285. (beginning-of-line))
  286. )
  287. (what-cursor-position) ; Report position.
  288. ))
  289. (defun mouse-line-to-top (window x y)
  290. "Scrolls the line at the mouse cursor up to the top."
  291. (eval-in-window window (scroll-up y)))
  292. (defun mouse-top-to-line (window x y)
  293. "Scrolls the top line down to the mouse cursor."
  294. (eval-in-window window (scroll-down y)))
  295. (defun mouse-line-to-bottom (window x y)
  296. "Scrolls the line at the mouse cursor to the bottom."
  297. (eval-in-window window (scroll-up (+ y (- 2 (window-height))))))
  298. (defun mouse-bottom-to-line (window x y)
  299. "Scrolls the bottom line up to the mouse cursor."
  300. (eval-in-window window (scroll-down (+ y (- 2 (window-height))))))
  301. (defun mouse-line-to-middle (window x y)
  302. "Scrolls the line at the mouse cursor to the middle."
  303. (eval-in-window window (scroll-up (- y -1 (/ (window-height) 2)))))
  304. (defun mouse-middle-to-line (window x y)
  305. "Scrolls the line at the middle to the mouse cursor."
  306. (eval-in-window window (scroll-up (- (/ (window-height) 2) y 1))))
  307. ;;;
  308. ;;; main emacs menu.
  309. ;;;
  310. (defmenu expand-menu
  311. ("Vertically" mouse-expand-vertically *menu-window*)
  312. ("Horizontally" mouse-expand-horizontally *menu-window*))
  313. (defmenu delete-window-menu
  314. ("This One" delete-window *menu-window*)
  315. ("All Others" delete-other-windows *menu-window*))
  316. (defmenu mouse-help-menu
  317. ("Text Region"
  318. mouse-help-region *menu-window* *menu-x* *menu-y* 'text)
  319. ("Scrollbar"
  320. mouse-help-region *menu-window* *menu-x* *menu-y* 'scrollbar)
  321. ("Modeline"
  322. mouse-help-region *menu-window* *menu-x* *menu-y* 'modeline)
  323. ("Minibuffer"
  324. mouse-help-region *menu-window* *menu-x* *menu-y* 'minibuffer)
  325. )
  326. (defmenu emacs-quit-menu
  327. ("Suspend" suspend-emacstool)
  328. ("Quit" save-buffers-kill-emacs))
  329. (defmenu emacs-menu
  330. ("Emacs Menu")
  331. ("Stuff Selection" sun-yank-selection)
  332. ("Expand" . expand-menu)
  333. ("Delete Window" . delete-window-menu)
  334. ("Previous Buffer" mouse-select-previous-buffer *menu-window*)
  335. ("Save Buffers" save-some-buffers)
  336. ("List Directory" list-directory nil)
  337. ("Dired" dired nil)
  338. ("Mouse Help" . mouse-help-menu)
  339. ("Quit" . emacs-quit-menu))
  340. (defun emacs-menu-eval (window x y)
  341. "Pop-up menu of editor commands."
  342. (sun-menu-evaluate window (1+ x) (1- y) 'emacs-menu))
  343. (defun mouse-expand-horizontally (window)
  344. (eval-in-window window
  345. (enlarge-window 4 t)
  346. (update-display) ; Try to redisplay, since can get confused.
  347. ))
  348. (defun mouse-expand-vertically (window)
  349. (eval-in-window window (enlarge-window 4)))
  350. (defun mouse-select-previous-buffer (window)
  351. "Switch buffer in mouse window to most recently selected buffer."
  352. (eval-in-window window (switch-to-buffer (other-buffer))))
  353. ;;;
  354. ;;; minibuffer menu
  355. ;;;
  356. (defmenu minibuffer-menu
  357. ("Minibuffer" message "Just some miscellanous minibuffer commands")
  358. ("Stuff" sun-yank-selection)
  359. ("Do-It" exit-minibuffer)
  360. ("Abort" abort-recursive-edit)
  361. ("Suspend" suspend-emacs))
  362. (defun minibuffer-menu-eval (window x y)
  363. "Pop-up menu of commands."
  364. (sun-menu-evaluate window x (1- y) 'minibuffer-menu))
  365. (defun mini-move-point (window x y)
  366. ;; -6 is good for most common cases
  367. (mouse-move-point window (- x 6) 0))
  368. (defun mini-set-mark-and-stuff (window x y)
  369. ;; -6 is good for most common cases
  370. (mouse-set-mark-and-stuff window (- x 6) 0))
  371. ;;;*******************************************************************
  372. ;;;
  373. ;;; Mouse Bindings.
  374. ;;;
  375. ;;; There is some sense to this mouse binding madness:
  376. ;;; LEFT and RIGHT scrolls are inverses.
  377. ;;; SHIFT makes an opposite meaning in the scroll bar.
  378. ;;; SHIFT is an alternative to DOUBLE (but double chords do not exist).
  379. ;;; META makes the scrollbar functions work in the text region.
  380. ;;; MIDDLE operates the mark
  381. ;;; LEFT operates at point
  382. ;;; META commands are generally non-destructive,
  383. ;;; SHIFT is a little more dangerous.
  384. ;;; CONTROL is for the really complicated ones.
  385. ;;; CONTROL-META-SHIFT-RIGHT gives help on that region.
  386. ;;;
  387. ;;; Text Region mousemap
  388. ;;;
  389. ;; The basics: Point, Mark, Menu, Sun-Select:
  390. (global-set-mouse '(text left) 'mouse-drag-move-point)
  391. (global-set-mouse '(text up left) 'mouse-drag-set-mark-stuff)
  392. (global-set-mouse '(text shift left) 'mouse-exch-pt-and-mark)
  393. (global-set-mouse '(text double left) 'mouse-exch-pt-and-mark)
  394. (global-set-mouse '(text middle) 'mouse-set-mark-and-stuff)
  395. (global-set-mouse '(text right) 'emacs-menu-eval)
  396. (global-set-mouse '(text shift right) '(sun-yank-selection))
  397. (global-set-mouse '(text double right) '(sun-yank-selection))
  398. ;; The Slymoblics multi-command for Save, Kill, Copy, Move:
  399. (global-set-mouse '(text shift middle) 'mouse-save/delete/yank)
  400. (global-set-mouse '(text double middle) 'mouse-save/delete/yank)
  401. ;; Save, Kill, Copy, Move Things:
  402. ;; control-left composes with control middle/right to produce copy/move
  403. (global-set-mouse '(text control middle ) 'mouse-save-thing-there)
  404. (global-set-mouse '(text control right ) 'mouse-kill-thing-there)
  405. (global-set-mouse '(text control left) 'mouse-yank-at-point)
  406. (global-set-mouse '(text control middle left) 'mouse-copy-thing)
  407. (global-set-mouse '(text control right left) 'mouse-move-thing)
  408. (global-set-mouse '(text control right middle) 'mouse-mark-thing)
  409. ;; The Universal mouse help command (press all buttons):
  410. (global-set-mouse '(text shift control meta right) 'mouse-help-region)
  411. (global-set-mouse '(text double control meta right) 'mouse-help-region)
  412. ;;; Meta in Text Region is like meta version in scrollbar:
  413. (global-set-mouse '(text meta left) 'mouse-line-to-top)
  414. (global-set-mouse '(text meta shift left) 'mouse-line-to-bottom)
  415. (global-set-mouse '(text meta double left) 'mouse-line-to-bottom)
  416. (global-set-mouse '(text meta middle) 'mouse-line-to-middle)
  417. (global-set-mouse '(text meta shift middle) 'mouse-middle-to-line)
  418. (global-set-mouse '(text meta double middle) 'mouse-middle-to-line)
  419. (global-set-mouse '(text meta control middle) 'mouse-split-vertically)
  420. (global-set-mouse '(text meta right) 'mouse-top-to-line)
  421. (global-set-mouse '(text meta shift right) 'mouse-bottom-to-line)
  422. (global-set-mouse '(text meta double right) 'mouse-bottom-to-line)
  423. ;; Miscellaneous:
  424. (global-set-mouse '(text meta control left) 'mouse-call-kbd-macro)
  425. (global-set-mouse '(text meta control right) 'mouse-undo)
  426. ;;;
  427. ;;; Scrollbar mousemap.
  428. ;;; Are available in the Scrollbar Region, or with Meta Text (or Meta Scrollbar)
  429. ;;;
  430. (global-set-mouse '(scrollbar left) 'mouse-line-to-top)
  431. (global-set-mouse '(scrollbar shift left) 'mouse-line-to-bottom)
  432. (global-set-mouse '(scrollbar double left) 'mouse-line-to-bottom)
  433. (global-set-mouse '(scrollbar middle) 'mouse-line-to-middle)
  434. (global-set-mouse '(scrollbar shift middle) 'mouse-middle-to-line)
  435. (global-set-mouse '(scrollbar double middle) 'mouse-middle-to-line)
  436. (global-set-mouse '(scrollbar control middle) 'mouse-split-vertically)
  437. (global-set-mouse '(scrollbar right) 'mouse-top-to-line)
  438. (global-set-mouse '(scrollbar shift right) 'mouse-bottom-to-line)
  439. (global-set-mouse '(scrollbar double right) 'mouse-bottom-to-line)
  440. (global-set-mouse '(scrollbar meta left) 'mouse-line-to-top)
  441. (global-set-mouse '(scrollbar meta shift left) 'mouse-line-to-bottom)
  442. (global-set-mouse '(scrollbar meta double left) 'mouse-line-to-bottom)
  443. (global-set-mouse '(scrollbar meta middle) 'mouse-line-to-middle)
  444. (global-set-mouse '(scrollbar meta shift middle) 'mouse-middle-to-line)
  445. (global-set-mouse '(scrollbar meta double middle) 'mouse-middle-to-line)
  446. (global-set-mouse '(scrollbar meta control middle) 'mouse-split-vertically)
  447. (global-set-mouse '(scrollbar meta right) 'mouse-top-to-line)
  448. (global-set-mouse '(scrollbar meta shift right) 'mouse-bottom-to-line)
  449. (global-set-mouse '(scrollbar meta double right) 'mouse-bottom-to-line)
  450. ;; And the help menu:
  451. (global-set-mouse '(scrollbar shift control meta right) 'mouse-help-region)
  452. (global-set-mouse '(scrollbar double control meta right) 'mouse-help-region)
  453. ;;;
  454. ;;; Modeline mousemap.
  455. ;;;
  456. ;;; Note: meta of any single button selects window.
  457. (global-set-mouse '(modeline left) 'mouse-scroll-up)
  458. (global-set-mouse '(modeline meta left) 'mouse-select-window)
  459. (global-set-mouse '(modeline middle) 'mouse-scroll-proportional)
  460. (global-set-mouse '(modeline meta middle) 'mouse-select-window)
  461. (global-set-mouse '(modeline control middle) 'mouse-split-horizontally)
  462. (global-set-mouse '(modeline right) 'mouse-scroll-down)
  463. (global-set-mouse '(modeline meta right) 'mouse-select-window)
  464. ;;; control-left selects this window, control-right deletes it.
  465. (global-set-mouse '(modeline control left) 'mouse-delete-other-windows)
  466. (global-set-mouse '(modeline control right) 'mouse-delete-window)
  467. ;; in case of confusion, just select it:
  468. (global-set-mouse '(modeline control left right)'mouse-select-window)
  469. ;; even without confusion (and without the keyboard) select it:
  470. (global-set-mouse '(modeline left right) 'mouse-select-window)
  471. ;; And the help menu:
  472. (global-set-mouse '(modeline shift control meta right) 'mouse-help-region)
  473. (global-set-mouse '(modeline double control meta right) 'mouse-help-region)
  474. ;;;
  475. ;;; Minibuffer Mousemap
  476. ;;; Demonstrating some variety:
  477. ;;;
  478. (global-set-mouse '(minibuffer left) 'mini-move-point)
  479. (global-set-mouse '(minibuffer middle) 'mini-set-mark-and-stuff)
  480. (global-set-mouse '(minibuffer shift middle) '(prev-complex-command))
  481. (global-set-mouse '(minibuffer double middle) '(prev-complex-command))
  482. (global-set-mouse '(minibuffer control middle) '(next-complex-command 1))
  483. (global-set-mouse '(minibuffer meta middle) '(previous-complex-command 1))
  484. (global-set-mouse '(minibuffer right) 'minibuffer-menu-eval)
  485. (global-set-mouse '(minibuffer shift control meta right) 'mouse-help-region)
  486. (global-set-mouse '(minibuffer double control meta right) 'mouse-help-region)