aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorPaul Eggert2015-01-05 09:07:45 -0800
committerPaul Eggert2015-01-05 10:14:58 -0800
commit58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c (patch)
treed6d79ad7b7cceafc78c5a9c54f5be1ac441a8ed7 /src/keymap.c
parentd2cf05d1bac19d8564d0806f515b9f40fe57f4df (diff)
downloademacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.tar.gz
emacs-58f2d6ef32b28a787fcc4e0d98b3f331ceb2a68c.zip
Compute C decls for DEFSYMs automatically
Fixes Bug#15880. This patch also makes Q constants (e.g., Qnil) constant addresses from the C point of view. * make-docfile.c: Revamp to generate table of symbols, too. Include <stdbool.h>. (xstrdup): New function. (main): Don't process the same file twice. (SYMBOL): New constant in enum global_type. (struct symbol): Turn 'value' member into a union, either v.value for int or v.svalue for string. All uses changed. (add_global): New arg svalue, which overrides value, so that globals can have a string value. (close_emacs_global): New arg num_symbols; all uses changed. Output lispsym decl. (write_globals): Output symbol globals too. Output more ATTRIBUTE_CONST, now that Qnil etc. are C constants. Output defsym_name table. (scan_c_file): Move most of guts into ... (scan_c_stream): ... new function. Scan for DEFSYMs and record symbols found. Don't read past EOF if file doesn't end in newline. * alloc.c, bidi.c, buffer.c, bytecode.c, callint.c, casefiddle: * casetab.c, category.c, ccl.c, charset.c, chartab.c, cmds.c, coding.c: * composite.c, data.c, dbusbind.c, decompress.c, dired.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, fns.c, font.c, fontset.c: * frame.c, fringe.c, ftfont.c, ftxfont.c, gfilenotify.c, gnutls.c: * image.c, inotify.c, insdel.c, keyboard.c, keymap.c, lread.c: * macfont.m, macros.c, minibuf.c, nsfns.m, nsfont.m, nsimage.m: * nsmenu.m, nsselect.m, nsterm.m, print.c, process.c, profiler.c: * search.c, sound.c, syntax.c, term.c, terminal.c, textprop.c, undo.c: * window.c, xdisp.c, xfaces.c, xfns.c, xftfont.c, xmenu.c, xml.c: * xselect.c, xsettings.c, xterm.c: Remove Q vars that represent symbols (e.g., Qnil, Qt, Qemacs). These names are now defined automatically by make-docfile. * alloc.c (init_symbol): New function. (Fmake_symbol): Use it. (c_symbol_p): New function. (valid_lisp_object_p, purecopy): Use it. * alloc.c (marked_pinned_symbols): Use make_lisp_symbol instead of make_lisp_ptr. (garbage_collect_1): Mark lispsym symbols. (CHECK_ALLOCATED_AND_LIVE_SYMBOL): New macro. (mark_object): Use it. (sweep_symbols): Sweep lispsym symbols. (symbol_uses_obj): New function. (which_symbols): Use it. Work for lispsym symbols, too. (init_alloc_once): Initialize Vpurify_flag here; no need to wait, since Qt's address is already known now. (syms_of_alloc): Add lispsym count to symbols_consed. * buffer.c (init_buffer_once): Compare to Qnil, not to make_number (0), when testing whether storage is all bits zero. * dispextern (struct image_type): * font.c (font_property_table): * frame.c (struct frame_parm_table, frame_parms): * keyboard.c (scroll_bar_parts, struct event_head): * xdisp.c (struct props): Use XSYMBOL_INIT (Qfoo) and struct Lisp_Symbol * rather than &Qfoo and Lisp_Object *, since Qfoo is no longer an object whose address can be taken. All uses changed. * eval.c (run_hook): New function. Most uses of Frun_hooks changed to use it, so that they no longer need to take the address of a Lisp sym. (syms_of_eval): Don't use DEFSYM on Vrun_hooks, as it's a variable. * frame.c (syms_of_frame): Add defsyms for the frame_parms table. * keyboard.c (syms_of_keyboard): Don't DEFSYM Qmenu_bar here. DEFSYM Qdeactivate_mark before the corresponding var. * keymap.c (syms_of_keymap): Use DEFSYM for Qmenu_bar and Qmode_line instead of interning their symbols; this avoids duplicates. (LISP_INITIALLY, TAG_PTR) (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END, XSYMBOL_INIT): New macros. (LISP_INITIALLY_ZERO): Use it. (enum symbol_interned, enum symbol_redirect, struct Lisp_Symbol) (EXFUN, DEFUN_ARGS_MANY, DEFUN_ARGS_UNEVALLED, DEFUN_ARGS_*): Move decls up, to avoid forward uses. Include globals.h earlier, too. (make_lisp_symbol): New function. (XSETSYMBOL): Use it. (DEFSYM): Now just a placeholder for make-docfile. * lread.c (DEFINE_SYMBOLS): Define, for globals.h. (intern_sym): New function, with body taken from old intern_driver. (intern_driver): Use it. Last arg is now Lisp integer, not ptrdiff_t. All uses changed. (define_symbol): New function. (init_obarray): Define the C symbols taken from lispsym. Use plain DEFSYM for Qt and Qnil. * syntax.c (init_syntax_once): No need to worry about Qchar_table_extra_slots.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/keymap.c b/src/keymap.c
index ab21a226271..9c7b4d29a3e 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -76,12 +76,6 @@ Lisp_Object control_x_map; /* The keymap used for globally bound
76 bindings when spaces are not encouraged 76 bindings when spaces are not encouraged
77 in the minibuf. */ 77 in the minibuf. */
78 78
79/* Keymap used for minibuffers when doing completion. */
80/* Keymap used for minibuffers when doing completion and require a match. */
81static Lisp_Object Qkeymapp, Qnon_ascii;
82Lisp_Object Qkeymap, Qmenu_item, Qremap;
83static Lisp_Object QCadvertised_binding;
84
85/* Alist of elements like (DEL . "\d"). */ 79/* Alist of elements like (DEL . "\d"). */
86static Lisp_Object exclude_keys; 80static Lisp_Object exclude_keys;
87 81
@@ -654,8 +648,6 @@ map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args,
654 UNGCPRO; 648 UNGCPRO;
655} 649}
656 650
657static Lisp_Object Qkeymap_canonicalize;
658
659/* Same as map_keymap, but does it right, properly eliminating duplicate 651/* Same as map_keymap, but does it right, properly eliminating duplicate
660 bindings due to inheritance. */ 652 bindings due to inheritance. */
661void 653void
@@ -1998,7 +1990,6 @@ then the value includes only maps for prefixes that start with PREFIX. */)
1998 } 1990 }
1999 return maps; 1991 return maps;
2000} 1992}
2001static Lisp_Object Qsingle_key_description, Qkey_description;
2002 1993
2003/* This function cannot GC. */ 1994/* This function cannot GC. */
2004 1995
@@ -3734,12 +3725,15 @@ be preferred. */);
3734 Vwhere_is_preferred_modifier = Qnil; 3725 Vwhere_is_preferred_modifier = Qnil;
3735 where_is_preferred_modifier = 0; 3726 where_is_preferred_modifier = 0;
3736 3727
3728 DEFSYM (Qmenu_bar, "menu-bar");
3729 DEFSYM (Qmode_line, "mode-line");
3730
3737 staticpro (&Vmouse_events); 3731 staticpro (&Vmouse_events);
3738 Vmouse_events = listn (CONSTYPE_PURE, 9, 3732 Vmouse_events = listn (CONSTYPE_PURE, 9,
3739 intern_c_string ("menu-bar"), 3733 Qmenu_bar,
3740 intern_c_string ("tool-bar"), 3734 intern_c_string ("tool-bar"),
3741 intern_c_string ("header-line"), 3735 intern_c_string ("header-line"),
3742 intern_c_string ("mode-line"), 3736 Qmode_line,
3743 intern_c_string ("mouse-1"), 3737 intern_c_string ("mouse-1"),
3744 intern_c_string ("mouse-2"), 3738 intern_c_string ("mouse-2"),
3745 intern_c_string ("mouse-3"), 3739 intern_c_string ("mouse-3"),
@@ -3748,6 +3742,9 @@ be preferred. */);
3748 3742
3749 DEFSYM (Qsingle_key_description, "single-key-description"); 3743 DEFSYM (Qsingle_key_description, "single-key-description");
3750 DEFSYM (Qkey_description, "key-description"); 3744 DEFSYM (Qkey_description, "key-description");
3745
3746 /* Keymap used for minibuffers when doing completion. */
3747 /* Keymap used for minibuffers when doing completion and require a match. */
3751 DEFSYM (Qkeymapp, "keymapp"); 3748 DEFSYM (Qkeymapp, "keymapp");
3752 DEFSYM (Qnon_ascii, "non-ascii"); 3749 DEFSYM (Qnon_ascii, "non-ascii");
3753 DEFSYM (Qmenu_item, "menu-item"); 3750 DEFSYM (Qmenu_item, "menu-item");