OS X 上的直接排序错误

发布于 2024-09-30 02:26:03 字数 426 浏览 8 评论 0原文

在 OS X 10.5 Emacs 23.2 上,在 dired 模式下,如果我尝试使用前缀参数 --sort=extensiondired-sort-toggle-or-edit 进行排序-X,我得到:

insert-directory: Listing directory failed but `access-file' worked

并且 dired 缓冲区变空。我尝试设置

(setq dired-use-ls-dired nil)

但这没有效果。 dired-sort-toggle-or-edit 和按扩展名排序似乎在我的 Ubuntu 机器上工作正常。有人知道发生了什么事吗?

On OS X 10.5 Emacs 23.2, in dired-mode, if I try to sort by dired-sort-toggle-or-edit with prefix argument --sort=extension or -X, I get:

insert-directory: Listing directory failed but `access-file' worked

and the dired buffer becomes empty. I tried setting

(setq dired-use-ls-dired nil)

but this had no effect. dired-sort-toggle-or-edit and sorting by extension seems to work okay on my Ubuntu box. Anyone have a clue what's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

∞琼窗梦回ˉ 2024-10-07 02:26:03

目前,我还使用 ls-lisp 找到了另一个解决方案

(when (eq system-type 'darwin)
  (require 'ls-lisp)
  (setq ls-lisp-use-insert-directory-program nil))

For now, I've also found another solution using ls-lisp

(when (eq system-type 'darwin)
  (require 'ls-lisp)
  (setq ls-lisp-use-insert-directory-program nil))
始终不够 2024-10-07 02:26:03

OS X 上安装的 ls 不支持 -X 或任何长参数,例如 --sort。设置 dired-use-ls-dired 不会有任何效果; dired 将始终使用 ls,但如果该变量非零,则会将 --dired 传递给 ls。

如果你想要这种类型的排序,你可能可以使用 fink 之类的东西来安装 coreutils,它将提供一个更像你在 Ubuntu 中习惯的 ls 。

The ls that's installed on OS X doesn't support -X or any long arguments like --sort. Setting dired-use-ls-dired won't have any effect; dired will always use ls, but if that variable is non-nil, it will pass --dired to ls.

If you want that type of sorting, you can probably use something like fink to install coreutils, which will provide an ls more like what you're used to in Ubuntu.

我不吻晚风 2024-10-07 02:26:03

以下是使用通过 macports 安装的 coreutils 在 Snow Leopard 10.6.8 上运行 Emacs 的步骤:

注意:我的 macports 安装与通用 (/opt/...) 不同——即,我使用 /macports 作为根目录。不需要改变根设置,这只是我的个人喜好。对于普通 macport 安装或替代设置,请相应地调整路径。

sudo /macports/bin/port install coreutils

这位于 .emacsinit.el 内部:

;; sort directories first

(setq insert-directory-program "/macports/bin/gls")

(setq dired-listing-switches "-aBhl --group-directories-first")

注意:  不建议使用 gls/ls 的符号链接,因为它会破坏 macports 安装的功能,而且很可能还会破坏其他功能。


想要更多控制权的用户的替代安装:

从以下位置下载:coreutils-8.21.tar.xz http://ftp.gnu.org/gnu/coreutils/

如果您没有用于解压缩 *.xz 文件的实用程序,您可以使用诸如 之类的实用程序TheUnarchiver3.9.1

以下是制作 coreutils 的快速参考 - 我将安装位置设置为我自己的个人偏好,而不是默认值:

./configure \
--prefix=/Users/HOME/.0.data/.0.emacs/elpa

make

sudo make install

将它们插入到您的 .emacs中init.el 文件——相应地调整路径:

;; sort directories first

(setq insert-directory-program "/Users/HOME/.0.data/.0.emacs/elpa/bin/ls")

(setq dired-listing-switches "-aBhl --group-directories-first")

Here are the steps for Emacs running on Snow Leopard 10.6.8 using coreutils installed through macports:

NOTE:   My macports installation is different than the generic (/opt/...) -- i.e., I use /macports as the root. Altering the root setup is not required, it is just a personal preference of mine. For vanilla macport installations or alternative setups, adjust the path accordingly.

sudo /macports/bin/port install coreutils

This goes inside the .emacs or init.el:

;; sort directories first

(setq insert-directory-program "/macports/bin/gls")

(setq dired-listing-switches "-aBhl --group-directories-first")

NOTE:   Using a symlink for gls/ls is not recommended because it breaks functionality with macports install and most likely other stuff too.


Alternative installation for users who want more control:

Download: coreutils-8.21.tar.xz from:  http://ftp.gnu.org/gnu/coreutils/

If you do not have a utility to unzip an *.xz file, you can use a utility such as TheUnarchiver3.9.1.

Here is a quick reference to make the coreutils -- I set the installation location to my own personal preference instead of the default:

./configure \
--prefix=/Users/HOME/.0.data/.0.emacs/elpa

make

sudo make install

Insert these into your .emacs or init.el file -- adjust the path accordingly:

;; sort directories first

(setq insert-directory-program "/Users/HOME/.0.data/.0.emacs/elpa/bin/ls")

(setq dired-listing-switches "-aBhl --group-directories-first")
灵芸 2024-10-07 02:26:03

2020年依然发生!如果像我一样,您使用 brew 作为开源包管理器,并且您已经使用 brew install coreutils 安装了 coreutils,那么这是复制粘贴的正确解决方案在您的 .emacs 文件中,或者您保存启动自定义的任何位置:(

(when (equal system-type 'darwin)
  (setq insert-directory-program "/insert/here/path/to/homebrew/ls"))

我检查操作系统,因为我在多个系统上部署了 Emacs 配置)。

当前路径:

/opt/homebrew/opt/coreutils/libexec/gnubin/ls

以前(2022 年之前?)它曾经是:

/usr/local/opt/coreutils/libexec/gnubin/ls

像往常一样,如果您在当前选择的 shell 中将 gnu ls 配置为默认路径,则可以随时通过键入 which ls.

奇怪的是,这种情况突然发生在 Mojave 系统上,我从那时起就经常在该系统上使用 Emacs,并且我确信 dired 过去一直在该系统上工作。我猜想更新破坏了一些东西,使得 Dired 使用正确的二进制文件,而无需手动设置它。

Still happening in 2020! If, like me, you're using brew as your open source package manager, and you have already installed coreutils with brew install coreutils, this is the right solution to copy paste in your .emacs file, or wherever you keep your startup customizations:

(when (equal system-type 'darwin)
  (setq insert-directory-program "/insert/here/path/to/homebrew/ls"))

(I check for the OS because I deploy my Emacs configuration on multiple systems).

Current path:

/opt/homebrew/opt/coreutils/libexec/gnubin/ls

Previously (before 2022?) it used to be:

/usr/local/opt/coreutils/libexec/gnubin/ls

As usual, if you have configured gnu ls as your default in your current shell of choice, you can always check its current full path by typing which ls.

Oddly enough, this happened suddenly on a Mojave system on which I routinely use Emacs since forever, and on which I am sure dired was working in the past. I guess that an update broke something that made dired use the correct binary, without having to manually set it.

悸初 2024-10-07 02:26:03

这与 lawlist 的好答案没有太大不同,但信息略有不同,并且是为那些使用 Nix 包管理器的人量身定制的:

(use-package dired
  :custom
  ;; See http://stackoverflow.com/questions/4115465/emacs-dired-too-much-information
  ;; NOTE: Just some information worth keeping in mind. More readable dired file
  ;; size output - consider adding F (make file type obvious), or p (p adds a
  ;; trailing slash to dirs, but makes moving dirs fail), and G (colorize) too.
  (dired-listing-switches "-alh --group-directories-first")
  :config
  ;; [[https://stackoverflow.com/questions/4076360/error-in-dired-sorting-on-os-x][macos - error in dired sorting on OS X - Stack Overflow]]
  ;; To fix the
  ;; (error "Listing directory failed but 'access-file' worked")
  ;; error. Emacs needs to use gnu's ls, which I get through nixpkgs' coreutils.
  ;; In my config, currently, Emacs is not picking up the path to my nix install
  ;; ls (todo: fix).
  ;;
  ;; Note that, unlike the info at the link provided above,
  ;; --group-directories-first is not needed to fix this error. I just like to
  ;; see the directories first in a dired buffer.
  (setq insert-directory-program (expand-file-name ".nix-profile/bin/ls"
                                                   (getenv "HOME"))))

This is not much different than lawlist's nice answer, but has slightly different information and is tailored to those who use the Nix package manager:

(use-package dired
  :custom
  ;; See http://stackoverflow.com/questions/4115465/emacs-dired-too-much-information
  ;; NOTE: Just some information worth keeping in mind. More readable dired file
  ;; size output - consider adding F (make file type obvious), or p (p adds a
  ;; trailing slash to dirs, but makes moving dirs fail), and G (colorize) too.
  (dired-listing-switches "-alh --group-directories-first")
  :config
  ;; [[https://stackoverflow.com/questions/4076360/error-in-dired-sorting-on-os-x][macos - error in dired sorting on OS X - Stack Overflow]]
  ;; To fix the
  ;; (error "Listing directory failed but 'access-file' worked")
  ;; error. Emacs needs to use gnu's ls, which I get through nixpkgs' coreutils.
  ;; In my config, currently, Emacs is not picking up the path to my nix install
  ;; ls (todo: fix).
  ;;
  ;; Note that, unlike the info at the link provided above,
  ;; --group-directories-first is not needed to fix this error. I just like to
  ;; see the directories first in a dired buffer.
  (setq insert-directory-program (expand-file-name ".nix-profile/bin/ls"
                                                   (getenv "HOME"))))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文