diff options
author | Richard M. Stallman <rms@gnu.org> | 1993-03-07 09:25:28 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1993-03-07 09:25:28 +0000 |
commit | 3e6cc0b478751dbf30b72b6deadcf3dfa1a6a633 (patch) | |
tree | 3d7582ba1937b9e504672963491aa18123a531ca /src/lread.c | |
parent | 35255b926ab802c6d307f6de5fd14f2b16be48d0 (diff) | |
download | emacs-3e6cc0b478751dbf30b72b6deadcf3dfa1a6a633.tar.gz |
(syms_of_lread): Set up Qascii_character.
(Fread_char, Fread_char_exclusive): Use that property
to convert symbols like tab, return, M-return,... to ASCII.
Include termhooks.h.
(read_escape): Handle \H, \A, \s. Use ..._modifier.
Diffstat (limited to 'src/lread.c')
-rw-r--r-- | src/lread.c | 73 |
1 files changed, 68 insertions, 5 deletions
diff --git a/src/lread.c b/src/lread.c index 049a9bd0b62..62e702e8abb 100644 --- a/src/lread.c +++ b/src/lread.c @@ -33,6 +33,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "paths.h" #include "commands.h" #include "keyboard.h" +#include "termhooks.h" #endif #ifdef lint @@ -49,6 +50,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ Lisp_Object Qread_char, Qget_file_char, Qstandard_input; Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; +Lisp_Object Qascii_character; + +extern Lisp_Object Qevent_symbol_element_mask; /* non-zero if inside `load' */ int load_in_progress; @@ -200,11 +204,25 @@ If you want to read non-character events, or ignore them, call\n\ if (! NILP (delayed_switch_frame)) unread_switch_frame = delayed_switch_frame; - /* Only ASCII characters are acceptable. */ + /* Only ASCII characters are acceptable. + But convert certain symbols to their ASCII equivalents. */ + if (XTYPE (val) == Lisp_Symbol) + { + Lisp_Object tem, tem1, tem2; + tem = Fget (val, Qevent_symbol_element_mask); + if (!NILP (tem)) + { + tem1 = Fget (Fcar (tem), Qascii_character); + /* Merge this symbol's modifier bits + with the ASCII equivalent of its basic code. */ + if (!NILP (tem1)) + XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem))); + } + } if (XTYPE (val) != Lisp_Int) { unread_command_events = Fcons (val, Qnil); - error ("Object read was not a character"); + error ("Non-character input-event"); } } #else @@ -241,6 +259,21 @@ It is returned as a number. Non character events are ignored.") { val = read_char (0, 0, 0, Qnil, 0); + /* Convert certain symbols (for keys like RET, DEL, TAB) + to ASCII integers. */ + if (XTYPE (val) == Lisp_Symbol) + { + Lisp_Object tem, tem1; + tem = Fget (val, Qevent_symbol_element_mask); + if (!NILP (tem)) + { + tem1 = Fget (Fcar (tem), Qascii_character); + /* Merge this symbol's modifier bits + with the ASCII equivalent of its basic code. */ + if (!NILP (tem1)) + XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem))); + } + } if (XTYPE (val) == Lisp_Int) break; @@ -790,7 +823,7 @@ read_escape (readcharfun) c = READCHAR; if (c == '\\') c = read_escape (readcharfun); - return c | CHAR_META; + return c | meta_modifier; case 'S': c = READCHAR; @@ -799,7 +832,34 @@ read_escape (readcharfun) c = READCHAR; if (c == '\\') c = read_escape (readcharfun); - return c | CHAR_SHIFT; + return c | shift_modifier; + + case 'H': + c = READCHAR; + if (c != '-') + error ("Invalid escape character syntax"); + c = READCHAR; + if (c == '\\') + c = read_escape (readcharfun); + return c | hyper_modifier; + + case 'A': + c = READCHAR; + if (c != '-') + error ("Invalid escape character syntax"); + c = READCHAR; + if (c == '\\') + c = read_escape (readcharfun); + return c | alt_modifier; + + case 's': + c = READCHAR; + if (c != '-') + error ("Invalid escape character syntax"); + c = READCHAR; + if (c == '\\') + c = read_escape (readcharfun); + return c | super_modifier; case 'C': c = READCHAR; @@ -818,7 +878,7 @@ read_escape (readcharfun) else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) return (c & (037 | ~0177)); else - return c | CHAR_CTL; + return c | ctrl_modifier; case '0': case '1': @@ -1747,4 +1807,7 @@ but does prevent execution of the rest of the FORMS."); Qget_file_char = intern ("get-file-char"); staticpro (&Qget_file_char); + + Qascii_character = intern ("ascii-character"); + staticpro (&Qascii_character); } |