Subject: Re: bug#50630: [PATCH] Add tests for insert-directory

From: John Cummings <[email-masked]>
Date: Sat, 25 Sep 2021 17:15:21 +0000

>>  I and others found that the same problem was duplicated in ls-lisp.el
>>  and tramp-sh.el, and I provided instructions to reproduce attached
>>  earlier in the thread:
>>  https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-09/msg01813.html

> That recipe invokes insert-directory in some arbitrary way, which is
> probably different from what happens when one invokes Dired.  So I'm
> not sure we should worry about that.  But anyway, I tried that recipe
> on MS-Windows, and I don't see the problem: the values shown on the
> first line reflect my home directory, not pwd-a or pwd-b.

I'm replying only to this part for now, because we need to agree on
the facts in order to do anything else. If what you say is accurate,
then this bug may not really exist as I've described it, but I think
I've done everything reasonable to eliminate that possibility. Are you
sure that you picked values for pwd-a and pwd-b that would have
different amounts of available space on MS-Windows, like two drive
letters on physically separate disks?  But if Windows uses ls-lisp for
this, we should see the same results on any system using ls-lisp, so I
think it's OK to focus on ls-lisp and forget about MS-Windows for the
purposes of this reply.

I tried to supply values for pwd-a and pwd-b that would be under
different mount points on a Unix-like system, / and /proc, but if your
system is different, you may need to pick different Unix-like values
for those, too.

I just built 285f59cbe230701f15d28dfe8036cf2feb9d1d31 (terminal only)
from a brand new git clone on Ubuntu 20,and here are the results of
the recipes. I'll use a "[" character to quote the text I copied off
my terminal:

