自从升级到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设置为非nil,并且我在第一次查看目录时一直在破坏它吗?并在我的dired-use-ls-dired中将.emacs设置为nil会使消息静音?

有没有人认为不去上班可能意味着安全问题?即由空格组成的文件名是否仍不可见?

也许我应该测试上面的一些...

最佳答案

在macOS上,ls不支持--dired选项,而在Linux上则受支持。

(when (string= system-type "darwin")
  (setq dired-use-ls-dired nil))

10-04 14:28