use dynwind_begin and dynwind_end
[bpt/emacs.git] / src / minibuf.c
index c53f91a..e257ac2 100644 (file)
@@ -205,7 +205,7 @@ string_to_object (Lisp_Object val, Lisp_Object defalt)
     }
 
   val = Fcar (expr_and_pos);
-  RETURN_UNGCPRO (val);
+  return val;
 }
 
 
@@ -377,7 +377,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
              bool allow_props, bool inherit_input_method)
 {
   Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   Lisp_Object mini_frame, ambient_dir, minibuffer, input_method;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   Lisp_Object enable_multibyte;
@@ -462,7 +462,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
                                         expflag, histvar, histpos, defalt,
                                         allow_props, inherit_input_method);
       UNGCPRO;
-      return unbind_to (count, val);
+      dynwind_end ();
+      return val;
     }
 
   /* Choose the minibuffer window and frame, and take action on them.  */
@@ -625,7 +626,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
 
   /* Erase the buffer.  */
   {
-    ptrdiff_t count1 = SPECPDL_INDEX ();
+    dynwind_begin ();
     specbind (Qinhibit_read_only, Qt);
     specbind (Qinhibit_modification_hooks, Qt);
     Ferase_buffer ();
@@ -647,7 +648,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
        Fadd_text_properties (make_number (BEG), make_number (PT),
                              Vminibuffer_prompt_properties, Qnil);
       }
-    unbind_to (count1, Qnil);
+    dynwind_end ();
   }
 
   minibuf_prompt_width = current_column ();
@@ -753,7 +754,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
   /* The appropriate frame will get selected
      in set-window-configuration.  */
   UNGCPRO;
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 /* Return a buffer to be used as the minibuffer at depth `depth'.
@@ -787,7 +789,7 @@ get_minibuffer (EMACS_INT depth)
     }
   else
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       /* 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.  */
@@ -799,7 +801,7 @@ get_minibuffer (EMACS_INT depth)
        call0 (intern ("minibuffer-inactive-mode"));
       else
         Fkill_all_local_variables ();
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   return buf;
@@ -853,14 +855,14 @@ read_minibuf_unwind (void)
 
   /* Erase the minibuffer we were using at this level.  */
   {
-    ptrdiff_t count = SPECPDL_INDEX ();
+    dynwind_begin ();
     /* Prevent error in erase-buffer.  */
     specbind (Qinhibit_read_only, Qt);
     specbind (Qinhibit_modification_hooks, Qt);
     old_deactivate_mark = Vdeactivate_mark;
     Ferase_buffer ();
     Vdeactivate_mark = old_deactivate_mark;
-    unbind_to (count, Qnil);
+    dynwind_end ();
   }
 
   /* When we get to the outmost level, make sure we resize the
@@ -983,7 +985,7 @@ Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
   (Lisp_Object prompt, Lisp_Object initial_input, Lisp_Object history, Lisp_Object default_value, Lisp_Object inherit_input_method)
 {
   Lisp_Object val;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   /* Just in case we're in a recursive minibuffer, make it clear that the
      previous minibuffer's completion table does not apply to the new
@@ -996,7 +998,8 @@ Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
                               inherit_input_method);
   if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value))
     val = CONSP (default_value) ? XCAR (default_value) : default_value;
-  return unbind_to (count, val);
+  dynwind_end ();
+  return val;
 }
 
 DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 1, 3, 0,
@@ -1093,7 +1096,7 @@ function, instead of the usual behavior.  */)
   Lisp_Object args[4], result;
   char *s;
   ptrdiff_t len;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
 
   if (BUFFERP (def))
     def = BVAR (XBUFFER (def), name);
@@ -1142,7 +1145,8 @@ function, instead of the usual behavior.  */)
       args[3] = require_match;
       result = Ffuncall (4, args);
     }
-  return unbind_to (count, result);
+  dynwind_end ();
+  return result;
 }
 \f
 static Lisp_Object
@@ -1746,17 +1750,20 @@ the values STRING, PREDICATE and `lambda'.  */)
   /* Reject this element if it fails to match all the regexps.  */
   if (CONSP (Vcompletion_regexp_list))
     {
-      ptrdiff_t count = SPECPDL_INDEX ();
+      dynwind_begin ();
       specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
       for (regexps = Vcompletion_regexp_list; CONSP (regexps);
           regexps = XCDR (regexps))
        {
          if (NILP (Fstring_match (XCAR (regexps),
                                   SYMBOLP (tem) ? string : tem,
-                                  Qnil)))
-           return unbind_to (count, Qnil);
+                                  Qnil))){
+           
+             dynwind_end ();
+           return Qnil;
+           }
        }
-      unbind_to (count, Qnil);
+      dynwind_end ();
     }
 
   /* Finally, check the predicate.  */