files.el (this case is already fixed):
 [emacsdev@ubuntu:~/freshemacs/emacs$ src/emacs -Q --eval "\
 [> (progn \
 [>    (setq pwd-a \"/\") \
 [>    (setq pwd-b \"/proc\")  \
 [>    (setq list-dir \"~\") \
 [>    (with-current-buffer-window \"a\" nil nil \
 [>       (cd pwd-a) \
 [>       (insert-directory list-dir \"-l\" nil t) \
 [>       (insert (format \"listing of %s in cwd %s\" list-dir (pwd)))) \
 [>    (with-current-buffer-window \"b\" nil nil \
 [>       (cd pwd-b) \
 [>       (insert-directory list-dir \"-l\" nil t) \
 [>       (insert (format \"listing of %s in cwd %s\" list-dir (pwd)))) \
 [>    (switch-to-buffer \"a\") \
 [>    (switch-to-buffer-other-window \"b\"))"

Resulting Emacs frame:
 [File Edit Options Buffers Tools Help
 [total used in directory 0 available 7.6 GiB
 [lrwxrwxrwx 1 emacsdev emacsdev 26 Sep 24 12:18 emacs -> /media/ubuntu/turkey/emacs
 [lrwxrwxrwx 1 emacsdev emacsdev 31 Sep 25 12:26 freshemacs -> /media/ubuntu/turkey/freshemacs
 [listing of ~ in cwd Directory /
 [
 [
 [
 [
 [
 [
 [
 [-UUU:%%--F1  a              All L1     (Fundamental) -----------------------------------------
 [total used in directory 0 available 7.6 GiB
 [lrwxrwxrwx 1 emacsdev emacsdev 26 Sep 24 12:18 emacs -> /media/ubuntu/turkey/emacs
 [lrwxrwxrwx 1 emacsdev emacsdev 31 Sep 25 12:26 freshemacs -> /media/ubuntu/turkey/freshemacs
 [listing of ~ in cwd Directory /proc/
 [
 [
 [
 [
 [
 [
 [-UUU:%%--F1  b              All L1     (Fundamental) -----------------------------------------
 [

ls-lisp.el (not fixed yet):
 [emacsdev@ubuntu:~/freshemacs/emacs$ src/emacs -Q --eval "\
 [> (progn \
 [>    (setq pwd-a \"/\") \
 [>    (setq pwd-b \"/proc\")  \
 [>    (setq list-dir \"~\") \
 [>    (require 'ls-lisp) \
 [>    (setq ls-lisp-use-insert-directory-program nil) \
 [>    (with-current-buffer-window \"a\" nil nil \
 [>       (cd pwd-a) \
 [>       (insert-directory list-dir \"-l\" nil t) \
 [>       (insert (format \"listing of %s in cwd %s\" list-dir (pwd)))) \
 [>    (with-current-buffer-window \"b\" nil nil \
 [>       (cd pwd-b) \
 [>       (insert-directory list-dir \"-l\" nil t) \
 [>       (insert (format \"listing of %s in cwd %s\" list-dir (pwd)))) \
 [>    (switch-to-buffer \"a\") \
 [>    (switch-to-buffer-other-window \"b\"))"

 Resulting Emacs frame with different available space:
 [File Edit Options Buffers Tools Help
 [total used in directory 1 available 7.6 GiB
 [lrwxrwxrwx  1 emacsdev emacsdev 26 09-24 12:18 emacs -> /media/ubuntu/turkey/emacs
 [lrwxrwxrwx  1 emacsdev emacsdev 31 09-25 12:26 freshemacs -> /media/ubuntu/turkey/freshemacs
 [listing of ~ in cwd Directory /
 [
 [
 [
 [
 [
 [
 [
 [-UUU:%%--F1  a              All L1     (Fundamental) -----------------------------------------
 [total used in directory 1 available 0 B
 [lrwxrwxrwx  1 emacsdev emacsdev 26 09-24 12:18 emacs -> /media/ubuntu/turkey/emacs
 [lrwxrwxrwx  1 emacsdev emacsdev 31 09-25 12:26 freshemacs -> /media/ubuntu/turkey/freshemacs
 [listing of ~ in cwd Directory /proc/
 [
 [
 [
 [
 [
 [
 [-UUU:%%--F1  b              All L1     (Fundamental) -----------------------------------------
 [

tramp-sh.el (not fixed yet):
 [emacsdev@ubuntu:~/freshemacs/emacs$ src/emacs -Q --eval "\
 [> (progn \
 [>    (setq pwd-a \"/\") \
 [>    (setq pwd-b \"/proc\")  \
 [>    (setq list-dir \"/ssh:emacsdev@localhost:~/\") \
 [>    (require 'tramp) \
 [>    (setq ls-lisp-use-insert-directory-program t) \
 [>    (with-current-buffer-window \"a\" nil nil \
 [>       (cd pwd-a) \
 [>       (insert-directory list-dir \"-l\" nil t) \
 [>       (insert (format \"listing of %s in cwd %s\" list-dir (pwd)))) \
 [>    (with-current-buffer-window \"b\" nil nil \
 [>       (cd pwd-b) \
 [>       (insert-directory list-dir \"-l\" nil t) \
 [>       (insert (format \"listing of %s in cwd %s\" list-dir (pwd)))) \
 [>    (switch-to-buffer \"a\") \
 [>    (switch-to-buffer-other-window \"b\"))"

 Resulting Emacs frame with different available space:
 [File Edit Options Buffers Tools Help
 [total used in directory 0 available 7.6 GiB
 [lrwxrwxrwx 1 emacsdev emacsdev 26 Sep 24 12:18 emacs -> /media/ubuntu/turkey/emacs
 [lrwxrwxrwx 1 emacsdev emacsdev 31 Sep 25 12:26 freshemacs -> /media/ubuntu/turkey/freshemacs
 [listing of /ssh:emacsdev@localhost:~/ in cwd Directory /
 [
 [
 [
 [
 [
 [
 [
 [-UUU:%%--F1  a              All L1     (Fundamental) -----------------------------------------
 [total used in directory 0 available 0 B
 [lrwxrwxrwx 1 emacsdev emacsdev 26 Sep 24 12:18 emacs -> /media/ubuntu/turkey/emacs
 [lrwxrwxrwx 1 emacsdev emacsdev 31 Sep 25 12:26 freshemacs -> /media/ubuntu/turkey/freshemacs
 [listing of /ssh:emacsdev@localhost:~/ in cwd Directory /proc/
 [
 [
 [
 [
 [
 [
 [-UUU:%%--F1  b              All L1     (Fundamental) -----------------------------------------
 [