Mercurial > emacs
changeset 2407:1c590cd84ab3
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 28 Mar 1993 08:29:21 +0000 |
parents | 465732c007f4 |
children | a9c05a12b615 |
files | src/fileio.c |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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. */