Mercurial > emacs
annotate lisp/emulation/keypad.el @ 77352:9216901ae66e
** Send an email to the various distributions, including the GNOME
and KDE projects, to use the new Emacs icons in etc/images/icons.
Being done (see emacs-devel thread).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 20 Apr 2007 21:40:10 +0000 |
parents | cc42c775a741 |
children | ac0efac52065 95d0cdf160ea |
rev | line source |
---|---|
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1 ;;; keypad.el --- simplified keypad bindings |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
2 |
75223
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, |
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
4 ;; 2007 Free Software Foundation, Inc. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
5 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
6 ;; Author: Kim F. Storm <storm@cua.dk> |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
7 ;; Keywords: keyboard convenience |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
8 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
10 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
14 ;; any later version. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
15 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
20 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
25 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
26 ;;; Commentary: |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
27 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
28 ;; The keypad package allows easy binding of the keypad keys to |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
29 ;; various commonly used sets of commands. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
30 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
31 ;; With the following setup, the keypad can be used for numeric data |
45296 | 32 ;; entry when NumLock is off, and to give numeric prefix arguments to |
33 ;; emacs commands, when NumLock on on. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
34 ;; |
45296 | 35 ;; keypad-setup => Plain Numeric Keypad |
36 ;; keypad-numlock-setup => Prefix numeric args | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
37 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
38 ;; +--------+--------+--------+ |
45296 | 39 ;; | M-7 | M-8 | M-9 | <- numlock on |
40 ;; | 7 | 8 | 9 | <- numlock off | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
41 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
42 ;; | M-4 | M-5 | M-6 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
43 ;; | 4 | 5 | 6 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
44 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
45 ;; | M-1 | M-2 | M-3 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
46 ;; | 1 | 2 | 3 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
47 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
48 ;; | M-0 | M-- | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
49 ;; | 0 | . | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
50 ;; +-----------------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
51 |
45296 | 52 ;; The following keypad setup is used for navigation together with |
53 ;; modes like cua-mode which uses shifted movement keys to extend the | |
54 ;; region. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
55 ;; |
45296 | 56 ;; keypad-setup => Cursor keys |
57 ;; keypad-shifted-setup => Shifted cursor keys | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
58 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
59 ;; +--------+--------+--------+ |
45296 | 60 ;; | S-home | S-up | S-PgUp | <- shifted, numlock off |
61 ;; | Home | up | PgUp | <- unshifted, numlock off | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
62 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
63 ;; | S-left |S-space |S-right | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
64 ;; | left | space | right | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
65 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
66 ;; | S-end | S-down | S-PgDn | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
67 ;; | end | down | PgDn | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
68 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
69 ;; | S-insert |S-delete| |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
70 ;; | insert | delete | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
71 ;; +-----------------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
72 |
45296 | 73 ;; The following setup binds the unshifted keypad keys to plain |
74 ;; numeric keys when NumLock is either on or off, but the decimal key | |
75 ;; produces either a . (NumLock off) or a , (NumLock on). This is | |
76 ;; useful for e.g. Danish users where the decimal separator is a | |
77 ;; comma. | |
78 ;; | |
79 ;; keypad-setup => Plain Numeric Keypad | |
80 ;; keypad-numlock-setup => Numeric Keypad with Decimal key: , | |
81 ;; | |
82 ;; +--------+--------+--------+ | |
83 ;; | 7 | 8 | 9 | <- numlock on | |
84 ;; | 7 | 8 | 9 | <- numlock off | |
85 ;; +--------+--------+--------+ | |
86 ;; | 4 | 5 | 6 | | |
87 ;; | 4 | 5 | 6 | | |
88 ;; +--------+--------+--------+ | |
89 ;; | 1 | 2 | 3 | | |
90 ;; | 1 | 2 | 3 | | |
91 ;; +--------+--------+--------+ | |
92 ;; | 0 | , | | |
93 ;; | 0 | . | | |
94 ;; +-----------------+--------+ | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
95 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
96 ;;; Code: |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
97 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
98 (provide 'keypad) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
99 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
100 ;;; Customization |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
101 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
102 ;;;###autoload |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
103 (defcustom keypad-setup nil |
45296 | 104 "Specifies the keypad setup for unshifted keypad keys when NumLock is off. |
105 When selecting the plain numeric keypad setup, the character returned by the | |
106 decimal key must be specified." | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
107 :set (lambda (symbol value) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
108 (if value |
45296 | 109 (keypad-setup value nil nil value))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
110 :initialize 'custom-initialize-default |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
111 :link '(emacs-commentary-link "keypad.el") |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
112 :version "22.1" |
45296 | 113 :type '(choice (const :tag "Plain numeric keypad" numeric) |
114 (character :tag "Numeric Keypad with Decimal Key" | |
115 :match (lambda (widget value) (integerp value)) | |
116 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
117 (const :tag "Numeric prefix arguments" prefix) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
118 (const :tag "Cursor keys" cursor) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
119 (const :tag "Shifted cursor keys" S-cursor) |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
120 (const :tag "Unspecified/User-defined" none) |
45296 | 121 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
122 :require 'keypad |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
123 :group 'keyboard) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
124 |
45296 | 125 ;;;###autoload |
126 (defcustom keypad-numlock-setup nil | |
127 "Specifies the keypad setup for unshifted keypad keys when NumLock is on. | |
128 When selecting the plain numeric keypad setup, the character returned by the | |
129 decimal key must be specified." | |
130 :set (lambda (symbol value) | |
131 (if value | |
132 (keypad-setup value t nil value))) | |
133 :initialize 'custom-initialize-default | |
134 :link '(emacs-commentary-link "keypad.el") | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
135 :version "22.1" |
45296 | 136 :type '(choice (const :tag "Plain numeric keypad" numeric) |
137 (character :tag "Numeric Keypad with Decimal Key" | |
138 :match (lambda (widget value) (integerp value)) | |
139 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
140 (const :tag "Numeric prefix arguments" prefix) |
45296 | 141 (const :tag "Cursor keys" cursor) |
142 (const :tag "Shifted cursor keys" S-cursor) | |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
143 (const :tag "Unspecified/User-defined" none) |
45296 | 144 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
145 :require 'keypad |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
146 :group 'keyboard) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
147 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
148 ;;;###autoload |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
149 (defcustom keypad-shifted-setup nil |
45296 | 150 "Specifies the keypad setup for shifted keypad keys when NumLock is off. |
151 When selecting the plain numeric keypad setup, the character returned by the | |
152 decimal key must be specified." | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
153 :set (lambda (symbol value) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
154 (if value |
45296 | 155 (keypad-setup value nil t value))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
156 :initialize 'custom-initialize-default |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
157 :link '(emacs-commentary-link "keypad.el") |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
158 :version "22.1" |
45296 | 159 :type '(choice (const :tag "Plain numeric keypad" numeric) |
160 (character :tag "Numeric Keypad with Decimal Key" | |
161 :match (lambda (widget value) (integerp value)) | |
162 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
163 (const :tag "Numeric prefix arguments" prefix) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
164 (const :tag "Cursor keys" cursor) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
165 (const :tag "Shifted cursor keys" S-cursor) |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
166 (const :tag "Unspecified/User-defined" none) |
45296 | 167 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
168 :require 'keypad |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
169 :group 'keyboard) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
170 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
171 ;;;###autoload |
45296 | 172 (defcustom keypad-numlock-shifted-setup nil |
173 "Specifies the keypad setup for shifted keypad keys when NumLock is off. | |
174 When selecting the plain numeric keypad setup, the character returned by the | |
175 decimal key must be specified." | |
176 :set (lambda (symbol value) | |
177 (if value | |
178 (keypad-setup value t t value))) | |
179 :initialize 'custom-initialize-default | |
180 :link '(emacs-commentary-link "keypad.el") | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
181 :version "22.1" |
45296 | 182 :type '(choice (const :tag "Plain numeric keypad" numeric) |
183 (character :tag "Numeric Keypad with Decimal Key" | |
184 :match (lambda (widget value) (integerp value)) | |
185 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
186 (const :tag "Numeric prefix arguments" prefix) |
45296 | 187 (const :tag "Cursor keys" cursor) |
188 (const :tag "Shifted cursor keys" S-cursor) | |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
189 (const :tag "Unspecified/User-defined" none) |
45296 | 190 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
191 :require 'keypad |
45296 | 192 :group 'keyboard) |
193 | |
194 | |
195 ;;;###autoload | |
196 (defun keypad-setup (setup &optional numlock shift decimal) | |
75223
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
197 "Set keypad bindings in `function-key-map' according to SETUP. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
198 If optional second argument NUMLOCK is non-nil, the NumLock On bindings |
75223
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
199 are changed. Otherwise, the NumLock Off bindings are changed. |
45296 | 200 If optional third argument SHIFT is non-nil, the shifted keypad |
201 keys are bound. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
202 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
203 Setup Binding |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
204 ------------------------------------------------------------- |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
205 'prefix Command prefix argument, i.e. M-0 .. M-9 and M-- |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
206 'S-cursor Bind shifted keypad keys to the shifted cursor movement keys. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
207 'cursor Bind keypad keys to the cursor movement keys. |
45296 | 208 'numeric Plain numeric keypad, i.e. 0 .. 9 and . (or DECIMAL arg) |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
209 'none Removes all bindings for keypad keys in function-key-map; |
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
210 this enables any user-defined bindings for the keypad keys |
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
211 in the global and local keymaps. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
212 |
45296 | 213 If SETUP is 'numeric and the optional fourth argument DECIMAL is non-nil, |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
214 the decimal key on the keypad is mapped to DECIMAL instead of `.'" |
45296 | 215 (let* ((i 0) |
216 (var (cond | |
217 ((and (not numlock) (not shift)) 'keypad-setup) | |
218 ((and (not numlock) shift) 'keypad-shifted-setup) | |
219 ((and numlock (not shift)) 'keypad-numlock-setup) | |
220 ((and numlock shift) 'keypad-numlock-shifted-setup))) | |
221 (kp (cond | |
222 ((eq var 'keypad-setup) | |
223 [kp-delete kp-insert kp-end kp-down kp-next kp-left | |
224 kp-space kp-right kp-home kp-up kp-prior]) | |
225 ((eq var 'keypad-shifted-setup) | |
226 [S-kp-decimal S-kp-0 S-kp-1 S-kp-2 S-kp-3 S-kp-4 | |
227 S-kp-5 S-kp-6 S-kp-7 S-kp-8 S-kp-9]) | |
228 ((eq var 'keypad-numlock-setup) | |
229 [kp-decimal kp-0 kp-1 kp-2 kp-3 kp-4 | |
230 kp-5 kp-6 kp-7 kp-8 kp-9]) | |
231 ((eq var 'keypad-numlock-shifted-setup) | |
232 [S-kp-delete S-kp-insert S-kp-end S-kp-down S-kp-next S-kp-left | |
233 S-kp-space S-kp-right S-kp-home S-kp-up S-kp-prior]))) | |
234 (bind | |
235 (cond | |
236 ((or (eq setup 'numeric) | |
237 (char-valid-p setup)) | |
238 (if (eq decimal 'numeric) | |
239 (setq decimal nil)) | |
240 (vector (or decimal ?.) ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) | |
241 ((eq setup 'prefix) | |
242 [?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4 | |
243 ?\M-5 ?\M-6 ?\M-7 ?\M-8 ?\M-9]) | |
244 ((eq setup 'cursor) | |
245 [delete insert end down next left | |
246 space right home up prior]) | |
247 ((eq setup 'S-cursor) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
248 [S-delete S-insert S-end S-down S-next S-left |
45296 | 249 S-space S-right S-home S-up S-prior]) |
250 ((eq setup 'none) | |
251 nil) | |
252 (t | |
253 (signal 'error (list "Unknown keypad setup: " setup)))))) | |
254 | |
255 (set var setup) | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
256 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
257 ;; Bind the keys in KP list to BIND list in function-key-map. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
258 ;; If BIND is nil, all bindings for the keys are removed. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
259 (if (not (boundp 'function-key-map)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
260 (setq function-key-map (make-sparse-keymap))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
261 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
262 (while (< i 11) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
263 (define-key function-key-map (vector (aref kp i)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
264 (if bind (vector (aref bind i)))) |
45953
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
265 (if (= i 6) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
266 (cond ((eq (aref kp i) 'kp-space) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
267 (define-key function-key-map [kp-begin] |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
268 (if bind (vector (aref bind i))))) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
269 ((eq (aref kp i) 'S-kp-space) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
270 (define-key function-key-map [S-kp-begin] |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
271 (if bind (vector (aref bind i))))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
272 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
273 (setq i (1+ i))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
274 |
52401 | 275 ;;; arch-tag: 0899d2bd-9e12-4b4e-9aef-d0014d3b6414 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
276 ;;; keypad.el ends here |