diff options
| author | Eli Zaretskii | 2018-09-10 12:46:22 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-09-10 12:46:22 +0300 |
| commit | 5cf282d65f10f59f7efa63359dfd2b2e124943da (patch) | |
| tree | 2f46d097912980052ce13faa6433913adc580f72 /src | |
| parent | 96281c5ee1582ac0c329d09797ab7ab3dbae26d1 (diff) | |
| download | emacs-5cf282d65f10f59f7efa63359dfd2b2e124943da.tar.gz emacs-5cf282d65f10f59f7efa63359dfd2b2e124943da.zip | |
Clarify documentation of functions reading character events
* doc/lispref/help.texi (Describing Characters):
* doc/lispref/commands.texi (Keyboard Events)
(Reading One Event, Classifying Events): Make the distinction
between characters and character events more explicit.
* src/keymap.c (Ftext_char_description)
(Fsingle_key_description):
* src/lread.c (Fread_char, Fread_char_exclusive): Doc fixes,
to make a clear distinction between a character input event
and a character code. (Bug#32562)
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 17 | ||||
| -rw-r--r-- | src/lread.c | 20 |
2 files changed, 24 insertions, 13 deletions
diff --git a/src/keymap.c b/src/keymap.c index c8cc933e782..ec483c7a632 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2205,10 +2205,12 @@ push_key_description (EMACS_INT ch, char *p) | |||
| 2205 | 2205 | ||
| 2206 | DEFUN ("single-key-description", Fsingle_key_description, | 2206 | DEFUN ("single-key-description", Fsingle_key_description, |
| 2207 | Ssingle_key_description, 1, 2, 0, | 2207 | Ssingle_key_description, 1, 2, 0, |
| 2208 | doc: /* Return a pretty description of command character KEY. | 2208 | doc: /* Return a pretty description of a character event KEY. |
| 2209 | Control characters turn into C-whatever, etc. | 2209 | Control characters turn into C-whatever, etc. |
| 2210 | Optional argument NO-ANGLES non-nil means don't put angle brackets | 2210 | Optional argument NO-ANGLES non-nil means don't put angle brackets |
| 2211 | around function keys and event symbols. */) | 2211 | around function keys and event symbols. |
| 2212 | |||
| 2213 | See `text-char-description' for describing character codes. */) | ||
| 2212 | (Lisp_Object key, Lisp_Object no_angles) | 2214 | (Lisp_Object key, Lisp_Object no_angles) |
| 2213 | { | 2215 | { |
| 2214 | USE_SAFE_ALLOCA; | 2216 | USE_SAFE_ALLOCA; |
| @@ -2282,11 +2284,12 @@ push_text_char_description (register unsigned int c, register char *p) | |||
| 2282 | /* This function cannot GC. */ | 2284 | /* This function cannot GC. */ |
| 2283 | 2285 | ||
| 2284 | DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0, | 2286 | DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0, |
| 2285 | doc: /* Return a pretty description of file-character CHARACTER. | 2287 | doc: /* Return the description of CHARACTER in standard Emacs notation. |
| 2286 | Control characters turn into "^char", etc. This differs from | 2288 | CHARACTER must be a valid character code that passes the `characterp' test. |
| 2287 | `single-key-description' which turns them into "C-char". | 2289 | Control characters turn into "^char", the 2**7 bit is treated as Meta, etc. |
| 2288 | Also, this function recognizes the 2**7 bit as the Meta character, | 2290 | This differs from `single-key-description' which accepts character events, |
| 2289 | whereas `single-key-description' uses the 2**27 bit for Meta. | 2291 | and thus doesn't enforce the `characterp' condition, turns control |
| 2292 | characters into "C-char", and uses the 2**27 bit for Meta. | ||
| 2290 | See Info node `(elisp)Describing Characters' for examples. */) | 2293 | See Info node `(elisp)Describing Characters' for examples. */) |
| 2291 | (Lisp_Object character) | 2294 | (Lisp_Object character) |
| 2292 | { | 2295 | { |
diff --git a/src/lread.c b/src/lread.c index d5ba48a170d..2e5cba510c5 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -735,10 +735,14 @@ read_filtered_event (bool no_switch_frame, bool ascii_required, | |||
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0, | 737 | DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0, |
| 738 | doc: /* Read a character from the command input (keyboard or macro). | 738 | doc: /* Read a character event from the command input (keyboard or macro). |
| 739 | It is returned as a number. | 739 | It is returned as a number. |
| 740 | If the character has modifiers, they are resolved and reflected to the | 740 | If the event has modifiers, they are resolved and reflected in the |
| 741 | character code if possible (e.g. C-SPC -> 0). | 741 | returned character code if possible (e.g. C-SPC yields 0 and C-a yields 97). |
| 742 | If some of the modifiers cannot be reflected in the character code, the | ||
| 743 | returned value will include those modifiers, and will not be a valid | ||
| 744 | character code: it will fail the `characterp' test. Use `event-basic-type' | ||
| 745 | to recover the character code with the modifiers removed. | ||
| 742 | 746 | ||
| 743 | If the user generates an event which is not a character (i.e. a mouse | 747 | If the user generates an event which is not a character (i.e. a mouse |
| 744 | click or function key event), `read-char' signals an error. As an | 748 | click or function key event), `read-char' signals an error. As an |
| @@ -785,10 +789,14 @@ floating-point value. */) | |||
| 785 | } | 789 | } |
| 786 | 790 | ||
| 787 | DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 3, 0, | 791 | DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 3, 0, |
| 788 | doc: /* Read a character from the command input (keyboard or macro). | 792 | doc: /* Read a character event from the command input (keyboard or macro). |
| 789 | It is returned as a number. Non-character events are ignored. | 793 | It is returned as a number. Non-character events are ignored. |
| 790 | If the character has modifiers, they are resolved and reflected to the | 794 | If the event has modifiers, they are resolved and reflected in the |
| 791 | character code if possible (e.g. C-SPC -> 0). | 795 | returned character code if possible (e.g. C-SPC yields 0 and C-a yields 97). |
| 796 | If some of the modifiers cannot be reflected in the character code, the | ||
| 797 | returned value will include those modifiers, and will not be a valid | ||
| 798 | character code: it will fail the `characterp' test. Use `event-basic-type' | ||
| 799 | to recover the character code with the modifiers removed. | ||
| 792 | 800 | ||
| 793 | If the optional argument PROMPT is non-nil, display that as a prompt. | 801 | If the optional argument PROMPT is non-nil, display that as a prompt. |
| 794 | If the optional argument INHERIT-INPUT-METHOD is non-nil and some | 802 | If the optional argument INHERIT-INPUT-METHOD is non-nil and some |