Generalize INTERNAL_FIELD between buffers, keyboards and frames.
[bpt/emacs.git] / src / minibuf.c
index 050a22a..5ece9d5 100644 (file)
@@ -102,14 +102,14 @@ choose_minibuf_frame (void)
 {
   if (FRAMEP (selected_frame)
       && FRAME_LIVE_P (XFRAME (selected_frame))
-      && !EQ (minibuf_window, XFRAME (selected_frame)->minibuffer_window))
+      && !EQ (minibuf_window, FVAR (XFRAME (selected_frame), minibuffer_window)))
     {
       struct frame *sf = XFRAME (selected_frame);
       Lisp_Object buffer;
 
       /* I don't think that any frames may validly have a null minibuffer
         window anymore.  */
-      if (NILP (sf->minibuffer_window))
+      if (NILP (FVAR (sf, minibuffer_window)))
        abort ();
 
       /* Under X, we come here with minibuf_window being the
@@ -117,8 +117,8 @@ choose_minibuf_frame (void)
         init_window_once.  That window doesn't have a buffer.  */
       buffer = XWINDOW (minibuf_window)->buffer;
       if (BUFFERP (buffer))
-       Fset_window_buffer (sf->minibuffer_window, buffer, Qnil);
-      minibuf_window = sf->minibuffer_window;
+       Fset_window_buffer (FVAR (sf, minibuffer_window), buffer, Qnil);
+      minibuf_window = FVAR (sf, minibuffer_window);
     }
 
   /* Make sure no other frame has a minibuffer as its selected window,
@@ -424,8 +424,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
     {
       if (CONSP (initial))
        {
-         Lisp_Object backup_n = Fcdr (initial);
-         initial = Fcar (initial);
+         Lisp_Object backup_n = XCDR (initial);
+         initial = XCAR (initial);
          CHECK_STRING (initial);
          if (!NILP (backup_n))
            {
@@ -792,8 +792,8 @@ get_minibuffer (EMACS_INT depth)
   buf = Fcar (tail);
   if (NILP (buf) || NILP (BVAR (XBUFFER (buf), name)))
     {
-      sprintf (name, " *Minibuf-%"pI"d*", depth);
-      buf = Fget_buffer_create (build_string (name));
+      buf = Fget_buffer_create
+       (make_formatted_string (name, " *Minibuf-%"pI"d*", depth));
 
       /* Although the buffer's name starts with a space, undo should be
         enabled in it.  */
@@ -804,10 +804,9 @@ get_minibuffer (EMACS_INT depth)
   else
     {
       ptrdiff_t count = SPECPDL_INDEX ();
-      /* `reset_buffer' blindly sets the list of overlays to NULL, so we
-        have to empty the list, otherwise we end up with overlays that
-        think they belong to this buffer while the buffer doesn't know about
-        them any more.  */
+      /* We have to empty both overlay lists.  Otherwise we end
+        up with overlays that think they belong to this buffer
+        while the buffer doesn't know about them any more.  */
       delete_all_overlays (XBUFFER (buf));
       reset_buffer (XBUFFER (buf));
       record_unwind_protect (Fset_buffer, Fcurrent_buffer ());