Function: ls-lisp--sanitize-switches

ls-lisp--sanitize-switches is a byte-compiled function defined in ls-lisp.el.gz.

Signature

(ls-lisp--sanitize-switches SWITCHES)

Documentation

Convert long options of GNU 'ls' to their short form.

Conversion is done only for flags supported by ls-lisp. Long options not supported by ls-lisp are removed. Supported options are: A a B C c F G g h i n R r S s t U u v X. The l switch is assumed to be always present and cannot be turned off.

Source Code

;; Defined in /usr/src/emacs/lisp/ls-lisp.el.gz
(defun ls-lisp--sanitize-switches (switches)
  "Convert long options of GNU 'ls' to their short form.
Conversion is done only for flags supported by ls-lisp.
Long options not supported by ls-lisp are removed.
Supported options are: A a B C c F G g h i n R r S s t U u v X.
The l switch is assumed to be always present and cannot be turned off."
  (let ((lsflags '(("-a" . "--all")
                   ("-A" . "--almost-all")
                   ("-B" . "--ignore-backups")
                   ("-C" . "--color")
                   ("-F" . "--classify")
                   ("-G" . "--no-group")
                   ("-h" . "--human-readable")
                   ("-H" . "--dereference-command-line")
                   ("-i" . "--inode")
                   ("-n" . "--numeric-uid-gid")
                   ("-r" . "--reverse")
                   ("-R" . "--recursive")
                   ("-s" . "--size")
                   ("-S" . "--sort.*[ \\\t]")
                   (""   . "--group-directories-first")
                   (""   . "--author")
                   (""   . "--escape")
                   (""   . "--directory")
                   (""   . "--dired")
                   (""   . "--file-type")
                   (""   . "--format")
                   (""   . "--full-time")
                   (""   . "--si")
                   (""   . "--dereference-command-line-symlink-to-dir")
                   (""   . "--hide")
                   (""   . "--hyperlink")
                   (""   . "--ignore")
                   (""   . "--kibibytes")
                   (""   . "--dereference")
                   (""   . "--literal")
                   (""   . "--hide-control-chars")
                   (""   . "--show-control-chars")
                   (""   . "--quote-name")
                   (""   . "--context")
                   (""   . "--help")
                   ;; (""   . "--indicator-style.*[ \\\t]")
                   ;; (""   . "--quoting-style.*[ \t\\]")
                   ;; (""   . "--time.*[ \\\t]")
                   ;; (""   . "--time-style.*[ \\\t]")
                   ;; (""   . "--tabsize.*[ \\\t]")
                   ;; (""   . "--width.*[ \\\t]")
                   (""   . "--.*=.*[ \\\t\n]?") ;; catch all with '=' sign in
                   (""   . "--version"))))
    (dolist (f lsflags)
      (if (string-match (cdr f) switches)
          (setq switches (replace-match (car f) nil nil switches))))
    (string-trim switches)))