# HG changeset patch # User Richard M. Stallman # Date 733307361 0 # Node ID 1c590cd84ab38658816ce239cf8587b14d12f56e # Parent 465732c007f4918ba4d16e38cb3006991bfacb13 (Fexpand_file_name): Default DEFALT at beginning, before expanding it. But avoid unneeded or infinite recursive expand. (Fwrite_region): Set visit_file after expanding file arg. Also expand VISIT arg if specified. diff -r 465732c007f4 -r 1c590cd84ab3 src/fileio.c --- a/src/fileio.c Sun Mar 28 08:27:34 1993 +0000 +++ b/src/fileio.c Sun Mar 28 08:29:21 1993 +0000 @@ -623,6 +623,11 @@ if (!NILP (handler)) return call3 (handler, Qexpand_file_name, name, defalt); + /* Use the buffer's default-directory if DEFALT is omitted. */ + if (NILP (defalt)) + defalt = current_buffer->directory; + CHECK_STRING (defalt, 1); + /* Make sure DEFALT is properly expanded. It would be better to do this down below where we actually use defalt. Unfortunately, calling Fexpand_file_name recursively @@ -630,8 +635,12 @@ be annoying because we have pointers into strings lying around that would need adjusting, and people would add new pointers to the code and forget to adjust them, resulting in intermittent bugs. - Putting this call here avoids all that crud. */ - if (! NILP (defalt)) + Putting this call here avoids all that crud. + + The EQ test avoids infinite recursion. */ + if (! NILP (defalt) && !EQ (defalt, name) + /* This saves time in a common case. */ + && XSTRING (defalt)->data[0] != '/') { struct gcpro gcpro1; @@ -831,9 +840,6 @@ #endif /* not VMS */ && !newdir) { - if (NILP (defalt)) - defalt = current_buffer->directory; - CHECK_STRING (defalt, 1); newdir = XSTRING (defalt)->data; } @@ -2486,7 +2492,7 @@ unsigned char *fname = 0; /* If non-0, original filename (must rename) */ #endif /* VMS */ Lisp_Object handler; - Lisp_Object visit_file = XTYPE (visit) == Lisp_String ? visit : filename; + Lisp_Object visit_file; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; /* Special kludge to simplify auto-saving */ @@ -2498,8 +2504,13 @@ else if (XTYPE (start) != Lisp_String) validate_region (&start, &end); + filename = Fexpand_file_name (filename, Qnil); + if (XTYPE (visit) == Lisp_String) + visit = Fexpand_file_name (visit, Qnil); + else + visit_file = filename; + GCPRO4 (start, filename, visit, visit_file); - filename = Fexpand_file_name (filename, Qnil); /* If the file name has special constructs in it, call the corresponding file handler. */