首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >emacs错误“ls不支持--dired”

emacs错误“ls不支持--dired”
EN

Stack Overflow用户
提问于 2014-08-05 02:28:09
回答 3查看 6.9K关注 0票数 17

自从升级到emacs 24.x后,我每次打开一个目录都会看到这个错误。整个错误是:

代码语言:javascript
复制
ls does not support --dired; see `dired-use-ls-dired' for more details.

查看该变量,您会发现:

代码语言:javascript
复制
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级别的,也没有提供--dired选项。我真的不想麻烦地在我所有的服务器上安装GNU核心实用程序。

有没有人有使用上面提到的lisp ls替代方案的经验?

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

有没有人认为不去工作可能是一个安全问题?也就是说,由空格组成的文件名会保持不可见吗?

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

EN

回答 3

Stack Overflow用户

发布于 2017-02-04 16:25:00

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

代码语言:javascript
复制
(when (string= system-type "darwin")       
  (setq dired-use-ls-dired nil))
票数 14
EN

Stack Overflow用户

发布于 2019-05-12 14:37:41

在这种情况下,您也可以尝试使用gnu-ls,您可以安装此实用程序takea查看此处how-to-replace-mac-os-x-utilities-with-gnu-core-utilities

在我的例子中,我维护两者,并且gnu核心实用程序以"g“为前缀。

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

代码语言:javascript
复制
man gls

NAME ls - 列出目录内容

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

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

多头期权的强制性参数对于空头期权也是强制性的。 .... -d, --directory 列出目录本身,而不是它们的内容 ....

代码语言:javascript
复制
which gls                                                                                                                                                                
/usr/local/bin/gls

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

代码语言:javascript
复制
(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"))

然后,您可以使用以下命令:

票数 6
EN

Stack Overflow用户

发布于 2014-08-05 04:09:58

dired.el可能在加载时将dired-

-ls-dired设置为非nil值,而我在第一次查看目录时却不断地重击它?在我的.emacs中将dired-use-ls-dired设置为nil会使消息静默吗?

我认为你说的是对的。将该值自定义为nil。(如果这不起作用,您可以随时删除您的自定义设置。)

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25125200

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档