代码之家  ›  专栏  ›  技术社区  ›  hatmatrix

OS X上的定向排序错误

  •  11
  • hatmatrix  · 技术社区  · 14 年前

    dired-sort-toggle-or-edit 带前缀参数 --sort=extension -X ,我得到:

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

    脏缓冲区变空了。我试着设置

    (setq dired-use-ls-dired nil)
    

    但这没有效果。 定向排序切换或编辑

    3 回复  |  直到 9 年前
        1
  •  8
  •   Eric Warmenhoven    14 年前

    这个 ls 安装在OS X上的不支持 -X 或者任何长时间的争论 --sort . 设置 dired-use-ls-dired 不会有任何效果;dired将始终使用ls,但如果该变量不是nil,则它将传递 --dired

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

        2
  •  13
  •   hatmatrix    14 年前

    ls-lisp

    (when (eq system-type 'darwin)
      (require 'ls-lisp)
      (setq ls-lisp-use-insert-directory-program nil))
    
        3
  •  8
  •   lawlist    11 年前

    下面是使用 coreutils 通过macports安装:

    注意:我的macports安装不同于一般的( /opt/... /macports 作为根。不需要更改根设置,这只是我个人的偏好。对于vanilla macport安装或其他设置,请相应地调整路径。

    sudo /macports/bin/port install coreutils
    

    这个在里面 .emacs init.el :

    ;; sort directories first
    
    (setq insert-directory-program "/macports/bin/gls")
    
    (setq dired-listing-switches "-aBhl --group-directories-first")
    

    注意:使用符号链接 gls / ls


    为需要更多控制的用户提供的替代安装:

    下载: coreutils-8.21.tar.xz http://ftp.gnu.org/gnu/coreutils/

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

    这里有一个快速的参考使 核壳

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

    将这些插入 .emacs公司 初始el file—相应地调整路径:

    ;; sort directories first
    
    (setq insert-directory-program "/Users/HOME/.0.data/.0.emacs/elpa/bin/ls")
    
    (setq dired-listing-switches "-aBhl --group-directories-first")
    
        4
  •  0
  •   Joe    5 年前

    这与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"))))