emacs错误';ls不支持--dired';

emacs错误';ls不支持--dired';,emacs,freebsd,emacs24,Emacs,Freebsd,Emacs24,自从升级到emacs24.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

自从升级到
emacs24.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
设置为nil。emacs
会使消息安静吗

是否有人认为不开车上班可能代表安全问题?i、 e.由空白组成的文件名是否仍然不可见

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

大概是dired.el在加载时将dired use ls dired设置为非nil,而我在第一次查看目录时不断地对其进行重击?在my.emacs中将dired use ls dired设置为nil会使消息安静吗


我认为你说的是对的。将值自定义为
nil
。(如果这没有帮助,您可以随时删除自定义项。)

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

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

在这种情况下,您也可以尝试使用GNULS,您可以在这里安装这个实用程序

在我的例子中,我维护这两个工具,gnu核心实用程序的前缀都是“g”

如果使用gls,则启用--dired参数

man gls
名字 ls-列出目录内容

概要 ls[选项]。。。[文件]

描述 列出有关文件的信息(默认情况下为当前目录)。如果没有-cftuvSUX或--Sort,则按字母顺序对条目进行排序 是指定的

   Mandatory arguments to long options are mandatory for short options too.


                             .... 
   -d, --directory
          list directories themselves, not their contents

                              ....
然后我们有太多的配置emacs:

(when (string= system-type "darwin")
  (setq dired-use-ls-dired t
        insert-directory-program "/usr/local/bin/gls"
        dired-listing-switches "-aBhl --group-directories-first"))

然后您可以使用这个:

emacs依赖于特定于GNU的ls实现,很有趣。我不熟悉ls-lisp,但如果不能正确处理文件名中的空格,可能会被利用。“大概”--你不必做任何假设,只要阅读你引用的文档就可以了。如果您想知道由空白组成的文件名会发生什么情况,请尝试一个。这里没有安全问题,当然与看起来与普通ASCII相同但不是“emacs依赖于GNU特定的ls实现,有趣”的unicode序列相比——emacs不“依赖”它,它只是在可用时使用它。它说如果你的
ls
不支持--dired,你可以使用
ls-lisp
ls lisp
没有GNU
ls
的所有功能,但是您不需要它们来驱动。emacs正确处理文件名中的空白;是
ls
没有指明哪些空白是或不是文件名的一部分。。。但你不必使用ls。。。只需使用
ls lisp
即可。(emacs在一些没有任何
ls
命令的系统上运行。它不“依赖”它。)另外,如果您不想让空白文件名不可见,请在dired列表开关中设置--quoting样式(请参见man ls)。我在运行24.5.1的OSX机器上尝试将dired use ls diredt设置为nil,它确实消除了该消息。之后Dired似乎也能正常工作。@kevin如果您将此选项设置为零。。。Dired将无法解析某些“不寻常”的文件名,例如,带有前导空格的文件名。除非你有这样的文件,当然dired会“正常工作”。
(when (string= system-type "darwin")
  (setq dired-use-ls-dired t
        insert-directory-program "/usr/local/bin/gls"
        dired-listing-switches "-aBhl --group-directories-first"))