Always use set_buffer_if_live to restore original buffer at unwind.
[bpt/emacs.git] / src / print.c
index ffa8a9b..52c07c7 100644 (file)
@@ -197,8 +197,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1;
                               ? PT - start_point : 0),                 \
                  old_point_byte + (old_point_byte >= start_point_byte  \
                                    ? PT_BYTE - start_point_byte : 0)); \
-   if (old != current_buffer)                                          \
-     set_buffer_internal (old);
+   set_buffer_internal (old);
 
 #define PRINTCHAR(ch) printchar (ch, printcharfun)
 
@@ -488,20 +487,20 @@ temp_output_buffer_setup (const char *bufname)
   register struct buffer *old = current_buffer;
   register Lisp_Object buf;
 
-  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
+  record_unwind_current_buffer ();
 
   Fset_buffer (Fget_buffer_create (build_string (bufname)));
 
   Fkill_all_local_variables ();
   delete_all_overlays (current_buffer);
-  BVAR (current_buffer, directory) = BVAR (old, directory);
-  BVAR (current_buffer, read_only) = Qnil;
-  BVAR (current_buffer, filename) = Qnil;
-  BVAR (current_buffer, undo_list) = Qt;
+  bset_directory (current_buffer, BVAR (old, directory));
+  bset_read_only (current_buffer, Qnil);
+  bset_filename (current_buffer, Qnil);
+  bset_undo_list (current_buffer, Qt);
   eassert (current_buffer->overlays_before == NULL);
   eassert (current_buffer->overlays_after == NULL);
-  BVAR (current_buffer, enable_multibyte_characters)
-    = BVAR (&buffer_defaults, enable_multibyte_characters);
+  bset_enable_multibyte_characters
+    (current_buffer, BVAR (&buffer_defaults, enable_multibyte_characters));
   specbind (Qinhibit_read_only, Qt);
   specbind (Qinhibit_modification_hooks, Qt);
   Ferase_buffer ();
@@ -586,6 +585,7 @@ A printed representation of an object is text which describes that object.  */)
   (Lisp_Object object, Lisp_Object noescape)
 {
   Lisp_Object printcharfun;
+  bool prev_abort_on_gc;
   /* struct gcpro gcpro1, gcpro2; */
   Lisp_Object save_deactivate_mark;
   ptrdiff_t count = SPECPDL_INDEX ();
@@ -601,7 +601,8 @@ A printed representation of an object is text which describes that object.  */)
        No need for specbind, since errors deactivate the mark.  */
     save_deactivate_mark = Vdeactivate_mark;
     /* GCPRO2 (object, save_deactivate_mark); */
-    abort_on_gc++;
+    prev_abort_on_gc = abort_on_gc;
+    abort_on_gc = 1;
 
     printcharfun = Vprin1_to_string_buffer;
     PRINTPREPARE;
@@ -625,7 +626,7 @@ A printed representation of an object is text which describes that object.  */)
   Vdeactivate_mark = save_deactivate_mark;
   /* UNGCPRO; */
 
-  abort_on_gc--;
+  abort_on_gc = prev_abort_on_gc;
   return unbind_to (count, object);
 }
 
@@ -1194,7 +1195,7 @@ print_preprocess (Lisp_Object obj)
        {
        case Lisp_String:
          /* A string may have text properties, which can be circular.  */
-         traverse_intervals_noorder (STRING_INTERVALS (obj),
+         traverse_intervals_noorder (string_intervals (obj),
                                      print_preprocess_string, Qnil);
          break;
 
@@ -1297,7 +1298,7 @@ static Lisp_Object
 print_prune_string_charset (Lisp_Object string)
 {
   print_check_string_result = 0;
-  traverse_intervals (STRING_INTERVALS (string), 0,
+  traverse_intervals (string_intervals (string), 0,
                      print_check_string_charset_prop, string);
   if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
     {
@@ -1408,7 +1409,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
          if (! EQ (Vprint_charset_text_property, Qt))
            obj = print_prune_string_charset (obj);
 
-         if (!NULL_INTERVAL_P (STRING_INTERVALS (obj)))
+         if (string_intervals (obj))
            {
              PRINTCHAR ('#');
              PRINTCHAR ('(');
@@ -1499,9 +1500,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
            }
          PRINTCHAR ('\"');
 
-         if (!NULL_INTERVAL_P (STRING_INTERVALS (obj)))
+         if (string_intervals (obj))
            {
-             traverse_intervals (STRING_INTERVALS (obj),
+             traverse_intervals (string_intervals (obj),
                                  0, print_interval, printcharfun);
              PRINTCHAR (')');
            }
@@ -1697,11 +1698,11 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
          if (escapeflag)
            {
              strout ("#<process ", -1, -1, printcharfun);
-             print_string (PGET (XPROCESS (obj), name), printcharfun);
+             print_string (XPROCESS (obj)->name, printcharfun);
              PRINTCHAR ('>');
            }
          else
-           print_string (PGET (XPROCESS (obj), name), printcharfun);
+           print_string (XPROCESS (obj)->name, printcharfun);
        }
       else if (BOOL_VECTOR_P (obj))
        {