annotate lisp/emulation/keypad.el @ 89626:e2d5f38e23b4

(Fdefine_key): Fix handling of Lucid style event type list.
author Kenichi Handa <handa@m17n.org>
date Mon, 17 Nov 2003 01:06:37 +0000
parents db33d6285e97
children 68c22ea6027c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
3 ;; Copyright (C) 2002 Free Software Foundation, Inc.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
4
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
5 ;; 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
6 ;; Keywords: keyboard convenience
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
7
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
8 ;; 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
9
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
10 ;; 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
11 ;; 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
12 ;; 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
13 ;; any later version.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
14
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
15 ;; 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
16 ;; 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
17 ;; 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
18 ;; 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
19
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
20 ;; 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
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
24
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
25 ;;; Commentary:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
26
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
27 ;; 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
28 ;; 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
29 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
30 ;; With the following setup, the keypad can be used for numeric data
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
31 ;; entry when NumLock is off, and to give numeric prefix arguments to
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
32 ;; 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
33 ;;
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
34 ;; keypad-setup => Plain Numeric Keypad
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
35 ;; 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
36 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
37 ;; +--------+--------+--------+
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
38 ;; | M-7 | M-8 | M-9 | <- numlock on
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
39 ;; | 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
40 ;; +--------+--------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
41 ;; | 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
42 ;; | 4 | 5 | 6 |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
43 ;; +--------+--------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
44 ;; | 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
45 ;; | 1 | 2 | 3 |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
46 ;; +--------+--------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
47 ;; | M-0 | M-- |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
48 ;; | 0 | . |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
49 ;; +-----------------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
50
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
51 ;; The following keypad setup is used for navigation together with
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
52 ;; modes like cua-mode which uses shifted movement keys to extend the
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
53 ;; region.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
54 ;;
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
55 ;; keypad-setup => Cursor keys
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
56 ;; 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
57 ;;
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
58 ;; +--------+--------+--------+
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
59 ;; | S-home | S-up | S-PgUp | <- shifted, numlock off
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
60 ;; | 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
61 ;; +--------+--------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
62 ;; | 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
63 ;; | left | space | right |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
64 ;; +--------+--------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
65 ;; | 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
66 ;; | end | down | PgDn |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
67 ;; +--------+--------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
68 ;; | S-insert |S-delete|
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
69 ;; | insert | delete |
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
70 ;; +-----------------+--------+
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
71
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
72 ;; The following setup binds the unshifted keypad keys to plain
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
73 ;; numeric keys when NumLock is either on or off, but the decimal key
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
74 ;; produces either a . (NumLock off) or a , (NumLock on). This is
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
75 ;; useful for e.g. Danish users where the decimal separator is a
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
76 ;; comma.
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
77 ;;
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
78 ;; keypad-setup => Plain Numeric Keypad
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
79 ;; keypad-numlock-setup => Numeric Keypad with Decimal key: ,
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
80 ;;
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
81 ;; +--------+--------+--------+
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
82 ;; | 7 | 8 | 9 | <- numlock on
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
83 ;; | 7 | 8 | 9 | <- numlock off
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
84 ;; +--------+--------+--------+
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
85 ;; | 4 | 5 | 6 |
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
86 ;; | 4 | 5 | 6 |
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
87 ;; +--------+--------+--------+
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
88 ;; | 1 | 2 | 3 |
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
89 ;; | 1 | 2 | 3 |
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
90 ;; +--------+--------+--------+
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
91 ;; | 0 | , |
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
92 ;; | 0 | . |
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
93 ;; +-----------------+--------+
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
94
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
95 ;;; Code:
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
96
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
97 (provide 'keypad)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
98
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
99 ;;; Customization
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
100
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
101 ;;;###autoload
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
102 (defcustom keypad-setup nil
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
103 "Specifies the keypad setup for unshifted keypad keys when NumLock is off.
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
104 When selecting the plain numeric keypad setup, the character returned by the
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
105 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
106 :set (lambda (symbol value)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
107 (if value
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
108 (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
109 :initialize 'custom-initialize-default
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
110 :link '(emacs-commentary-link "keypad.el")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
111 :version "21.4"
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
112 :type '(choice (const :tag "Plain numeric keypad" numeric)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
113 (character :tag "Numeric Keypad with Decimal Key"
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
114 :match (lambda (widget value) (integerp value))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
115 :value ?.)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47484
diff changeset
116 (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
117 (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
118 (const :tag "Shifted cursor keys" S-cursor)
47484
02bdb3eae562 (keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents: 45990
diff changeset
119 (const :tag "Unspecified/User-defined" none)
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
120 (other :tag "Keep existing bindings" nil))
45990
f9d81d6b86b5 Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents: 45953
diff changeset
121 :require 'keypad
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
122 :group 'keyboard)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
123
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
124 ;;;###autoload
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
125 (defcustom keypad-numlock-setup nil
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
126 "Specifies the keypad setup for unshifted keypad keys when NumLock is on.
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
127 When selecting the plain numeric keypad setup, the character returned by the
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
128 decimal key must be specified."
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
129 :set (lambda (symbol value)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
130 (if value
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
131 (keypad-setup value t nil value)))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
132 :initialize 'custom-initialize-default
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
133 :link '(emacs-commentary-link "keypad.el")
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
134 :version "21.4"
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
135 :type '(choice (const :tag "Plain numeric keypad" numeric)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
136 (character :tag "Numeric Keypad with Decimal Key"
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
137 :match (lambda (widget value) (integerp value))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
138 :value ?.)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47484
diff changeset
139 (const :tag "Numeric prefix arguments" prefix)
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
140 (const :tag "Cursor keys" cursor)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
141 (const :tag "Shifted cursor keys" S-cursor)
47484
02bdb3eae562 (keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents: 45990
diff changeset
142 (const :tag "Unspecified/User-defined" none)
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
143 (other :tag "Keep existing bindings" nil))
45990
f9d81d6b86b5 Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents: 45953
diff changeset
144 :require 'keypad
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
145 :group 'keyboard)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
146
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
147 ;;;###autoload
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
148 (defcustom keypad-shifted-setup nil
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
149 "Specifies the keypad setup for shifted keypad keys when NumLock is off.
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
150 When selecting the plain numeric keypad setup, the character returned by the
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
151 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
152 :set (lambda (symbol value)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
153 (if value
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
154 (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
155 :initialize 'custom-initialize-default
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
156 :link '(emacs-commentary-link "keypad.el")
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
157 :version "21.4"
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
158 :type '(choice (const :tag "Plain numeric keypad" numeric)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
159 (character :tag "Numeric Keypad with Decimal Key"
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
160 :match (lambda (widget value) (integerp value))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
161 :value ?.)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47484
diff changeset
162 (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
163 (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
164 (const :tag "Shifted cursor keys" S-cursor)
47484
02bdb3eae562 (keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents: 45990
diff changeset
165 (const :tag "Unspecified/User-defined" none)
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
166 (other :tag "Keep existing bindings" nil))
45990
f9d81d6b86b5 Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents: 45953
diff changeset
167 :require 'keypad
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
168 :group 'keyboard)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
169
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
170 ;;;###autoload
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
171 (defcustom keypad-numlock-shifted-setup nil
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
172 "Specifies the keypad setup for shifted keypad keys when NumLock is off.
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
173 When selecting the plain numeric keypad setup, the character returned by the
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
174 decimal key must be specified."
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
175 :set (lambda (symbol value)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
176 (if value
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
177 (keypad-setup value t t value)))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
178 :initialize 'custom-initialize-default
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
179 :link '(emacs-commentary-link "keypad.el")
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
180 :version "21.4"
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
181 :type '(choice (const :tag "Plain numeric keypad" numeric)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
182 (character :tag "Numeric Keypad with Decimal Key"
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
183 :match (lambda (widget value) (integerp value))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
184 :value ?.)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47484
diff changeset
185 (const :tag "Numeric prefix arguments" prefix)
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
186 (const :tag "Cursor keys" cursor)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
187 (const :tag "Shifted cursor keys" S-cursor)
47484
02bdb3eae562 (keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents: 45990
diff changeset
188 (const :tag "Unspecified/User-defined" none)
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
189 (other :tag "Keep existing bindings" nil))
45990
f9d81d6b86b5 Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents: 45953
diff changeset
190 :require 'keypad
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
191 :group 'keyboard)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
192
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
193
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
194 ;;;###autoload
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
195 (defun keypad-setup (setup &optional numlock shift decimal)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
196 "Set keypad bindings in function-key-map according to SETUP.
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
197 If optional second argument NUMLOCK is non-nil, the NumLock On bindings
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
198 are changed. Otherwise, the NumLock Off bindings are changed.
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
199 If optional third argument SHIFT is non-nil, the shifted keypad
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
200 keys are bound.
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
201
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
202 Setup Binding
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
203 -------------------------------------------------------------
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
204 '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
205 '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
206 'cursor Bind keypad keys to the cursor movement keys.
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
207 '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
208 '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
209 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
210 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
211
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
212 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
213 the decimal key on the keypad is mapped to DECIMAL instead of `.'"
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
214 (let* ((i 0)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
215 (var (cond
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
216 ((and (not numlock) (not shift)) 'keypad-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
217 ((and (not numlock) shift) 'keypad-shifted-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
218 ((and numlock (not shift)) 'keypad-numlock-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
219 ((and numlock shift) 'keypad-numlock-shifted-setup)))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
220 (kp (cond
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
221 ((eq var 'keypad-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
222 [kp-delete kp-insert kp-end kp-down kp-next kp-left
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
223 kp-space kp-right kp-home kp-up kp-prior])
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
224 ((eq var 'keypad-shifted-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
225 [S-kp-decimal S-kp-0 S-kp-1 S-kp-2 S-kp-3 S-kp-4
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
226 S-kp-5 S-kp-6 S-kp-7 S-kp-8 S-kp-9])
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
227 ((eq var 'keypad-numlock-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
228 [kp-decimal kp-0 kp-1 kp-2 kp-3 kp-4
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
229 kp-5 kp-6 kp-7 kp-8 kp-9])
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
230 ((eq var 'keypad-numlock-shifted-setup)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
231 [S-kp-delete S-kp-insert S-kp-end S-kp-down S-kp-next S-kp-left
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
232 S-kp-space S-kp-right S-kp-home S-kp-up S-kp-prior])))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
233 (bind
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
234 (cond
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
235 ((or (eq setup 'numeric)
89490
db33d6285e97 (keypad-setup): Use characterp.
Dave Love <fx@gnu.org>
parents: 88123
diff changeset
236 (characterp setup))
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
237 (if (eq decimal 'numeric)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
238 (setq decimal nil))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
239 (vector (or decimal ?.) ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
240 ((eq setup 'prefix)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
241 [?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
242 ?\M-5 ?\M-6 ?\M-7 ?\M-8 ?\M-9])
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
243 ((eq setup 'cursor)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
244 [delete insert end down next left
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
245 space right home up prior])
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
246 ((eq setup 'S-cursor)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47484
diff changeset
247 [S-delete S-insert S-end S-down S-next S-left
45296
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
248 S-space S-right S-home S-up S-prior])
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
249 ((eq setup 'none)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
250 nil)
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
251 (t
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
252 (signal 'error (list "Unknown keypad setup: " setup))))))
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
253
eb7082dc04a0 Improved commentary.
Kim F. Storm <storm@cua.dk>
parents: 44938
diff changeset
254 (set var setup)
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
255
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
256 ;; 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
257 ;; 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
258 (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
259 (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
260
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
261 (while (< i 11)
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
262 (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
263 (if bind (vector (aref bind i))))
45953
66857c2230b6 Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents: 45296
diff changeset
264 (if (= i 6)
66857c2230b6 Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents: 45296
diff changeset
265 (cond ((eq (aref kp i) 'kp-space)
66857c2230b6 Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents: 45296
diff changeset
266 (define-key function-key-map [kp-begin]
66857c2230b6 Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents: 45296
diff changeset
267 (if bind (vector (aref bind i)))))
66857c2230b6 Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents: 45296
diff changeset
268 ((eq (aref kp i) 'S-kp-space)
66857c2230b6 Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents: 45296
diff changeset
269 (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
270 (if bind (vector (aref bind i)))))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47484
diff changeset
271
44938
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
272 (setq i (1+ i)))))
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
273
358d42530d42 Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
274 ;;; keypad.el ends here