Function: eshell-ls--insert-directory

eshell-ls--insert-directory is a byte-compiled function defined in em-ls.el.gz.

Signature

(eshell-ls--insert-directory ORIG-FUN FILE SWITCHES &optional WILDCARD FULL-DIRECTORY-P)

Documentation

Insert directory listing for FILE, formatted according to SWITCHES.

Leaves point after the inserted text. SWITCHES may be a string of options, or a list of strings. Optional third arg WILDCARD means treat FILE as shell wildcard. Optional fourth arg FULL-DIRECTORY-P means file is a directory and switches do not contain d, so that a full listing is expected.

This version of the function uses eshell/ls. If any of the switches passed are not recognized, the operating system's version will be used instead.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-ls.el.gz
(defun eshell-ls--insert-directory
  (orig-fun file switches &optional wildcard full-directory-p)
  "Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
SWITCHES may be a string of options, or a list of strings.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.

This version of the function uses `eshell/ls'.  If any of the switches
passed are not recognized, the operating system's version will be used
instead."
  (if (not eshell-ls-use-in-dired)
      (funcall orig-fun file switches wildcard full-directory-p)
    (let ((handler (find-file-name-handler file 'insert-directory)))
      (if handler
          (funcall handler 'insert-directory file switches
                   wildcard full-directory-p)
        (if (stringp switches)
            (setq switches (split-string switches)))
        (let (eshell-current-handles
              eshell-current-subjob-p
              font-lock-mode)
          ;; use the fancy highlighting in `eshell-ls' rather than font-lock
          (when eshell-ls-use-colors
            (font-lock-mode -1)
            (setq font-lock-defaults nil)
            (if (boundp 'font-lock-buffers)
                (setq font-lock-buffers
                      (delq (current-buffer)
                            (symbol-value 'font-lock-buffers)))))
          (require 'em-glob)
          (let* ((insert-func 'insert)
                 (error-func 'insert)
                 (flush-func 'ignore)
                 (eshell-error-if-no-glob t)
                 (target ; Expand the shell wildcards if any.
                  (if (and (atom file)
                           (string-match "[[?*]" file)
                           (not (file-exists-p file)))
                      (mapcar #'file-relative-name (eshell-extended-glob file))
                    (file-relative-name file)))
                 (switches
                  (append eshell-ls-dired-initial-args
                          (and (or (consp dired-directory) wildcard) (list "-d"))
                          switches)))
            (eshell-do-ls (nconc switches (list target)))))))))