From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: keypad-*-setup Date: Wed, 12 Sep 2007 10:22:23 -0700 Message-ID: References: <87fy1k3m2s.fsf@kfs-lx.testafd.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0002_01C7F526.CF48B700" X-Trace: sea.gmane.org 1189617826 1076 80.91.229.12 (12 Sep 2007 17:23:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 Sep 2007 17:23:46 +0000 (UTC) Cc: "Kim F. Storm" To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 12 19:23:43 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IVVw8-0008D2-9w for ged-emacs-devel@m.gmane.org; Wed, 12 Sep 2007 19:23:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IVVw7-0003ip-PD for ged-emacs-devel@m.gmane.org; Wed, 12 Sep 2007 13:23:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IVVw3-0003h5-Un for emacs-devel@gnu.org; Wed, 12 Sep 2007 13:23:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IVVw2-0003fy-PJ for emacs-devel@gnu.org; Wed, 12 Sep 2007 13:23:31 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IVVw2-0003fj-Ll for emacs-devel@gnu.org; Wed, 12 Sep 2007 13:23:30 -0400 Original-Received: from agminet01.oracle.com ([141.146.126.228]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IVVw1-00057r-VB for emacs-devel@gnu.org; Wed, 12 Sep 2007 13:23:30 -0400 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l8CHN5Mc017455; Wed, 12 Sep 2007 12:23:05 -0500 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id l8B1OQOg012442; Wed, 12 Sep 2007 11:23:04 -0600 Original-Received: from dhcp-4op11-4op12-west-130-35-178-203.us.oracle.com by acsmt350.oracle.com with ESMTP id 3206199521189617743; Wed, 12 Sep 2007 10:22:23 -0700 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <87fy1k3m2s.fsf@kfs-lx.testafd.dk> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-Detected-Kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:78696 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0002_01C7F526.CF48B700 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I've tried to improve the doc for this feature (library keypad.el) - both the Emacs manual and the doc strings and Customize tags. I have not tried to mess with texinfo. I will make any changes people think are needed to the attached doc and code files, and I will then pass the result on to someone else to modify the texinfo and install in CVS. Attached is a patch for keypad.el. I did not change the behavior of the code; I made only cosmetic changes, e.g. doc and Commentary. Attached is a text file for the Emacs manual. I propose these changes: - Node "Function Keys": Remove all text starting with "Many keyboards have a "numeric keypad...". Put that topic in its own node (see next). - New node, "Numeric Keypad", child of "Key Bindings", Next node after "Function Keys". See attached file keypad-doc.txt for the text. Some questions: 1. A nil ("No change (keep existing bindings)") value for the setup options seems to be a no-op. What is its use; what does it do (change)? If it does nothing, then perhaps we should remove it (and modify the doc accordingly). Here is the :set code for `defcustom' - it seems to do nothing if `value' is nil. Am I reading this wrong? :set (lambda (symbol value) (when value (keypad-setup value nil nil value))) 2. Do we really need a separate `numeric' choice? Why not always specify an explicit decimal-point? That is, why not get rid of the value `numeric' ("Numeric with standard decimal point") and just use the version that specifies a decimal-point character - it uses `.' as the default value, which is the same as choosing the option value `numeric'. 3. Shouldn't `integerp' be `char-valid-p' in the test for the value? :match (lambda (widget value) (integerp value)). In function `keypad-setup', `char-valid-p' is used to test the character. ------=_NextPart_000_0002_01C7F526.CF48B700 Content-Type: application/octet-stream; name="keypad-2007-09-12.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="keypad-2007-09-12.patch" *** keypad-patched-2007-09-11a.el Wed Sep 12 09:46:36 2007=0A= --- keypad-CVS-2007-09-11.el Tue Sep 11 08:27:10 2007=0A= ***************=0A= *** 25,92 ****=0A= =0A= ;;; Commentary:=0A= =0A= ! ;; The keypad package allows easy binding of the numeric keypad keys=0A= ! ;; to various commonly used sets of commands. It does this by binding=0A= ! ;; those keys in `function-key-map'.=0A= ;;=0A= ! ;; By `keypad' is meant here the 11 keys of the numeric keypad. Each=0A= ! ;; of these keys typically has two physical labels, one of which is a=0A= ! ;; decimal digit (0-9) or the decimal point (`.'), and the other of=0A= ! ;; which is a cursor-movement arrow (left, right, up, down), `Home',=0A= ! ;; `End', `Ins', `Del', `PgUp', `PgDn', or space (empty).=0A= ;;=0A= ! ;; You can define four keypad setups, one for each combination of=0A= ! ;; NumLock and the Shift key: NumLock on or off and Shift key pressed=0A= ! ;; or not. These setups are customizable user options:=0A= ! ;;=0A= ! ;; `keypad-setup' - NumLock off, unshifted=0A= ! ;; `keypad-numlock-setup' - NumLock on, unshifted=0A= ! ;; `keypad-shifted-setup' - NumLock off, shifted=0A= ! ;; `keypad-numlock-shifted-setup' - NumLock on, shifted=0A= ! ;;=0A= ! ;; You can customize *each* of these setups to *any* of the following=0A= ! ;; behaviors. Each behavior affects all keypad keys in the same way=0A= ! ;; (see exception for the decimal-point key). As an example, consider=0A= ! ;; the `' key, which is the key labeled with `8' and an up=0A= ! ;; arrow.=0A= ! ;;=0A= ! ;; 1. Use the numeric value. E.g., do what the main-keyboard `8' key=0A= ! ;; does.=0A= ! ;;=0A= ! ;; 2. Same as #1, except the decimal-point key (`.') is mapped to=0A= ! ;; another character, which is typically a different decimal-point=0A= ! ;; character (e.g. `,').=0A= ! ;;=0A= ! ;; 3. Use the non-numeric value. E.g., do what the main-keyboard `up'=0A= ! ;; key (up arrow) does.=0A= ! ;;=0A= ! ;; 4. Use the numeric value as a prefix argument for an Emacs command.=0A= ! ;; E.g., do what `M-8' does. The decimal-point key, `.', acts like=0A= ! ;; `M--'.=0A= ! ;;=0A= ! ;; 5. Use the shifted non-numeric value. E.g., do what `S-up' does.=0A= ! ;;=0A= ! ;; 6. Unspecified (user-defined) behavior. E.g. make `'=0A= ! ;; undefined in `function-key-map'. Choose this to define a custom=0A= ! ;; behavior for a keypad setup.=0A= ! ;;=0A= ! ;; 7. Do nothing special - do whatever the keypad key would normally=0A= ! ;; do. E.g., if `' is not itself bound, then it is, by=0A= ! ;; default, translated to the `8' key. This is the default=0A= ! ;; behavior for each keypad setup.=0A= ! ;;=0A= ! ;; Here are a few possibilities, as examples.=0A= ! ;;=0A= ! ;; 1. Define `keypad-setup' as `numeric' ("Numeric with standard=0A= ! ;; decimal-point key"). Define `keypad-numlock-setup' as `prefix'=0A= ! ;; ("Prefix argument"). With these setups, the keypad can be used=0A= ! ;; for numeric data entry when NumLock is off, and to provide=0A= ! ;; numeric prefix arguments to emacs commands, when NumLock is on.=0A= ! ;; Ignoring the shifted possibilities, this is the picture:=0A= ;;=0A= ;; +--------+--------+--------+=0A= ! ;; | M-7 | M-8 | M-9 | <- keypad-numlock-setup: NumLock on=0A= ! ;; | 7 | 8 | 9 | <- keypad-setup: NumLock off=0A= ;; +--------+--------+--------+=0A= ;; | M-4 | M-5 | M-6 |=0A= ;; | 4 | 5 | 6 |=0A= --- 25,43 ----=0A= =0A= ;;; Commentary:=0A= =0A= ! ;; The keypad package allows easy binding of the keypad keys to=0A= ! ;; various commonly used sets of commands.=0A= ;;=0A= ! ;; With the following setup, the keypad can be used for numeric data=0A= ! ;; entry when NumLock is off, and to give numeric prefix arguments to=0A= ! ;; emacs commands, when NumLock on on.=0A= ;;=0A= ! ;; keypad-setup =3D> Plain Numeric Keypad=0A= ! ;; keypad-numlock-setup =3D> Prefix numeric args=0A= ;;=0A= ;; +--------+--------+--------+=0A= ! ;; | M-7 | M-8 | M-9 | <- numlock on=0A= ! ;; | 7 | 8 | 9 | <- numlock off=0A= ;; +--------+--------+--------+=0A= ;; | M-4 | M-5 | M-6 |=0A= ;; | 4 | 5 | 6 |=0A= ***************=0A= *** 97,118 ****=0A= ;; | M-0 | M-- |=0A= ;; | 0 | . |=0A= ;; +-----------------+--------+=0A= ;;=0A= ! ;; Could you define these two options the other way around, so that=0A= ! ;; NumLock off means prefix arguments? Yes.=0A= ! ;;=0A= ! ;; 2. Define `keypad-setup' as `cursor' ("Non-numeric"), which is=0A= ! ;; generally for cursor movement. Define `keypad-shifted-setup' as=0A= ! ;; `S-cursor' ("Shifted non-numeric"). With both of these setups,=0A= ! ;; keys have their non-numeric meaning. By default, that means=0A= ! ;; generally cursor movement. The shifted movement keys are useful=0A= ! ;; for modes such as Delete Selection and CUA that use them to=0A= ! ;; extend the region. Ignoring the NumLock possibilities, this is=0A= ! ;; the picture:=0A= ;;=0A= ;; +--------+--------+--------+=0A= ! ;; | S-home | S-up | S-PgUp | <- keypad-shifted-setup: shifted=0A= ! ;; | Home | up | PgUp | <- keypad-setup: unshifted=0A= ;; +--------+--------+--------+=0A= ;; | S-left |S-space |S-right |=0A= ;; | left | space | right |=0A= --- 48,64 ----=0A= ;; | M-0 | M-- |=0A= ;; | 0 | . |=0A= ;; +-----------------+--------+=0A= + =0A= + ;; The following keypad setup is used for navigation together with=0A= + ;; modes like cua-mode which uses shifted movement keys to extend the=0A= + ;; region.=0A= ;;=0A= ! ;; keypad-setup =3D> Cursor keys=0A= ! ;; keypad-shifted-setup =3D> Shifted cursor keys=0A= ;;=0A= ;; +--------+--------+--------+=0A= ! ;; | S-home | S-up | S-PgUp | <- shifted, numlock off=0A= ! ;; | Home | up | PgUp | <- unshifted, numlock off=0A= ;; +--------+--------+--------+=0A= ;; | S-left |S-space |S-right |=0A= ;; | left | space | right |=0A= ***************=0A= *** 123,148 ****=0A= ;; | S-insert |S-delete|=0A= ;; | insert | delete |=0A= ;; +-----------------+--------+=0A= ! ;;=0A= ! ;; Again, however, there is no necessary relation between the setup=0A= ! ;; name and the chosen behavior. You could choose the "Shifted=0A= ! ;; non-numeric" behavior for the (unshifted) `keypad-setup'.=0A= ! ;;=0A= ! ;; 3. Define `keypad-setup' as `numeric' ("Numeric with standard=0A= ! ;; decimal point"). Define `keypad-numlock-setup' as `,' ("Numeric=0A= ! ;; with customized decimal point: ,"), that is, as 44, which is the=0A= ! ;; decimal value of the comma character. With these setups,=0A= ! ;; unshifted keypad keys are decimal digits, but the decimal-point=0A= ! ;; key (`.') is mapped to a different character for each setup.=0A= ! ;; With NumLock off, the decimal point is `.'; with NumLock on, it=0A= ! ;; is `,'.=0A= ;;=0A= ;; keypad-setup =3D> Plain Numeric Keypad=0A= ;; keypad-numlock-setup =3D> Numeric Keypad with Decimal key: ,=0A= ;;=0A= ;; +--------+--------+--------+=0A= ! ;; | 7 | 8 | 9 | <- keypad-numlock-setup: NumLock on=0A= ! ;; | 7 | 8 | 9 | <- keypad-setup: NumLock off=0A= ;; +--------+--------+--------+=0A= ;; | 4 | 5 | 6 |=0A= ;; | 4 | 5 | 6 |=0A= --- 69,87 ----=0A= ;; | S-insert |S-delete|=0A= ;; | insert | delete |=0A= ;; +-----------------+--------+=0A= ! =0A= ! ;; The following setup binds the unshifted keypad keys to plain=0A= ! ;; numeric keys when NumLock is either on or off, but the decimal key=0A= ! ;; produces either a . (NumLock off) or a , (NumLock on). This is=0A= ! ;; useful for e.g. Danish users where the decimal separator is a=0A= ! ;; comma.=0A= ;;=0A= ;; keypad-setup =3D> Plain Numeric Keypad=0A= ;; keypad-numlock-setup =3D> Numeric Keypad with Decimal key: ,=0A= ;;=0A= ;; +--------+--------+--------+=0A= ! ;; | 7 | 8 | 9 | <- numlock on=0A= ! ;; | 7 | 8 | 9 | <- numlock off=0A= ;; +--------+--------+--------+=0A= ;; | 4 | 5 | 6 |=0A= ;; | 4 | 5 | 6 |=0A= ***************=0A= *** 150,160 ****=0A= ;; | 1 | 2 | 3 |=0A= ;; | 1 | 2 | 3 |=0A= ;; +--------+--------+--------+=0A= ! ;; | 0 | , | <- comma=0A= ! ;; | 0 | . | <- period=0A= ;; +-----------------+--------+=0A= - ;;=0A= - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=0A= =0A= ;;; Code:=0A= =0A= --- 89,97 ----=0A= ;; | 1 | 2 | 3 |=0A= ;; | 1 | 2 | 3 |=0A= ;; +--------+--------+--------+=0A= ! ;; | 0 | , |=0A= ! ;; | 0 | . |=0A= ;; +-----------------+--------+=0A= =0A= ;;; Code:=0A= =0A= ***************=0A= *** 164,277 ****=0A= =0A= ;;;###autoload=0A= (defcustom keypad-setup nil=0A= ! "Numeric keypad setup for unshifted keys when NumLock is off."=0A= ! :set (lambda (symbol value) (when value (keypad-setup value nil nil = value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice=0A= ! (const :tag "Numeric with standard decimal point" numeric)=0A= ! (character :tag "Numeric with customized decimal point"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Prefix argument" prefix)=0A= ! (const :tag "Non-numeric" cursor)=0A= ! (const :tag "Shifted non-numeric" S-cursor)=0A= ! (const :tag "Unspecified (user-defined)" none)=0A= ! (other :tag "No change (keep existing bindings)" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defcustom keypad-numlock-setup nil=0A= ! "Numeric keypad setup for unshifted keys when NumLock is on."=0A= ! :set (lambda (symbol value) (when value (keypad-setup value t nil = value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice=0A= ! (const :tag "Numeric with standard decimal point" numeric)=0A= ! (character :tag "Numeric with customized decimal point"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Prefix argument" prefix)=0A= ! (const :tag "Non-numeric" cursor)=0A= ! (const :tag "Shifted non-numeric" S-cursor)=0A= ! (const :tag "Unspecified (user-defined)" none)=0A= ! (other :tag "No change (keep existing bindings)" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defcustom keypad-shifted-setup nil=0A= ! "Numeric keypad setup for shifted keys when NumLock is off."=0A= ! :set (lambda (symbol value) (when value (keypad-setup value nil t = value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice=0A= ! (const :tag "Numeric with standard decimal point" numeric)=0A= ! (character :tag "Numeric with customized decimal point"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Prefix argument" prefix)=0A= ! (const :tag "Non-numeric" cursor)=0A= ! (const :tag "Shifted non-numeric" S-cursor)=0A= ! (const :tag "Unspecified (user-defined)" none)=0A= ! (other :tag "No change (keep existing bindings)" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defcustom keypad-numlock-shifted-setup nil=0A= ! "Numeric keypad setup for shifted keys when NumLock is on."=0A= ! :set (lambda (symbol value) (when value (keypad-setup value t t = value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice=0A= ! (const :tag "Numeric with standard decimal point" numeric)=0A= ! (character :tag "Numeric with customized decimal point"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Prefix argument" prefix)=0A= ! (const :tag "Non-numeric" cursor)=0A= ! (const :tag "Shifted non-numeric" S-cursor)=0A= ! (const :tag "Unspecified (user-defined)" none)=0A= ! (other :tag "No change (keep existing bindings)" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defun keypad-setup (setup &optional numlock shift decimal)=0A= ! "Set bindings for numeric keypad in `function-key-map'.=0A= ! Argument SETUP determines the keypad key bindings as follows:=0A= ! =0A= ! Setup Binding=0A= ! -------------------------------------------------------------=0A= ! 'numeric Numeric keypad keys: `.' (or DECIMAL) plus `0' through `9'.=0A= ! 'prefix Command prefix argument: `M--' and `M-0' through `M-9'.=0A= ! 'cursor Non-numeric keypad keys: `', `up', and so on.=0A= ! 'S-cursor Shifted non-numeric keypad keys.=0A= ! 'none Removes all bindings for keypad keys in `function-key-map'.=0A= ! Enables any user-defined bindings for the keypad keys in=0A= ! the global and local keymaps.=0A= ! =0A= If optional second argument NUMLOCK is non-nil, the NumLock On bindings=0A= are changed. Otherwise, the NumLock Off bindings are changed.=0A= - =0A= If optional third argument SHIFT is non-nil, the shifted keypad=0A= keys are bound.=0A= =0A= ! If SETUP is `numeric' and optional fourth argument DECIMAL is non-nil,=0A= ! then the keypad decimal-point key is mapped to DECIMAL (a character)=0A= ! instead of `.'"=0A= (let* ((i 0)=0A= ! (var (cond ((and (not numlock) (not shift)) 'keypad-setup)=0A= ((and (not numlock) shift) 'keypad-shifted-setup)=0A= ((and numlock (not shift)) 'keypad-numlock-setup)=0A= ((and numlock shift) = 'keypad-numlock-shifted-setup)))=0A= ! (kp (cond ((eq var 'keypad-setup)=0A= [kp-delete kp-insert kp-end kp-down kp-next kp-left=0A= kp-space kp-right kp-home kp-up = kp-prior])=0A= ((eq var 'keypad-shifted-setup)=0A= --- 101,225 ----=0A= =0A= ;;;###autoload=0A= (defcustom keypad-setup nil=0A= ! "Specifies the keypad setup for unshifted keypad keys when NumLock = is off.=0A= ! When selecting the plain numeric keypad setup, the character returned = by the=0A= ! decimal key must be specified."=0A= ! :set (lambda (symbol value)=0A= ! (if value=0A= ! (keypad-setup value nil nil value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice (const :tag "Plain numeric keypad" numeric)=0A= ! (character :tag "Numeric Keypad with Decimal Key"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Numeric prefix arguments" prefix)=0A= ! (const :tag "Cursor keys" cursor)=0A= ! (const :tag "Shifted cursor keys" S-cursor)=0A= ! (const :tag "Unspecified/User-defined" none)=0A= ! (other :tag "Keep existing bindings" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defcustom keypad-numlock-setup nil=0A= ! "Specifies the keypad setup for unshifted keypad keys when NumLock = is on.=0A= ! When selecting the plain numeric keypad setup, the character returned = by the=0A= ! decimal key must be specified."=0A= ! :set (lambda (symbol value)=0A= ! (if value=0A= ! (keypad-setup value t nil value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice (const :tag "Plain numeric keypad" numeric)=0A= ! (character :tag "Numeric Keypad with Decimal Key"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Numeric prefix arguments" prefix)=0A= ! (const :tag "Cursor keys" cursor)=0A= ! (const :tag "Shifted cursor keys" S-cursor)=0A= ! (const :tag "Unspecified/User-defined" none)=0A= ! (other :tag "Keep existing bindings" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defcustom keypad-shifted-setup nil=0A= ! "Specifies the keypad setup for shifted keypad keys when NumLock is = off.=0A= ! When selecting the plain numeric keypad setup, the character returned = by the=0A= ! decimal key must be specified."=0A= ! :set (lambda (symbol value)=0A= ! (if value=0A= ! (keypad-setup value nil t value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice (const :tag "Plain numeric keypad" numeric)=0A= ! (character :tag "Numeric Keypad with Decimal Key"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Numeric prefix arguments" prefix)=0A= ! (const :tag "Cursor keys" cursor)=0A= ! (const :tag "Shifted cursor keys" S-cursor)=0A= ! (const :tag "Unspecified/User-defined" none)=0A= ! (other :tag "Keep existing bindings" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= ;;;###autoload=0A= (defcustom keypad-numlock-shifted-setup nil=0A= ! "Specifies the keypad setup for shifted keypad keys when NumLock is = off.=0A= ! When selecting the plain numeric keypad setup, the character returned = by the=0A= ! decimal key must be specified."=0A= ! :set (lambda (symbol value)=0A= ! (if value=0A= ! (keypad-setup value t t value)))=0A= :initialize 'custom-initialize-default=0A= :link '(emacs-commentary-link "keypad.el")=0A= :version "22.1"=0A= ! :type '(choice (const :tag "Plain numeric keypad" numeric)=0A= ! (character :tag "Numeric Keypad with Decimal Key"=0A= :match (lambda (widget value) (integerp value))=0A= :value ?.)=0A= ! (const :tag "Numeric prefix arguments" prefix)=0A= ! (const :tag "Cursor keys" cursor)=0A= ! (const :tag "Shifted cursor keys" S-cursor)=0A= ! (const :tag "Unspecified/User-defined" none)=0A= ! (other :tag "Keep existing bindings" nil))=0A= :require 'keypad=0A= :group 'keyboard)=0A= =0A= + =0A= ;;;###autoload=0A= (defun keypad-setup (setup &optional numlock shift decimal)=0A= ! "Set keypad bindings in `function-key-map' according to SETUP.=0A= If optional second argument NUMLOCK is non-nil, the NumLock On bindings=0A= are changed. Otherwise, the NumLock Off bindings are changed.=0A= If optional third argument SHIFT is non-nil, the shifted keypad=0A= keys are bound.=0A= =0A= ! Setup Binding=0A= ! -------------------------------------------------------------=0A= ! 'prefix Command prefix argument, i.e. M-0 .. M-9 and M--=0A= ! 'S-cursor Bind shifted keypad keys to the shifted cursor movement = keys.=0A= ! 'cursor Bind keypad keys to the cursor movement keys.=0A= ! 'numeric Plain numeric keypad, i.e. 0 .. 9 and . (or DECIMAL arg)=0A= ! 'none Removes all bindings for keypad keys in function-key-map;=0A= ! this enables any user-defined bindings for the keypad keys=0A= ! in the global and local keymaps.=0A= ! =0A= ! If SETUP is 'numeric and the optional fourth argument DECIMAL is = non-nil,=0A= ! the decimal key on the keypad is mapped to DECIMAL instead of `.'"=0A= (let* ((i 0)=0A= ! (var (cond=0A= ! ((and (not numlock) (not shift)) 'keypad-setup)=0A= ((and (not numlock) shift) 'keypad-shifted-setup)=0A= ((and numlock (not shift)) 'keypad-numlock-setup)=0A= ((and numlock shift) 'keypad-numlock-shifted-setup)))=0A= ! (kp (cond=0A= ! ((eq var 'keypad-setup)=0A= [kp-delete kp-insert kp-end kp-down kp-next kp-left=0A= kp-space kp-right kp-home kp-up kp-prior])=0A= ((eq var 'keypad-shifted-setup)=0A= ***************=0A= *** 283,311 ****=0A= ((eq var 'keypad-numlock-shifted-setup)=0A= [S-kp-delete S-kp-insert S-kp-end S-kp-down = S-kp-next S-kp-left=0A= S-kp-space S-kp-right S-kp-home = S-kp-up S-kp-prior])))=0A= ! (bind (cond ((or (eq setup 'numeric) (char-valid-p setup))=0A= ! (when (eq decimal 'numeric) (setq decimal nil))=0A= (vector (or decimal ?.) ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 = ?8 ?9))=0A= ((eq setup 'prefix)=0A= ! [?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4 ?\M-5 ?\M-6 = ?\M-7 ?\M-8 ?\M-9])=0A= ((eq setup 'cursor)=0A= ! [delete insert end down next left space right = home up prior])=0A= ((eq setup 'S-cursor)=0A= [S-delete S-insert S-end S-down S-next S-left=0A= S-space S-right S-home S-up S-prior])=0A= ! ((eq setup 'none) nil)=0A= ! (t (signal 'error (list "Unknown keypad setup: " = setup))))))=0A= (set var setup)=0A= ! ;; Bind the keys in KP list to BIND list in `function-key-map'.=0A= ! ;; If BIND is nil, then all bindings for the keys are removed.=0A= ! (unless (boundp 'function-key-map) (setq function-key-map = (make-sparse-keymap)))=0A= (while (< i 11)=0A= ! (define-key function-key-map (vector (aref kp i)) (and bind = (vector (aref bind i))))=0A= ! (when (=3D i 6)=0A= (cond ((eq (aref kp i) 'kp-space)=0A= ! (define-key function-key-map [kp-begin] (and bind = (vector (aref bind i)))))=0A= ((eq (aref kp i) 'S-kp-space)=0A= ! (define-key function-key-map [S-kp-begin] (and bind = (vector (aref bind i)))))))=0A= (setq i (1+ i)))))=0A= =0A= ;;; arch-tag: 0899d2bd-9e12-4b4e-9aef-d0014d3b6414=0A= --- 231,275 ----=0A= ((eq var 'keypad-numlock-shifted-setup)=0A= [S-kp-delete S-kp-insert S-kp-end S-kp-down S-kp-next S-kp-left=0A= S-kp-space S-kp-right S-kp-home S-kp-up S-kp-prior])))=0A= ! (bind=0A= ! (cond=0A= ! ((or (eq setup 'numeric)=0A= ! (char-valid-p setup))=0A= ! (if (eq decimal 'numeric)=0A= ! (setq decimal nil))=0A= (vector (or decimal ?.) ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))=0A= ((eq setup 'prefix)=0A= ! [?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4=0A= ! ?\M-5 ?\M-6 ?\M-7 ?\M-8 ?\M-9])=0A= ((eq setup 'cursor)=0A= ! [delete insert end down next left=0A= ! space right home up prior])=0A= ((eq setup 'S-cursor)=0A= [S-delete S-insert S-end S-down S-next S-left=0A= S-space S-right S-home S-up S-prior])=0A= ! ((eq setup 'none)=0A= ! nil)=0A= ! (t=0A= ! (signal 'error (list "Unknown keypad setup: " setup))))))=0A= ! =0A= (set var setup)=0A= ! =0A= ! ;; Bind the keys in KP list to BIND list in function-key-map.=0A= ! ;; If BIND is nil, all bindings for the keys are removed.=0A= ! (if (not (boundp 'function-key-map))=0A= ! (setq function-key-map (make-sparse-keymap)))=0A= ! =0A= (while (< i 11)=0A= ! (define-key function-key-map (vector (aref kp i))=0A= ! (if bind (vector (aref bind i))))=0A= ! (if (=3D i 6)=0A= (cond ((eq (aref kp i) 'kp-space)=0A= ! (define-key function-key-map [kp-begin]=0A= ! (if bind (vector (aref bind i)))))=0A= ((eq (aref kp i) 'S-kp-space)=0A= ! (define-key function-key-map [S-kp-begin]=0A= ! (if bind (vector (aref bind i)))))))=0A= ! =0A= (setq i (1+ i)))))=0A= =0A= ;;; arch-tag: 0899d2bd-9e12-4b4e-9aef-d0014d3b6414=0A= ------=_NextPart_000_0002_01C7F526.CF48B700 Content-Type: text/plain; name="keypad-doc.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="keypad-doc.txt" Emacs-manual node "Function Keys"=0A= ---------------------------------=0A= =0A= Remove all text starting with "Many keyboards have a "numeric=0A= keypad...". Put that topic in its own node (see below).=0A= =0A= =0A= =0A= New Emacs-manual node (child of node "Key Bindings", Next node after=0A= "Function Keys")=0A= =0A= Numeric Keypad=0A= --------------=0A= =0A= Many keyboards have a numeric keypad, which is typically to the right=0A= of the main keyboard (main set of keys). For simplicity, in this=0A= section, "keypad" means this numeric keypad. =0A= =0A= More precisely, "keypad" refers here only to the 11 keys that each=0A= have two physical labels, one of which is a decimal digit (0-9) or the=0A= decimal point (`.'), and the other of which is a cursor-movement arrow=0A= (left, right, up, down), `Home', `End', `Ins', `Del', `PgUp', `PgDn',=0A= or space (empty).=0A= =0A= Other keys that might be physically nearby, such as the keypad PF keys=0A= (e.g. `') and the keys labeled `/', `*', `-', `+', and `Enter',=0A= are not considered part of the keypad, as the term is understood=0A= here.=0A= =0A= This means that only some of the keys with names starting with `kp-'=0A= are considered "keypad" keys in this section. For example, the nearby=0A= key labeled `/' is often named `', but it is not a numeric=0A= keypad key. Be aware that in some other contexts any key whose Emacs=0A= name starts with `kp-' might be considered a "keypad" key. See, for=0A= instance, (elisp) "Function Keys".=0A= =0A= The Shift key and the NumLock key modify the behavior of keys on the=0A= numeric keypad. The Shift key acts as usual. The NumLock key is=0A= usually near the keypad keys. It acts similarly to the Caps Lock key,=0A= but instead of toggling between uppercase and lowercase for the main=0A= keyboard it toggles the keypad keys between two possible modes:=0A= numeric and non-numeric. Like the Caps Lock key, and unlike the Shift=0A= key, NumLock is modal: hitting it once enters a mode that stays active=0A= until you hit it again to change the mode. NumLock is not a modifier=0A= key: you do not hold it down while hitting other keys.=0A= =0A= The keypad keys thus each have two possible NumLock behaviors. For=0A= example, a key labeled both `7' and `Home' might act alternately as a=0A= `7' key (in numeric mode) and a `Home' key (in non-numeric mode).=0A= Combining this with the possibility of two different behaviors=0A= provided by the Shift key, there are four possible behaviors for any=0A= keypad key: NumLock off, shifted or unshifted, or NumLock on, shifted=0A= or unshifted.=0A= =0A= A physical keypad key labeled `7' and `Home' represents the Emacs keys=0A= `' and `', depending on whether NumLock is on or off.=0A= These two Emacs keys need not be bound to the same commands as the=0A= keys `7' and `' of the main keyboard. By default, Emacs does=0A= translate keypad keys to the corresponding keys of the main keyboard,=0A= however (see (elisp) "Function Keys").=0A= =0A= So, for instance, when NumLock is on, hitting the keypad `7' and=0A= `Home' physical key produces the Emacs key sequence `', which is=0A= translated to `7', by default. When NumLock is off, hitting the same=0A= key produces `', which is translated to `', by default.=0A= =0A= Because of this automatic key translation, if you rebind a main=0A= keyboard key such as `7' or `', then your binding affects the=0A= equivalent keypad key too, `' or `'. Rebinding a=0A= keypad key such as `' directly does not, however, affect the=0A= corresponding key on the main keyboard (`7').=0A= =0A= Besides this automatic translation, you can define four keypad setups,=0A= one for each combination of NumLock and the Shift key: NumLock on or=0A= off and Shift key pressed or not. These setups are customizable user=0A= options:=0A= =0A= `keypad-setup' - NumLock off, unshifted=0A= `keypad-numlock-setup' - NumLock on, unshifted=0A= `keypad-shifted-setup' - NumLock off, shifted=0A= `keypad-numlock-shifted-setup' - NumLock on, shifted=0A= =0A= You can customize *each* of these setups to *any* of the following=0A= behaviors. Each behavior affects all keypad keys in the same way (see=0A= exception for the decimal-point key). As an example, consider the=0A= `' key, which is the key labeled with `8' and an up arrow.=0A= =0A= 1. Use the numeric value. E.g., do what the main-keyboard `8' key=0A= does.=0A= =0A= 2. Same as #1, except the decimal-point key (`.') is mapped to a=0A= specific character, which is typically a different decimal-point=0A= character (e.g. `,').=0A= =0A= 3. Use the non-numeric value. E.g., do what the main-keyboard `up'=0A= key (up arrow) does.=0A= =0A= 4. Use the numeric value as a prefix argument for an Emacs command.=0A= E.g., do what `M-8' does. The decimal-point key, `.', acts like=0A= `M--'.=0A= =0A= 5. Use the shifted non-numeric value. E.g., do what `S-up' does.=0A= =0A= 6. Unspecified (user-defined) behavior. E.g. make `' undefined=0A= in `function-key-map'. Choose this to define a custom behavior for=0A= a keypad setup.=0A= =0A= 7. Do nothing special - do whatever the keypad key would normally do.=0A= E.g., if `' is not itself bound, then it is, by default,=0A= translated to the `8' key. This is the default behavior for each=0A= keypad setup option.=0A= =0A= Here are a few possibilities, as examples.=0A= =0A= 1. Define `keypad-setup' as `numeric' ("Numeric with standard=0A= decimal-point key"). Define `keypad-numlock-setup' as `prefix'=0A= ("Prefix argument"). With these setups, the keypad can be used for=0A= numeric data entry when NumLock is off, and to provide numeric=0A= prefix arguments to emacs commands, when NumLock is on. Ignoring=0A= the shifted possibilities, this is the picture:=0A= =0A= +--------+--------+--------+=0A= | M-7 | M-8 | M-9 | <- keypad-numlock-setup: NumLock on=0A= | 7 | 8 | 9 | <- keypad-setup: NumLock off=0A= +--------+--------+--------+=0A= | M-4 | M-5 | M-6 |=0A= | 4 | 5 | 6 |=0A= +--------+--------+--------+=0A= | M-1 | M-2 | M-3 |=0A= | 1 | 2 | 3 |=0A= +--------+--------+--------+=0A= | M-0 | M-- |=0A= | 0 | . |=0A= +-----------------+--------+=0A= =0A= Could you define these two options the other way around, so that=0A= NumLock off means prefix arguments? Yes.=0A= =0A= 2. Define `keypad-setup' as `cursor' ("Non-numeric"), which is=0A= generally for cursor movement. Define `keypad-shifted-setup' as=0A= `S-cursor' ("Shifted non-numeric"). With both of these setups,=0A= keys have their non-numeric meaning. By default, that means=0A= generally cursor movement. The shifted movement keys are useful=0A= for modes such as Delete Selection and CUA that use them to extend=0A= the region. Ignoring the NumLock possibilities, this is the=0A= picture:=0A= =0A= +--------+--------+--------+=0A= | S-home | S-up | S-PgUp | <- keypad-shifted-setup: shifted=0A= | Home | up | PgUp | <- keypad-setup: unshifted=0A= +--------+--------+--------+=0A= | S-left |S-space |S-right |=0A= | left | space | right |=0A= +--------+--------+--------+=0A= | S-end | S-down | S-PgDn |=0A= | end | down | PgDn |=0A= +--------+--------+--------+=0A= | S-insert |S-delete|=0A= | insert | delete |=0A= +-----------------+--------+=0A= =0A= Again, however, there is no necessary relation between the setup name=0A= and the chosen behavior. You could choose the "Shifted non-numeric"=0A= behavior for the (unshifted) `keypad-setup'.=0A= =0A= 3. Define `keypad-setup' as `numeric' ("Numeric with standard decimal=0A= point"). Define `keypad-numlock-setup' as `,' ("Numeric with=0A= customized decimal point: ,"), that is, as 44, which is the decimal=0A= value of the comma character. With these setups, unshifted keypad=0A= keys are decimal digits, but the decimal-point key (`.') is mapped=0A= to a different character for each setup. With NumLock off, the=0A= decimal point is `.'; with NumLock on, it is `,'.=0A= =0A= keypad-setup =3D> Plain Numeric Keypad=0A= keypad-numlock-setup =3D> Numeric Keypad with Decimal key: ,=0A= =0A= +--------+--------+--------+=0A= | 7 | 8 | 9 | <- keypad-numlock-setup: NumLock on=0A= | 7 | 8 | 9 | <- keypad-setup: NumLock off=0A= +--------+--------+--------+=0A= | 4 | 5 | 6 |=0A= | 4 | 5 | 6 |=0A= +--------+--------+--------+=0A= | 1 | 2 | 3 |=0A= | 1 | 2 | 3 |=0A= +--------+--------+--------+=0A= | 0 | , | <- comma=0A= | 0 | . | <- period=0A= +-----------------+--------+=0A= =0A= =0A= =0A= DOC STRINGS=0A= -----------=0A= =0A= `keypad-numlock-shifted-setup' corrected - should be "when NumLock is=0A= on" (not off).=0A= =0A= =0A= QUESTIONS=0A= ---------=0A= =0A= 1. nil value for the options: "No change (keep existing bindings)"=0A= seems to be a no-op. What is its use?=0A= =0A= 2. Do we need a separate `numeric' choice? Why not always specify an=0A= explicit decimal-point?=0A= =0A= 3. Should integerp be char-valid-p in the test for=0A= the value? :match (lambda (widget value) (integerp value))=0A= ------=_NextPart_000_0002_01C7F526.CF48B700 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ------=_NextPart_000_0002_01C7F526.CF48B700--