]> code.delx.au - gnu-emacs/blobdiff - src/data.c
Merge from emacs--rel--22
[gnu-emacs] / src / data.c
index 15169d3d3f4f7c77b5794ec7b202a3e11139bbb3..c8c40aa6df0d8ba1e29b05db5d133e6256025b3f 100644 (file)
@@ -6,7 +6,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -30,6 +30,7 @@ Boston, MA 02110-1301, USA.  */
 #include "keyboard.h"
 #include "frame.h"
 #include "syssignal.h"
+#include "termhooks.h"  /* For FRAME_KBOARD reference in y-or-n-p. */
 
 #ifdef STDC_HEADERS
 #include <float.h>
@@ -662,12 +663,20 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
      (symbol, definition)
      register Lisp_Object symbol, definition;
 {
+  register Lisp_Object function;
+
   CHECK_SYMBOL (symbol);
   if (NILP (symbol) || EQ (symbol, Qt))
     xsignal1 (Qsetting_constant, symbol);
-  if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (symbol)->function, Qunbound))
-    Vautoload_queue = Fcons (Fcons (symbol, XSYMBOL (symbol)->function),
-                            Vautoload_queue);
+
+  function = XSYMBOL (symbol)->function;
+
+  if (!NILP (Vautoload_queue) && !EQ (function, Qunbound))
+    Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
+
+  if (CONSP (function) && EQ (XCAR (function), Qautoload))
+    Fput (symbol, Qautoload, XCDR (function));
+
   XSYMBOL (symbol)->function = definition;
   /* Handle automatic advice activation */
   if (CONSP (XSYMBOL (symbol)->plist) && !NILP (Fget (symbol, Qad_advice_info)))
@@ -751,7 +760,7 @@ Value, if non-nil, is a list \(interactive SPEC).  */)
      Lisp_Object cmd;
 {
   Lisp_Object fun = indirect_function (cmd); /* Check cycles.  */
-  
+
   if (NILP (fun) || EQ (fun, Qunbound))
     return Qnil;
 
@@ -769,8 +778,11 @@ Value, if non-nil, is a list \(interactive SPEC).  */)
 
   if (SUBRP (fun))
     {
-      if (XSUBR (fun)->prompt)
-       return list2 (Qinteractive, build_string (XSUBR (fun)->prompt));
+      char *spec = XSUBR (fun)->intspec;
+      if (spec)
+       return list2 (Qinteractive,
+                     (*spec != '(') ? build_string (spec) :
+                     Fcar (Fread_from_string (build_string (spec), Qnil, Qnil)));
     }
   else if (COMPILEDP (fun))
     {
@@ -873,7 +885,18 @@ do_symval_forwarding (valcontents)
 
       case Lisp_Misc_Kboard_Objfwd:
        offset = XKBOARD_OBJFWD (valcontents)->offset;
-       return *(Lisp_Object *)(offset + (char *)current_kboard);
+        /* We used to simply use current_kboard here, but from Lisp
+           code, it's value is often unexpected.  It seems nicer to
+           allow constructions like this to work as intuitively expected:
+
+               (with-selected-frame frame
+                   (define-key local-function-map "\eOP" [f1]))
+
+           On the other hand, this affects the semantics of
+           last-command and real-last-command, and people may rely on
+           that.  I took a quick look at the Lisp codebase, and I
+           don't think anything will break.  --lorentey  */
+       return *(Lisp_Object *)(offset + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
       }
   return valcontents;
 }
@@ -961,7 +984,7 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
 
        case Lisp_Misc_Kboard_Objfwd:
          {
-           char *base = (char *) current_kboard;
+           char *base = (char *) FRAME_KBOARD (SELECTED_FRAME ());
            char *p = base + XKBOARD_OBJFWD (valcontents)->offset;
            *(Lisp_Object *) p = newval;
          }
@@ -1107,7 +1130,7 @@ find_symbol_value (symbol)
 
        case Lisp_Misc_Kboard_Objfwd:
          return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
-                                 + (char *)current_kboard);
+                                 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
        }
     }
 
@@ -1868,6 +1891,51 @@ If the current binding is global (the default), the value is nil.  */)
 
   return Qnil;
 }
+
+/* This code is disabled now that we use the selected frame to return
+   keyboard-local-values. */
+#if 0
+extern struct terminal *get_terminal P_ ((Lisp_Object display, int));
+
+DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0,
+       doc: /* Return the terminal-local value of SYMBOL on TERMINAL.
+If SYMBOL is not a terminal-local variable, then return its normal
+value, like `symbol-value'.
+
+TERMINAL may be a terminal id, a frame, or nil (meaning the
+selected frame's terminal device).  */)
+  (symbol, terminal)
+     Lisp_Object symbol;
+     Lisp_Object terminal;
+{
+  Lisp_Object result;
+  struct terminal *t = get_terminal (terminal, 1);
+  push_kboard (t->kboard);
+  result = Fsymbol_value (symbol);
+  pop_kboard ();
+  return result;
+}
+
+DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0,
+       doc: /* Set the terminal-local binding of SYMBOL on TERMINAL to VALUE.
+If VARIABLE is not a terminal-local variable, then set its normal
+binding, like `set'.
+
+TERMINAL may be a terminal id, a frame, or nil (meaning the
+selected frame's terminal device).  */)
+  (symbol, terminal, value)
+     Lisp_Object symbol;
+     Lisp_Object terminal;
+     Lisp_Object value;
+{
+  Lisp_Object result;
+  struct terminal *t = get_terminal (terminal, 1);
+  push_kboard (d->kboard);
+  result = Fset (symbol, value);
+  pop_kboard ();
+  return result;
+}
+#endif
 \f
 /* Find the function at the end of a chain of symbol function indirections.  */
 
@@ -3327,6 +3395,10 @@ syms_of_data ()
   defsubr (&Slocal_variable_p);
   defsubr (&Slocal_variable_if_set_p);
   defsubr (&Svariable_binding_locus);
+#if 0                           /* XXX Remove this. --lorentey */
+  defsubr (&Sterminal_local_value);
+  defsubr (&Sset_terminal_local_value);
+#endif
   defsubr (&Saref);
   defsubr (&Saset);
   defsubr (&Snumber_to_string);