bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36502: Fwd: bug#36502: 27.0.50; infinite loop in file-name-case-inse


From: Ken Brown
Subject: bug#36502: Fwd: bug#36502: 27.0.50; infinite loop in file-name-case-insensitive-p
Date: Mon, 8 Jul 2019 16:44:23 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

On 7/8/2019 11:17 AM, Ken Brown wrote:
> On 7/8/2019 9:59 AM, Eli Zaretskii wrote:
>> I'm asking why not do this instead:
>>
>>     if (NILP (default_directory))
>>       {
>>         default_directory = BVAR (current_buffer, directory);
>>         if (NILP (Ffile_name_absolute_p (default_directory)))
>>           default_directory = Fexpand_file_name (default_directory,
>>                                             Vinvocation_directory);
>>       }
> 
> Oh, I see.  I misunderstood what you were suggesting.
> 
>> Or will the above not work for some reason?
> 
> I think something like this should work, with some care.  First,
> invocation-directory might be nil, so we have to avoid an infinite loop in 
> that
> case.  Second, the code in emacs.c that sets Vinvocation_directory calls
> Fexpand_file_name in some cases, so there's another potential infinite loop
> resulting from that.
> 
> I'll see what I can come up with, also taking Andreas's comment into account.

New attempt:

--- a/src/fileio.c
+++ b/src/fileio.c
@@ -804,7 +804,22 @@ DEFUN ("expand-file-name", Fexpand_file_name, 
Sexpand_file_name, 1, 2, 0,

    /* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted.  */
    if (NILP (default_directory))
-    default_directory = BVAR (current_buffer, directory);
+    {
+      Lisp_Object dir = BVAR (current_buffer, directory);
+      /* The buffer's default-directory should be absolute.  If it
+        isn't, try to expand it relative to invocation-directory.
+        But we have to be careful to avoid an infinite loop, because
+        the code in emacs.c that sets Vinvocation_directory might
+        call Fexpand_file_name.  */
+      if (STRINGP (dir))
+       {
+         if (!NILP (Ffile_name_absolute_p (dir)))
+           default_directory = dir;
+         else if (STRINGP (Vinvocation_directory)
+                  && !NILP (Ffile_name_absolute_p (Vinvocation_directory)))
+           default_directory = Fexpand_file_name (dir, Vinvocation_directory);
+       }
+    }
    if (! STRINGP (default_directory))
      {
  #ifdef DOS_NT

reply via email to

[Prev in Thread] Current Thread [Next in Thread]