function split
authorBT Templeton <bt@hcoop.net>
Sat, 17 Aug 2013 20:25:56 +0000 (16:25 -0400)
committerRobin Templeton <robin@terpri.org>
Sun, 19 Apr 2015 07:43:01 +0000 (03:43 -0400)
src/alloc.c
src/cmds.c
src/data.c
src/doc.c
src/emacs.c
src/eval.c
src/keyboard.c
src/lisp.h
src/xterm.c

index 5b9aba6..be38f3e 100644 (file)
@@ -1183,7 +1183,7 @@ initialize_symbol (Lisp_Object val, Lisp_Object name)
   set_symbol_plist (val, Qnil);
   p->redirect = SYMBOL_PLAINVAL;
   SET_SYMBOL_VAL (p, Qunbound);
-  set_symbol_function (val, Qnil);
+  scm_module_define (function_module, val, Qnil);
   p->interned = SYMBOL_UNINTERNED;
   p->constant = 0;
   p->declared_special = false;
index db1ae7a..3755ac3 100644 (file)
@@ -448,11 +448,11 @@ internal_self_insert (int c, EMACS_INT n)
         and the hook has a non-nil `no-self-insert' property,
         return right away--don't really self-insert.  */
       if (SYMBOLP (sym) && ! NILP (sym)
-         && ! NILP (XSYMBOL (sym)->function)
-         && SYMBOLP (XSYMBOL (sym)->function))
+         && ! NILP (SYMBOL_FUNCTION (sym))
+         && SYMBOLP (SYMBOL_FUNCTION (sym)))
        {
          Lisp_Object prop;
-         prop = Fget (XSYMBOL (sym)->function, intern ("no-self-insert"));
+         prop = Fget (SYMBOL_FUNCTION (sym), intern ("no-self-insert"));
          if (! NILP (prop))
            return 1;
        }
index d053970..1c3edca 100644 (file)
@@ -646,7 +646,7 @@ DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0,
   (register Lisp_Object symbol)
 {
   CHECK_SYMBOL (symbol);
-  return NILP (XSYMBOL (symbol)->function) ? Qnil : Qt;
+  return NILP (SYMBOL_FUNCTION (symbol)) ? Qnil : Qt;
 }
 
 DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0,
@@ -678,7 +678,7 @@ DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
   (register Lisp_Object symbol)
 {
   CHECK_SYMBOL (symbol);
-  return XSYMBOL (symbol)->function;
+  return SYMBOL_FUNCTION (symbol);
 }
 
 DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0,
@@ -707,7 +707,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
   register Lisp_Object function;
   CHECK_SYMBOL (symbol);
 
-  function = XSYMBOL (symbol)->function;
+  function = SYMBOL_FUNCTION (symbol);
 
   if (!NILP (Vautoload_queue) && !NILP (function))
     Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
@@ -750,7 +750,7 @@ The return value is undefined.  */)
       { /* Only add autoload entries after dumping, because the ones before are
           not useful and else we get loads of them from the loaddefs.el.  */
 
-       if (AUTOLOADP (XSYMBOL (symbol)->function))
+       if (AUTOLOADP (SYMBOL_FUNCTION (symbol)))
          /* Remember that the function was already an autoload.  */
          LOADHIST_ATTACH (Fcons (Qt, symbol));
        LOADHIST_ATTACH (Fcons (autoload ? Qautoload : Qdefun, symbol));
@@ -2074,12 +2074,12 @@ indirect_function (register Lisp_Object object)
     {
       if (!SYMBOLP (hare) || NILP (hare))
        break;
-      hare = XSYMBOL (hare)->function;
+      hare = SYMBOL_FUNCTION (hare);
       if (!SYMBOLP (hare) || NILP (hare))
        break;
-      hare = XSYMBOL (hare)->function;
+      hare = SYMBOL_FUNCTION (hare);
 
-      tortoise = XSYMBOL (tortoise)->function;
+      tortoise = SYMBOL_FUNCTION (tortoise);
 
       if (EQ (hare, tortoise))
        xsignal1 (Qcyclic_function_indirection, object);
@@ -2103,7 +2103,7 @@ function chain of symbols.  */)
   /* Optimize for no indirection.  */
   result = object;
   if (SYMBOLP (result) && !NILP (result)
-      && (result = XSYMBOL (result)->function, SYMBOLP (result)))
+      && (result = SYMBOL_FUNCTION (result), SYMBOLP (result)))
     result = indirect_function (result);
   if (!NILP (result))
     return result;
@@ -3546,7 +3546,7 @@ syms_of_data (void)
   DEFSYM (Qinteractive_form, "interactive-form");
   DEFSYM (Qdefalias_fset_function, "defalias-fset-function");
 
-  set_symbol_function (Qwholenump, XSYMBOL (Qnatnump)->function);
+  set_symbol_function (Qwholenump, SYMBOL_FUNCTION (Qnatnump));
 
   DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum,
               doc: /* The largest value that is representable in a Lisp integer.  */);
index 5a19029..4d9434c 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -497,7 +497,7 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
 {
   /* Don't use indirect_function here, or defaliases will apply their
      docstrings to the base functions (Bug#2603).  */
-  Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj;
+  Lisp_Object fun = SYMBOLP (obj) ? SYMBOL_FUNCTION (obj) : obj;
 
   /* The type determines where the docstring is stored.  */
 
index 922f9a1..f013bbf 100644 (file)
@@ -108,6 +108,7 @@ extern void moncontrol (int mode);
 #endif
 
 Lisp_Object symbol_module;
+Lisp_Object function_module;
 
 static const char emacs_version[] = PACKAGE_VERSION;
 static const char emacs_copyright[] = COPYRIGHT;
@@ -1171,6 +1172,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
                                 scm_from_locale_keyword ("pure"),
                                 SCM_BOOL_T,
                                 SCM_UNDEFINED);
+      function_module = scm_call (scm_c_public_ref ("guile", "define-module*"),
+                                  scm_list_1 (scm_from_utf8_symbol ("elisp-functions")),
+                                  scm_from_locale_keyword ("pure"),
+                                  SCM_BOOL_T,
+                                  SCM_UNDEFINED);
       init_alloc_once ();
       init_guile ();
       init_fns_once ();
index 3d8573f..bb6d23e 100644 (file)
@@ -1040,7 +1040,7 @@ definitions to shadow the loaded ones for use in file byte-compilation.  */)
          tem = Fassq (sym, environment);
          if (NILP (tem))
            {
-             def = XSYMBOL (sym)->function;
+             def = SYMBOL_FUNCTION (sym);
              if (!NILP (def))
                continue;
            }
@@ -1922,8 +1922,8 @@ this does nothing and returns nil.  */)
   CHECK_STRING (file);
 
   /* If function is defined and not as an autoload, don't override.  */
-  if (!NILP (XSYMBOL (function)->function)
-      && !AUTOLOADP (XSYMBOL (function)->function))
+  if (!NILP (SYMBOL_FUNCTION (function))
+      && !AUTOLOADP (SYMBOL_FUNCTION (function)))
     return Qnil;
 
   return Fdefalias (function,
@@ -2163,7 +2163,7 @@ eval_sub_1 (Lisp_Object form)
   fun = original_fun;
   if (!SYMBOLP (fun))
     fun = Ffunction (Fcons (fun, Qnil));
-  else if (!NILP (fun) && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+  else if (!NILP (fun) && (fun = SYMBOL_FUNCTION (fun), SYMBOLP (fun)))
     fun = indirect_function (fun);
 
   if (SUBRP (fun))
@@ -2391,7 +2391,7 @@ usage: (apply FUNCTION &rest ARGUMENTS)  */)
 
   /* Optimize for no indirection.  */
   if (SYMBOLP (fun) && !NILP (fun)
-      && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+      && (fun = SYMBOL_FUNCTION (fun), SYMBOLP (fun)))
     fun = indirect_function (fun);
   if (NILP (fun))
     {
@@ -2866,7 +2866,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS)  */)
   /* Optimize for no indirection.  */
   fun = original_fun;
   if (SYMBOLP (fun) && !NILP (fun)
-      && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
+      && (fun = SYMBOL_FUNCTION (fun), SYMBOLP (fun)))
     fun = indirect_function (fun);
 
   if (SUBRP (fun))
index 9ab6509..b7cf362 100644 (file)
@@ -7923,7 +7923,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
                       (such as lmenu.el set it up), check if the
                       original command matches the cached command.  */
                    && !(SYMBOLP (def)
-                        && EQ (tem, XSYMBOL (def)->function))))
+                        && EQ (tem, SYMBOL_FUNCTION (def)))))
              keys = Qnil;
          }
 
@@ -8790,9 +8790,10 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
   /* Handle a symbol whose function definition is a keymap
      or an array.  */
   if (SYMBOLP (next) && !NILP (Ffboundp (next))
-      && (ARRAYP (XSYMBOL (next)->function)
-         || KEYMAPP (XSYMBOL (next)->function)))
-    next = Fautoload_do_load (XSYMBOL (next)->function, next, Qnil);
+      && (ARRAYP (SYMBOL_FUNCTION (next))
+         || KEYMAPP (SYMBOL_FUNCTION (next))))
+    next = Fautoload_do_load (SYMBOL_FUNCTION (next),
+                                              next, Qnil);
 
   /* If the keymap gives a function, not an
      array, then call the function with one arg and use
index 2a93f71..1bf3693 100644 (file)
@@ -647,6 +647,7 @@ XSTRING (Lisp_Object a)
 extern void initialize_symbol (Lisp_Object, Lisp_Object);
 INLINE Lisp_Object build_string (const char *);
 extern Lisp_Object symbol_module;
+extern Lisp_Object function_module;
 
 INLINE struct Lisp_Symbol *
 XSYMBOL (Lisp_Object a)
@@ -1338,9 +1339,6 @@ struct Lisp_Symbol
     union Lisp_Fwd *fwd;
   } val;
 
-  /* Function value of the symbol or Qnil if not fboundp.  */
-  Lisp_Object function;
-
   /* The symbol's property list.  */
   Lisp_Object plist;
 };
@@ -1412,6 +1410,12 @@ SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (Lisp_Object sym)
   return XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY;
 }
 
+INLINE Lisp_Object
+SYMBOL_FUNCTION (Lisp_Object sym)
+{
+  return scm_variable_ref (scm_module_lookup (function_module, sym));
+}
+
 /* Value is non-zero if symbol is considered a constant, i.e. its
    value cannot be changed (there is an exception for keyword symbols,
    whose value can be set to the keyword symbol itself).  */
@@ -2756,7 +2760,7 @@ set_hash_value_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
 INLINE void
 set_symbol_function (Lisp_Object sym, Lisp_Object function)
 {
-  XSYMBOL (sym)->function = function;
+  scm_variable_set_x (scm_module_lookup (function_module, sym), function);
 }
 
 INLINE void
index b64ca2d..2bad2f4 100644 (file)
@@ -9965,7 +9965,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
       {
        terminal->kboard = allocate_kboard (Qx);
 
-       if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound))
+       if (!EQ (SYMBOL_FUNCTION (Qvendor_specific_keysyms), Qunbound))
          {
            char *vendor = ServerVendor (dpy);