use dynwind_begin and dynwind_end
[bpt/emacs.git] / src / dired.c
index d3fe5b4..6bec249 100644 (file)
@@ -143,12 +143,9 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
   Lisp_Object list, dirfilename, encoded_directory;
   struct re_pattern_buffer *bufp = NULL;
   bool needsep = 0;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   struct dirent *dp;
-#ifdef WINDOWSNT
-  Lisp_Object w32_save = Qnil;
-#endif
 
   /* Because of file name handlers, these functions might call
      Ffuncall, and cause a GC.  */
@@ -203,7 +200,6 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
         file in the directory, when we call Ffile_attributes below.  */
       record_unwind_protect (directory_files_internal_w32_unwind,
                             Vw32_get_true_file_attributes);
-      w32_save = Vw32_get_true_file_attributes;
       if (EQ (Vw32_get_true_file_attributes, Qlocal))
        {
          /* w32.c:stat will notice these bindings and avoid calling
@@ -310,22 +306,13 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
       UNGCPRO;
     }
 
-  block_input ();
-  closedir (d);
-  unblock_input ();
-#ifdef WINDOWSNT
-  if (attrs)
-    Vw32_get_true_file_attributes = w32_save;
-#endif
-
-  /* Discard the unwind protect.  */
-  specpdl_ptr = specpdl + count;
+  dynwind_end ();
 
   if (NILP (nosort))
     list = Fsort (Fnreverse (list),
                  attrs ? Qfile_attributes_lessp : Qstring_lessp);
 
-  RETURN_UNGCPRO (list);
+  return list;
 }
 
 
@@ -465,7 +452,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
      well as "." and "..".  Until shown otherwise, assume we can't exclude
      anything.  */
   bool includeall = 1;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
 
   elt = Qnil;
@@ -756,7 +743,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
 
   UNGCPRO;
   /* This closes the directory.  */
-  bestmatch = unbind_to (count, bestmatch);
+  dynwind_end ();
 
   if (all_flag || NILP (bestmatch))
     return bestmatch;
@@ -1041,6 +1028,8 @@ The value may be nil if not supported on this platform.  */)
 void
 syms_of_dired (void)
 {
+#include "dired.x"
+
   DEFSYM (Qdirectory_files, "directory-files");
   DEFSYM (Qdirectory_files_and_attributes, "directory-files-and-attributes");
   DEFSYM (Qfile_name_completion, "file-name-completion");
@@ -1049,15 +1038,6 @@ syms_of_dired (void)
   DEFSYM (Qfile_attributes_lessp, "file-attributes-lessp");
   DEFSYM (Qdefault_directory, "default-directory");
 
-  defsubr (&Sdirectory_files);
-  defsubr (&Sdirectory_files_and_attributes);
-  defsubr (&Sfile_name_completion);
-  defsubr (&Sfile_name_all_completions);
-  defsubr (&Sfile_attributes);
-  defsubr (&Sfile_attributes_lessp);
-  defsubr (&Ssystem_users);
-  defsubr (&Ssystem_groups);
-
   DEFVAR_LISP ("completion-ignored-extensions", Vcompletion_ignored_extensions,
               doc: /* Completion ignores file names ending in any string in this list.
 It does not ignore them if all possible completions end in one of