【发布时间】:2014-08-04 18:28:08
【问题描述】:
自从升级到emacs 24.x 后,每当我打开一个目录时,我都会看到这个错误。整个错误是:
ls does not support --dired; see `dired-use-ls-dired' for more details.
查看变量,发现:
dired-use-ls-dired is a variable defined in `dired.el'.
Its value is nil
Original value was unspecified
Documentation:
Non-nil means Dired should pass the "--dired" option to "ls".
The special value of `unspecified' means to check explicitly, and
save the result in this variable. This is performed the first
time `dired-insert-directory' is called.
Note that if you set this option to nil, either through choice or
because your "ls" program does not support "--dired", Dired
will fail to parse some "unusual" file names, e.g. those with leading
spaces. You might want to install ls from GNU Coreutils, which does
support this option. Alternatively, you might want to use Emacs's
own emulation of "ls", by using:
(setq ls-lisp-use-insert-directory-program nil)
(require 'ls-lisp)
This is used by default on MS Windows, which does not have an "ls" program.
Note that `ls-lisp' does not support as many options as GNU ls, though.
For more details, see Info node `(emacs)ls in Lisp'.
You can customize this variable.
我在 FreeBSD 上运行;所以默认的ls 不是GNU'ish 并且不提供--dired 选项。我真的不想麻烦在我所有的服务器上安装 GNU coreutilities。
有人对上面提到的 lisp ls 替代方案有任何经验吗?
大概dired.el 在加载时将dired-use-ls-dired 设置为非零值,并且我在第一次查看目录时经常破坏它?在我的.emacs 中将dired-use-ls-dired 设置为nil 会使消息静音吗?
有没有人认为不急于工作可能代表安全问题?即由空格组成的文件名会保持不可见吗?
也许我应该测试一下上面的一些......
【问题讨论】:
-
emacs 依赖于 GNU 特定的 ls 实现,很有趣。我不熟悉 ls-lisp,但没有正确处理文件名中的空格可能会被利用。
-
“大概”——您不必假设任何事情,只需阅读您引用的文档即可。如果您想知道由空格组成的文件名会发生什么,只需尝试一个。而且这里不存在安全问题,当然与看起来与纯 ASCII 相同但实际上并非如此的 unicode 序列相比。
-
"emacs 依赖于 GNU 特定的 ls 实现,很有趣。" -- emacs 不“依赖”它,它只是在可用时使用它。它在那里说如果您的
ls不支持--dired,您可以使用ls-lisp;ls-lisp没有 GNUls的所有功能,但你不需要它们。并且 emacs 可以正确处理文件名中的空格;ls并没有指明哪个空格是或不是文件名的一部分... 但您不必使用 ls ... 只需使用ls-lisp代替。 (emacs 在一些没有任何ls命令的系统上运行。它不“依赖”它。) -
P.S.如果您不希望空白文件名不可见,请在 dired-listing-switches 中设置 --quoting-style(参见 man ls)。