aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2025-03-01 06:28:17 +0100
committerStefan Kangas2025-03-01 06:36:43 +0100
commit7ec6531c7bd99ff13e73b9cc2f00d49d2472565f (patch)
tree823217aeee183096d4578d9b596b688964cc3f26
parent8b804011275f9f7b5dda1f03e1d6118cae2846c5 (diff)
downloademacs-7ec6531c7bd99ff13e73b9cc2f00d49d2472565f.tar.gz
emacs-7ec6531c7bd99ff13e73b9cc2f00d49d2472565f.zip
keymaps.texi: Move "Key Sequences" section down
* doc/lispref/keymaps.texi (Key Sequences): Move section down. (Bug#52821)
-rw-r--r--doc/lispref/keymaps.texi133
1 files changed, 66 insertions, 67 deletions
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi
index 56bfb550974..ac63f296958 100644
--- a/doc/lispref/keymaps.texi
+++ b/doc/lispref/keymaps.texi
@@ -14,7 +14,6 @@ used to look up the next input event; this continues until a command
14is found. The whole process is called @dfn{key lookup}. 14is found. The whole process is called @dfn{key lookup}.
15 15
16@menu 16@menu
17* Key Sequences:: Key sequences as Lisp objects.
18* Keymap Basics:: Basic concepts of keymaps. 17* Keymap Basics:: Basic concepts of keymaps.
19* Format of Keymaps:: What a keymap looks like as a Lisp object. 18* Format of Keymaps:: What a keymap looks like as a Lisp object.
20* Creating Keymaps:: Functions to create and copy keymaps. 19* Creating Keymaps:: Functions to create and copy keymaps.
@@ -30,6 +29,7 @@ is found. The whole process is called @dfn{key lookup}.
30* Key Lookup:: Finding a key's binding in one keymap. 29* Key Lookup:: Finding a key's binding in one keymap.
31* Functions for Key Lookup:: How to request key lookup. 30* Functions for Key Lookup:: How to request key lookup.
32* Changing Key Bindings:: Redefining a key in a keymap. 31* Changing Key Bindings:: Redefining a key in a keymap.
32* Key Sequences:: Key sequences as Lisp objects.
33* Low-Level Key Binding:: Legacy key syntax description. 33* Low-Level Key Binding:: Legacy key syntax description.
34* Remapping Commands:: A keymap can translate one command to another. 34* Remapping Commands:: A keymap can translate one command to another.
35* Translation Keymaps:: Keymaps for translating sequences of events. 35* Translation Keymaps:: Keymaps for translating sequences of events.
@@ -38,72 +38,6 @@ is found. The whole process is called @dfn{key lookup}.
38* Menu Keymaps:: Defining a menu as a keymap. 38* Menu Keymaps:: Defining a menu as a keymap.
39@end menu 39@end menu
40 40
41@node Key Sequences
42@section Key Sequences
43@cindex key
44@cindex keystroke
45@cindex key sequence
46
47 A @dfn{key sequence}, or @dfn{key} for short, is a sequence of one
48or more input events that form a unit. Input events include
49characters, function keys, mouse actions, or system events external to
50Emacs, such as @code{iconify-frame} (@pxref{Input Events}).
51The Emacs Lisp representation for a key sequence is a string or
52vector. Unless otherwise stated, any Emacs Lisp function that accepts
53a key sequence as an argument can handle both representations.
54
55 In the string representation, alphanumeric characters ordinarily
56stand for themselves; for example, @code{"a"} represents @kbd{a}
57and @code{"2"} represents @kbd{2}. Control character events are
58prefixed by the substring @code{"\C-"}, and meta characters by
59@code{"\M-"}; for example, @code{"\C-x"} represents the key @kbd{C-x}.
60In addition, the @key{TAB}, @key{RET}, @key{ESC}, and @key{DEL} events
61are represented by @code{"\t"}, @code{"\r"}, @code{"\e"}, and
62@code{"\d"} respectively. The string representation of a complete key
63sequence is the concatenation of the string representations of the
64constituent events; thus, @code{"\C-xl"} represents the key sequence
65@kbd{C-x l}.
66
67 Key sequences containing function keys, mouse button events, system
68events, or non-@acronym{ASCII} characters such as @kbd{C-=} or
69@kbd{H-a} cannot be represented as strings; they have to be
70represented as vectors.
71
72 In the vector representation, each element of the vector represents
73an input event, in its Lisp form. @xref{Input Events}. For example,
74the vector @code{[?\C-x ?l]} represents the key sequence @kbd{C-x l}.
75
76 For examples of key sequences written in string and vector
77representations, @ref{Init Rebinding,,, emacs, The GNU Emacs Manual}.
78
79@defun kbd keyseq-text
80This function converts the text @var{keyseq-text} (a string constant)
81into a key sequence (a string or vector constant). The contents of
82@var{keyseq-text} should use the same syntax as in the buffer invoked
83by the @kbd{C-x C-k @key{RET}} (@code{kmacro-edit-macro}) command; in
84particular, you must surround function key names with
85@samp{<@dots{}>}. @xref{Edit Keyboard Macro,,, emacs, The GNU Emacs
86Manual}.
87
88@example
89(kbd "C-x") @result{} "\C-x"
90(kbd "C-x C-f") @result{} "\C-x\C-f"
91(kbd "C-x 4 C-f") @result{} "\C-x4\C-f"
92(kbd "X") @result{} "X"
93(kbd "RET") @result{} "^M"
94(kbd "C-c SPC") @result{} "\C-c@ "
95(kbd "<f1> SPC") @result{} [f1 32]
96(kbd "C-M-<down>") @result{} [C-M-down]
97@end example
98
99@findex key-valid-p
100The @code{kbd} function is very permissive, and will try to return
101something sensible even if the syntax used isn't completely
102conforming. To check whether the syntax is actually valid, use the
103@code{key-valid-p} function.
104@end defun
105
106
107@node Keymap Basics 41@node Keymap Basics
108@section Keymap Basics 42@section Keymap Basics
109@cindex key binding 43@cindex key binding
@@ -1697,6 +1631,71 @@ Modes}); then its keymap will automatically inherit from
1697@end smallexample 1631@end smallexample
1698@end defun 1632@end defun
1699 1633
1634@node Key Sequences
1635@section Key Sequences
1636@cindex key
1637@cindex keystroke
1638@cindex key sequence
1639
1640 A @dfn{key sequence}, or @dfn{key} for short, is a sequence of one
1641or more input events that form a unit. Input events include
1642characters, function keys, mouse actions, or system events external to
1643Emacs, such as @code{iconify-frame} (@pxref{Input Events}).
1644The Emacs Lisp representation for a key sequence is a string or
1645vector. Unless otherwise stated, any Emacs Lisp function that accepts
1646a key sequence as an argument can handle both representations.
1647
1648 In the string representation, alphanumeric characters ordinarily
1649stand for themselves; for example, @code{"a"} represents @kbd{a}
1650and @code{"2"} represents @kbd{2}. Control character events are
1651prefixed by the substring @code{"\C-"}, and meta characters by
1652@code{"\M-"}; for example, @code{"\C-x"} represents the key @kbd{C-x}.
1653In addition, the @key{TAB}, @key{RET}, @key{ESC}, and @key{DEL} events
1654are represented by @code{"\t"}, @code{"\r"}, @code{"\e"}, and
1655@code{"\d"} respectively. The string representation of a complete key
1656sequence is the concatenation of the string representations of the
1657constituent events; thus, @code{"\C-xl"} represents the key sequence
1658@kbd{C-x l}.
1659
1660 Key sequences containing function keys, mouse button events, system
1661events, or non-@acronym{ASCII} characters such as @kbd{C-=} or
1662@kbd{H-a} cannot be represented as strings; they have to be
1663represented as vectors.
1664
1665 In the vector representation, each element of the vector represents
1666an input event, in its Lisp form. @xref{Input Events}. For example,
1667the vector @code{[?\C-x ?l]} represents the key sequence @kbd{C-x l}.
1668
1669 For examples of key sequences written in string and vector
1670representations, @ref{Init Rebinding,,, emacs, The GNU Emacs Manual}.
1671
1672@defun kbd keyseq-text
1673This function converts the text @var{keyseq-text} (a string constant)
1674into a key sequence (a string or vector constant). The contents of
1675@var{keyseq-text} should use the same syntax as in the buffer invoked
1676by the @kbd{C-x C-k @key{RET}} (@code{kmacro-edit-macro}) command; in
1677particular, you must surround function key names with
1678@samp{<@dots{}>}. @xref{Edit Keyboard Macro,,, emacs, The GNU Emacs
1679Manual}.
1680
1681@example
1682(kbd "C-x") @result{} "\C-x"
1683(kbd "C-x C-f") @result{} "\C-x\C-f"
1684(kbd "C-x 4 C-f") @result{} "\C-x4\C-f"
1685(kbd "X") @result{} "X"
1686(kbd "RET") @result{} "^M"
1687(kbd "C-c SPC") @result{} "\C-c@ "
1688(kbd "<f1> SPC") @result{} [f1 32]
1689(kbd "C-M-<down>") @result{} [C-M-down]
1690@end example
1691
1692@findex key-valid-p
1693The @code{kbd} function is very permissive, and will try to return
1694something sensible even if the syntax used isn't completely
1695conforming. To check whether the syntax is actually valid, use the
1696@code{key-valid-p} function.
1697@end defun
1698
1700@node Low-Level Key Binding 1699@node Low-Level Key Binding
1701@section Low-Level Key Binding 1700@section Low-Level Key Binding
1702@cindex low-level key bindings 1701@cindex low-level key bindings