0

gls not ls:

My system has two forms of ls, the standard "old school" version of ls, and GNU ls which is available as gls. In my shell, I simply created an alias to use gls, but I have not found a way to create the same alias for emacs. As you can probably guess, this impacts my use of dired, which relies on the availability of GNU ls. How do I get emacs to recognize and use the gls instead of ls?

1 Answer 1

1
insert-directory-program is a variable defined in ‘files.el’.

Its value is "ls"

Absolute or relative name of the ‘ls’-like program.
This is used by ‘insert-directory’ and ‘dired-insert-directory’
(thus, also by ‘dired’).

  This variable may be risky if used as a file-local variable.

Hence:

(setq insert-directory-program "gls")
6
  • Confirmed! That worked. No more error messages about ls --dired. Hooray!!! On OpenBSD gls is exactly the same as calling ls on Linux. It is one of the catches programmers often run into when attempting to write code for both Linux and OpenBSD. I am so happy! Happy Dance Time!!!
    – Anoduck
    Commented Feb 25 at 8:54
  • I'm glad that did the trick. Given that particular error, though, you should also look at C-h v dired-use-ls-dired. By my reading, its default value should have been avoiding that error; so if that user option was set to its default value and failing to correctly detect the situation, then you should M-x report-emacs-bug so that the detection could be improved.
    – phils
    Commented Feb 25 at 11:26
  • That said, in order to figure out whether or not to use the --dired option, dired-insert-directory simply runs ls --dired behind the scenes and checks whether or not that produced an error, which seems like it ought to be reliable; so I'd think that either the ls implementation is behaving in unexpected ways, or you had that user option customized to enforce the --dired usage.
    – phils
    Commented Feb 25 at 11:36
  • I believe that using gls is still going to be the most reliable option, though, so I'm not suggesting that you revert that change.
    – phils
    Commented Feb 25 at 11:39
  • I believe the latter was the case. Saying this, I was aware of the ls-lisp option, but did not want to "settle" for it when there was no reason to, and have been meaning to "fix" the issue for an unreasonable amount of time.
    – Anoduck
    Commented Feb 25 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.