aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorRichard M. Stallman1993-03-07 09:25:28 +0000
committerRichard M. Stallman1993-03-07 09:25:28 +0000
commit7bd279cd8e4a94e2706d73fc3286b14a1db65454 (patch)
tree050f83095e2fdec97a74f587be59a8d46e39ed0e /src/lread.c
parentc48f61ef04f4c23b50d0ff1422281f049f38d5e7 (diff)
downloademacs-7bd279cd8e4a94e2706d73fc3286b14a1db65454.tar.gz
emacs-7bd279cd8e4a94e2706d73fc3286b14a1db65454.zip
(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.c73
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. */
33#include "paths.h" 33#include "paths.h"
34#include "commands.h" 34#include "commands.h"
35#include "keyboard.h" 35#include "keyboard.h"
36#include "termhooks.h"
36#endif 37#endif
37 38
38#ifdef lint 39#ifdef lint
@@ -49,6 +50,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
49 50
50Lisp_Object Qread_char, Qget_file_char, Qstandard_input; 51Lisp_Object Qread_char, Qget_file_char, Qstandard_input;
51Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; 52Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
53Lisp_Object Qascii_character;
54
55extern Lisp_Object Qevent_symbol_element_mask;
52 56
53/* non-zero if inside `load' */ 57/* non-zero if inside `load' */
54int load_in_progress; 58int load_in_progress;
@@ -200,11 +204,25 @@ If you want to read non-character events, or ignore them, call\n\
200 if (! NILP (delayed_switch_frame)) 204 if (! NILP (delayed_switch_frame))
201 unread_switch_frame = delayed_switch_frame; 205 unread_switch_frame = delayed_switch_frame;
202 206
203 /* Only ASCII characters are acceptable. */ 207 /* Only ASCII characters are acceptable.
208 But convert certain symbols to their ASCII equivalents. */
209 if (XTYPE (val) == Lisp_Symbol)
210 {
211 Lisp_Object tem, tem1, tem2;
212 tem = Fget (val, Qevent_symbol_element_mask);
213 if (!NILP (tem))
214 {
215 tem1 = Fget (Fcar (tem), Qascii_character);
216 /* Merge this symbol's modifier bits
217 with the ASCII equivalent of its basic code. */
218 if (!NILP (tem1))
219 XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem)));
220 }
221 }
204 if (XTYPE (val) != Lisp_Int) 222 if (XTYPE (val) != Lisp_Int)
205 { 223 {
206 unread_command_events = Fcons (val, Qnil); 224 unread_command_events = Fcons (val, Qnil);
207 error ("Object read was not a character"); 225 error ("Non-character input-event");
208 } 226 }
209 } 227 }
210#else 228#else
@@ -241,6 +259,21 @@ It is returned as a number. Non character events are ignored.")
241 { 259 {
242 val = read_char (0, 0, 0, Qnil, 0); 260 val = read_char (0, 0, 0, Qnil, 0);
243 261
262 /* Convert certain symbols (for keys like RET, DEL, TAB)
263 to ASCII integers. */
264 if (XTYPE (val) == Lisp_Symbol)
265 {
266 Lisp_Object tem, tem1;
267 tem = Fget (val, Qevent_symbol_element_mask);
268 if (!NILP (tem))
269 {
270 tem1 = Fget (Fcar (tem), Qascii_character);
271 /* Merge this symbol's modifier bits
272 with the ASCII equivalent of its basic code. */
273 if (!NILP (tem1))
274 XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem)));
275 }
276 }
244 if (XTYPE (val) == Lisp_Int) 277 if (XTYPE (val) == Lisp_Int)
245 break; 278 break;
246 279
@@ -790,7 +823,7 @@ read_escape (readcharfun)
790 c = READCHAR; 823 c = READCHAR;
791 if (c == '\\') 824 if (c == '\\')
792 c = read_escape (readcharfun); 825 c = read_escape (readcharfun);
793 return c | CHAR_META; 826 return c | meta_modifier;
794 827
795 case 'S': 828 case 'S':
796 c = READCHAR; 829 c = READCHAR;
@@ -799,7 +832,34 @@ read_escape (readcharfun)
799 c = READCHAR; 832 c = READCHAR;
800 if (c == '\\') 833 if (c == '\\')
801 c = read_escape (readcharfun); 834 c = read_escape (readcharfun);
802 return c | CHAR_SHIFT; 835 return c | shift_modifier;
836
837 case 'H':
838 c = READCHAR;
839 if (c != '-')
840 error ("Invalid escape character syntax");
841 c = READCHAR;
842 if (c == '\\')
843 c = read_escape (readcharfun);
844 return c | hyper_modifier;
845
846 case 'A':
847 c = READCHAR;
848 if (c != '-')
849 error ("Invalid escape character syntax");
850 c = READCHAR;
851 if (c == '\\')
852 c = read_escape (readcharfun);
853 return c | alt_modifier;
854
855 case 's':
856 c = READCHAR;
857 if (c != '-')
858 error ("Invalid escape character syntax");
859 c = READCHAR;
860 if (c == '\\')
861 c = read_escape (readcharfun);
862 return c | super_modifier;
803 863
804 case 'C': 864 case 'C':
805 c = READCHAR; 865 c = READCHAR;
@@ -818,7 +878,7 @@ read_escape (readcharfun)
818 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) 878 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
819 return (c & (037 | ~0177)); 879 return (c & (037 | ~0177));
820 else 880 else
821 return c | CHAR_CTL; 881 return c | ctrl_modifier;
822 882
823 case '0': 883 case '0':
824 case '1': 884 case '1':
@@ -1747,4 +1807,7 @@ but does prevent execution of the rest of the FORMS.");
1747 1807
1748 Qget_file_char = intern ("get-file-char"); 1808 Qget_file_char = intern ("get-file-char");
1749 staticpro (&Qget_file_char); 1809 staticpro (&Qget_file_char);
1810
1811 Qascii_character = intern ("ascii-character");
1812 staticpro (&Qascii_character);
1750} 1813}