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

时间:2014-08-04 18:28:09

标签: emacs freebsd emacs24

自从升级到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在加载时会将dired-use-ls-dired设置为非零值,而且在我第一次查看目录时,它会不断地破坏它?在.emacs中将{{1}}设置为nil会使信息安静吗?

有没有人认为不能直接上班可能代表安全问题?即,由空格组成的文件名是否仍然不可见?

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

3 个答案:

答案 0 :(得分:8)

macos命令ls不支持--dired选项,而支持linux操作系统!

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

答案 1 :(得分:4)

  

大概是dired.el在加载时将dired-use-ls-dired设置为非零值,并且在我第一次查看目录时不断破坏它?在我的.emacs中将dired-use-ls-dired设置为nil会使消息安静吗?

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

答案 2 :(得分:0)

在这种情况下,您也可以尝试使用gnu-ls,可以在此处how-to-replace-mac-os-x-utilities-with-gnu-core-utilities

安装此实用程序。

在我的情况下,我同时维护了两者,并且gnu核心实用程序的前缀为“ g”。

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

man gls
  

NAME          ls-列出目录内容

     

简介          ls [OPTION] ... [FILE] ...

     

说明          列出有关FILE的信息(默认为当前目录)。如果-cftuvSUX或--sort均不按字母顺序对条目进行排序   已指定。

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


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

                              ....
which gls                                                                                                                                                                
/usr/local/bin/gls

然后,我们也都配置了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"))

然后您可以使用此:

相关问题