Subject: Re: bug#39853: 26.3; Sort on file-newer-than-file-p does not work outside home folder
From: Stefan Kangas <[email-masked]>
To: Andreas Schwab <[email-masked]>
Cc: dalanicolai <[email-masked]>, [email-masked]
Date: Mon, 24 Aug 2020 04:36:59 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Andreas Schwab <[email-masked]> writes:

> On Mär 01 2020, dalanicolai wrote:
>
>> Although I tried to send this mail from plain emacs and from spacemacs. I
>> was not sure if it worked and did not find a way to check if it worked (At
>> least I did not receive any confirmation e-mail). Although I created this
>> bug report in spacemacs. I tested the behavior using emacs -Q
>>
>> 1. evaluate (sort (directory-files "~") 'file-newer-than-file-p)
>> 2. evaluate previous sexp with a different path ~ inserted: e.g.
>> .emacs.d folder as shown in the attachment
>>
>> The sexp with the home folder returns a date modified list while the
>> sexp with a different folder does not. The attachment shows both folder
>> contents of ordered on date modified in nautilus and the returned lists
>> from evaluating the sexps. The order of the home folder list is
>> consistent with that nautilus while that of the .emacs.d folder is not.
>
> That's because most of the files from ~/.emacs.d don't exist in
> default-directory, and nonexisting files are sorted last by
> file-newer-than-file-p.  Either use (directory-files "~/.emacs.d" t), or
> (let ((default-directory "~/.eamcs.d")) ...).

This is behaving as documented, and is not a bug.  Andreas Schwab
explains above how to use this function correctly.  I'm therefore
closing this bug report.

Best regards,
Stefan Kangas