Mercurial > hg > xemacs-beta
annotate lisp/mwheel.el @ 5652:cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
lisp/ChangeLog addition:
2012-05-01 Aidan Kehoe <kehoea@parhasard.net>
Avoid #'delq in core code, for the sake of style and a (very
slightly) smaller binary.
* behavior.el (disable-behavior):
* behavior.el (compute-behavior-group-children):
* buff-menu.el (buffers-tab-items):
* byte-optimize.el (byte-optimize-delay-constants-math):
* byte-optimize.el (byte-optimize-logmumble):
* byte-optimize.el (byte-decompile-bytecode-1):
* byte-optimize.el (byte-optimize-lapcode):
* bytecomp.el:
* bytecomp.el (byte-compile-arglist-warn):
* bytecomp.el (byte-compile-warn-about-unresolved-functions):
* bytecomp.el (byte-compile-lambda):
* bytecomp.el (byte-compile-out-toplevel):
* bytecomp.el (byte-compile-insert):
* bytecomp.el (byte-compile-defalias-warn):
* cl-macs.el (cl-upcase-arg):
* cl-macs.el (cl-transform-lambda):
* cl-macs.el (cl-do-proclaim):
* cl-macs.el (defstruct):
* cl-macs.el (cl-make-type-test):
* cl-macs.el (define-compiler-macro):
* cl-macs.el (delete-duplicates):
* cus-edit.el (widget-face-value-delete):
* cus-edit.el (face-history):
* easymenu.el (easy-menu-remove):
* files.el (files-fetch-hook-value):
* files.el (file-expand-wildcards):
* font-lock.el (font-lock-update-removed-keyword-alist):
* font-lock.el (font-lock-remove-keywords):
* frame.el (frame-initialize):
* frame.el (frame-notice-user-settings):
* frame.el (set-frame-font):
* frame.el (delete-other-frames):
* frame.el (get-frame-for-buffer-noselect):
* gnuserv.el (gnuserv-kill-buffer-function):
* gnuserv.el (gnuserv-check-device):
* gnuserv.el (gnuserv-kill-client):
* gnuserv.el (gnuserv-buffer-done-1):
* gtk-font-menu.el (gtk-reset-device-font-menus):
* gutter-items.el (buffers-tab-items):
* gutter.el (set-gutter-element-visible-p):
* info.el (Info-find-file-node):
* info.el (Info-history-add):
* info.el (Info-build-annotation-completions):
* info.el (Info-index):
* info.el (Info-reannotate-node):
* itimer.el (delete-itimer):
* itimer.el (start-itimer):
* lib-complete.el (lib-complete:cache-completions):
* loadhist.el (unload-feature):
* menubar-items.el (build-buffers-menu-internal):
* menubar.el (delete-menu-item):
* menubar.el (relabel-menu-item):
* msw-font-menu.el (mswindows-reset-device-font-menus):
* mule/make-coding-system.el (fixed-width-generate-helper):
* next-error.el (next-error-find-buffer):
* obsolete.el:
* obsolete.el (find-non-ascii-charset-string):
* obsolete.el (find-non-ascii-charset-region):
* occur.el (multi-occur-by-filename-regexp):
* occur.el (occur-1):
* packages.el (packages-package-hierarchy-directory-names):
* packages.el (package-get-key-1):
* process.el (setenv):
* simple.el (undo):
* simple.el (handle-pre-motion-command-current-command-is-motion):
* sound.el (load-sound-file):
* wid-edit.el (widget-field-value-delete):
* wid-edit.el (widget-checklist-match-inline):
* wid-edit.el (widget-checklist-match-find):
* wid-edit.el (widget-editable-list-delete-at):
* wid-edit.el (widget-editable-list-entry-create):
* window.el (quit-window):
* x-font-menu.el (x-reset-device-font-menus-core):
1. Replace (delq nil (mapcar ....)) with analogous (mapcan ...)
forms; this is in non-dumped files, it was done previously in
dumped files.
2. Replace (delq FOO (copy-sequence BAR)) with (remove* FOO BAR),
where #'eq and #'eql are equivalent
3. Replace (delq FOO BAR) with (delete* FOO BAR), where FOO is not
a non-fixnum number. Saves a little space in the dumped file
(since the compiler macro adds :test #'eq to the delete* call if
it's not clear that FOO is not a non-fixnum number).
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 01 May 2012 16:17:42 +0100 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
428 | 1 ;;; mwheel.el --- Mouse support for MS intelli-mouse type mice |
2 | |
3 ;; Copyright (C) 1998, Free Software Foundation, Inc. | |
4 ;; Maintainer: William M. Perry <wmperry@cs.indiana.edu> | |
5 ;; Keywords: mouse | |
6 | |
7 ;; This file is part of XEmacs. | |
8 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
9 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
10 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
11 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
12 ;; option) any later version. |
428 | 13 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
14 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
16 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
17 ;; for more details. |
428 | 18 |
19 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2546
diff
changeset
|
20 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
428 | 21 |
22 ;;; Synched up with: Not synched. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;; This code will enable the use of the infamous 'wheel' on the new | |
27 ;; crop of mice. Under XFree86 and the XSuSE X Servers, the wheel | |
28 ;; events are sent as button4/button5 events. | |
29 | |
30 ;; I for one would prefer some way of converting the button4/button5 | |
31 ;; events into different event types, like 'mwheel-up' or | |
32 ;; 'mwheel-down', but I cannot find a way to do this very easily (or | |
33 ;; portably), so for now I just live with it. | |
34 | |
35 ;; To enable this code, simply put this at the top of your .emacs | |
36 ;; file: | |
37 ;; | |
38 ;; (autoload 'mwheel-install "mwheel" "Enable mouse wheel support.") | |
39 ;; (mwheel-install) | |
40 | |
41 ;;; Code: | |
42 | |
43 (require 'custom) | |
44 (require 'cl) | |
45 | |
502 | 46 (globally-declare-fboundp |
47 '(event-basic-type | |
48 posn-window event-start mwheel-event-window mwheel-event-button)) | |
49 | |
1621 | 50 (defcustom mwheel-scroll-amount '(5 1 nil) |
428 | 51 "Amount to scroll windows by when spinning the mouse wheel. |
1621 | 52 A list with 3 elements specifying the amount to scroll on: a normal wheel |
53 event, a wheel event with the shift key pressed, and a wheel event with the | |
54 control key pressed, in that order. | |
428 | 55 |
56 Each item should be the number of lines to scroll, or `nil' for near | |
57 full screen. | |
58 A near full screen is `next-screen-context-lines' less than a full screen." | |
59 :group 'mouse | |
1621 | 60 :type '(list |
428 | 61 (choice :tag "Normal" |
62 (const :tag "Full screen" :value nil) | |
63 (integer :tag "Specific # of lines")) | |
64 (choice :tag "Shifted" | |
65 (const :tag "Full screen" :value nil) | |
1621 | 66 (integer :tag "Specific # of lines")) |
67 (choice :tag "Controlled" | |
68 (const :tag "Full screen" :value nil) | |
428 | 69 (integer :tag "Specific # of lines")))) |
70 | |
71 (defcustom mwheel-follow-mouse nil | |
72 "Whether the mouse wheel should scroll the window that the mouse is over. | |
73 This can be slightly disconcerting, but some people may prefer it." | |
74 :group 'mouse | |
75 :type 'boolean) | |
76 | |
77 (if (not (fboundp 'event-button)) | |
78 (defun mwheel-event-button (event) | |
79 (let ((x (symbol-name (event-basic-type event)))) | |
80 (if (not (string-match "^mouse-\\([0-9]+\\)" x)) | |
81 (error "Not a button event: %S" event)) | |
82 (string-to-int (substring x (match-beginning 1) (match-end 1))))) | |
83 (fset 'mwheel-event-button 'event-button)) | |
84 | |
85 (if (not (fboundp 'event-window)) | |
86 (defun mwheel-event-window (event) | |
87 (posn-window (event-start event))) | |
88 (fset 'mwheel-event-window 'event-window)) | |
89 | |
90 (defun mwheel-scroll (event) | |
91 (interactive "e") | |
92 (let ((curwin (if mwheel-follow-mouse | |
93 (prog1 | |
94 (selected-window) | |
95 (select-window (mwheel-event-window event))))) | |
96 (amt (if (memq 'shift (event-modifiers event)) | |
1621 | 97 (cadr mwheel-scroll-amount) |
98 (if (memq 'control (event-modifiers event)) | |
99 (caddr mwheel-scroll-amount) | |
100 (car mwheel-scroll-amount))))) | |
458 | 101 (unwind-protect |
102 (case (mwheel-event-button event) | |
103 (4 (scroll-down amt)) | |
104 (5 (scroll-up amt)) | |
105 (otherwise (error "Bad binding in mwheel-scroll"))) | |
106 (if curwin (select-window curwin))) | |
107 )) | |
428 | 108 |
109 ;;;###autoload | |
110 (defun mwheel-install () | |
111 "Enable mouse wheel support." | |
444 | 112 (interactive) |
1621 | 113 (let ((keys '([(mouse-4)] [(shift mouse-4)] [(control mouse-4)] |
114 [(mouse-5)] [(shift mouse-5)] [(control mouse-5)]))) | |
115 | |
428 | 116 ;; This condition-case is here because Emacs 19 will throw an error |
117 ;; if you try to define a key that it does not know about. I for one | |
118 ;; prefer to just unconditionally do a mwheel-install in my .emacs, so | |
119 ;; that if the wheeled-mouse is there, it just works, and this way it | |
120 ;; doesn't yell at me if I'm on my laptop or another machine, etc. | |
121 (condition-case () | |
122 (while keys | |
123 (define-key global-map (car keys) 'mwheel-scroll) | |
124 (setq keys (cdr keys))) | |
125 (error nil)))) | |
458 | 126 |
2546 | 127 ;;;###autoload |
128 (define-behavior 'mwheel | |
129 "This code enables the use of the infamous 'wheel' on the new | |
130 crop of mice. Under XFree86 and the XSuSE X Servers, the wheel | |
131 events are sent as button4/button5 events, which are automatically | |
132 set up to do scrolling in the expected way. The actual way that the | |
133 scrolling works can be controlled by `mwheel-scroll-amount' and | |
134 `mwheel-follow-mouse'." | |
135 :group 'mouse | |
136 :short-doc "Mouse wheel support for X Windows" | |
137 :enable 'mwheel-install) | |
138 | |
428 | 139 (provide 'mwheel) |
140 | |
141 ;;; mwheel.el ends here |