;ELC ;;; Compiled by cyd@localhost on Mon Apr 23 22:20:57 2007 ;;; from file /home/cyd/emacs/lisp/ls-lisp.el ;;; in Emacs version 22.0.99 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. (if (and (boundp 'emacs-version) (< (aref emacs-version (1- (length emacs-version))) ?A) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.29"))) (error "`ls-lisp.el' was compiled for Emacs 19.29 or later")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (custom-declare-group 'ls-lisp nil "Emulate the ls program completely in Emacs Lisp." :version "21.1" :group 'dired) #@325 *Platform to emulate: GNU (default), MacOS, MS-Windows, UNIX. Corresponding value is one of the atoms: nil, MacOS, MS-Windows, UNIX. Sets default values for: `ls-lisp-ignore-case', `ls-lisp-dirs-first', `ls-lisp-verbosity'. Need not match actual platform. Changing this option will have no effect until you restart Emacs. (custom-declare-variable 'ls-lisp-emulation '(cond ((eq system-type 'macos) 'MacOS) ((memq system-type '(hpux dgux usg-unix-v unisoft-unix rtu irix berkeley-unix)) 'UNIX)) '(#$ . -679) :type '(choice (const :tag "GNU" nil) (const MacOS) (const MS-Windows) (const UNIX)) :group 'ls-lisp) #@60 *Non-nil causes ls-lisp alphabetic sorting to ignore case. (custom-declare-variable 'ls-lisp-ignore-case '(or (memq ls-lisp-emulation '(MS-Windows MacOS)) (and (boundp 'ls-lisp-dired-ignore-case) ls-lisp-dired-ignore-case)) '(#$ . -1296) :type 'boolean :group 'ls-lisp) #@134 *Non-nil causes ls-lisp to sort directories first in any ordering. (Or last if it is reversed.) Follows Microsoft Windows Explorer. (custom-declare-variable 'ls-lisp-dirs-first '(eq ls-lisp-emulation 'MS-Windows) '(#$ . -1573) :type 'boolean :group 'ls-lisp) #@578 *A list of optional file attributes that ls-lisp should display. It should contain none or more of the symbols: links, uid, gid. nil (or an empty list) means display none of them. Concepts come from UNIX: `links' means count of names associated with the file; `uid' means user (owner) identifier; `gid' means group identifier. If emulation is MacOS then default is nil; if emulation is MS-Windows then default is `(links)' if platform is Windows NT/2K, nil otherwise; if emulation is UNIX then default is `(links uid)'; if emulation is GNU then default is `(links uid gid)'. (custom-declare-variable 'ls-lisp-verbosity '(cond ((eq ls-lisp-emulation 'MacOS) nil) ((eq ls-lisp-emulation 'MS-Windows) (if (and (fboundp 'w32-using-nt) (w32-using-nt)) '(links))) ((eq ls-lisp-emulation 'UNIX) '(links uid)) (t '(links uid gid))) '(#$ . -1840) :type '(set (const :tag "Show Link Count" links) (const :tag "Show User" uid) (const :tag "Show Group" gid)) :group 'ls-lisp) #@247 *Non-nil causes ls-lisp to revert back to using `insert-directory-program'. This is useful on platforms where ls-lisp is dumped into Emacs, such as Microsoft Windows, but you would still like to use a program to list the contents of a directory. (custom-declare-variable 'ls-lisp-use-insert-directory-program '(not (memq system-type '(macos ms-dos windows-nt))) '(#$ . -2813) :type 'boolean :group 'ls-lisp) #@139 *Non-nil means ls-lisp treats file patterns as shell wildcards. Otherwise they are treated as Emacs regexps (for backward compatibility). (custom-declare-variable 'ls-lisp-support-shell-wildcards 't '(#$ . -3228) :type 'boolean :group 'ls-lisp) #@556 *List of `format-time-string' specs to display file time stamps. These specs are used ONLY if a valid locale can not be determined. If `ls-lisp-use-localized-time-format' is non-nil, these specs are used regardless of whether the locale can be determined. Syntax: (EARLY-TIME-FORMAT OLD-TIME-FORMAT) The EARLY-TIME-FORMAT is used if file has been modified within the current year. The OLD-TIME-FORMAT is used for older files. To use ISO 8601 dates, you could set: (setq ls-lisp-format-time-list '("%Y-%m-%d %H:%M" "%Y-%m-%d ")) (custom-declare-variable 'ls-lisp-format-time-list ''("%b %e %H:%M" "%b %e %Y") '(#$ . -3480) :type '(list (string :tag "Early time format") (string :tag "Old time format")) :group 'ls-lisp) #@237 *Non-nil causes ls-lisp to use `ls-lisp-format-time-list' even if a valid locale is specified. WARNING: Using localized date/time format might cause Dired columns to fail to lign up, e.g. if month names are not all of the same length. (custom-declare-variable 'ls-lisp-use-localized-time-format 'nil '(#$ . -4234) :type 'boolean :group 'ls-lisp) #@68 This holds the original function definition of `insert-directory'. (defvar original-insert-directory nil (#$ . 4587)) (byte-code "\301\302!\204 \303K\301\207" [original-insert-directory featurep ls-lisp insert-directory] 2) #@1151 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 comes from `ls-lisp.el'. If the value of `ls-lisp-use-insert-directory-program' is non-nil then it works exactly like the version from `files.el' and runs a directory listing program whose name is in the variable `insert-directory-program'; if also WILDCARD is non-nil then it runs the shell specified by `shell-file-name'. If the value of `ls-lisp-use-insert-directory-program' is nil then it runs a Lisp emulation. The Lisp emulation does not run any external programs or shells. It supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards' is non-nil; otherwise, it interprets wildcards as regular expressions to match file names. It does not support all `ls' switches -- those that work are: A a c i r S s t u U X g G B C R and F partly. (defalias 'insert-directory #[(file switches &optional wildcard full-directory-p) "\203 \n \f $\207\306\307\n!\310\"\311\"\211#\203%#\310\n \f %\202\256\312\313 \"\2033\314\315\311\211 $\316\317\320 \311\"\"$\203Z\312\321\n\"\203Z\n\211GSH\322=\203X\n\323\nGSO\324\f\203w$\203k\325\326\n!!\202n\326\n!\"\327\n!\202\200\330 >\203\200\331\"\332\n \333 !\" %\210\212eb\210\334\335\311\324#\205\255\336\337!\211%\205\254\314\340!\210\311\210\341%\261))*\207" [ls-lisp-use-insert-directory-program original-insert-directory file switches wildcard full-directory-p find-file-name-handler expand-file-name insert-directory nil string-match "--dired " replace-match "" delete 45 append "[[?*]" 47 0 t wildcard-to-regexp file-name-nondirectory file-name-directory 66 "[^~]\\'" ls-lisp-insert-directory ls-lisp-time-index re-search-forward "^total" get-free-disk-space "." "total used in directory" " available " wildcard-regexp handler ls-lisp-support-shell-wildcards available] 7 (#$ . 4821)]) #@528 Insert directory listing for FILE, formatted according to SWITCHES. Leaves point after the inserted text. This is an internal function optionally called by the `ls-lisp.el' version of `insert-directory'. It is called recursively if the -R switch is used. SWITCHES is a *list* of characters. TIME-INDEX is the time index into file-attributes according to SWITCHES. WILDCARD-REGEXP is nil or an *Emacs regexp*. FULL-DIRECTORY-P means file is a directory and SWITCHES does not contain `d', so that a full listing is expected. (defalias 'ls-lisp-insert-directory #[(file switches time-index wildcard-regexp full-directory-p) "\204 \203/\306\n!\211\307 \310\311\312%\313 .\314/\310\21101\310\21123\310\21145\3106\3157>\203A\316\317 \"\202M\3207>\204M\316\321 \"\322 7\"\3237>\203a\324 !\210\202\347` \242B0 11\203\3141@21A12@32A6\3256846\203j4/\3264ZW\204\250\327/!\204\250\3274!\203\255/\202\261\330/!\\\211/\203j\33136478.&c\210\202j\2120@b\2100A\204\333\332c\210\333\334\335/\336\245!\"c\210)\3377>\205, \205, @2 A2\2119A@)\311=\203\356\340\3412@\"\204\356\3422@ \"2\3432\344\261\210\345278 %\210\202\356.\f\207\n\211GSH\346=\203>\n\314\347O\350\n\312\"\211:\203\\\331\n:\325:878\313 &c\202g\351\352\n\"\210\353 \210\354\355!)\207" [wildcard-regexp full-directory-p file dir default-directory file-alist file-name-as-directory directory-files-and-attributes nil t string current-time 0 65 ls-lisp-delete-matching "^\\.\\.?$" 97 "^\\." ls-lisp-handle-switches 67 ls-lisp-column-format 7 134217727 floatp float ls-lisp-format "(No match)\n" format "total %.0f\n" fceiling 1024.0 82 string-match "\\`\\.\\.?\\'" expand-file-name "\n" ":\n" ls-lisp-insert-directory 47 -1 file-attributes message "%s: doesn't exist or is inaccessible" ding sit-for 2 now sum total-line files elt short file-size fil attr switches time-index x fattr] 8 (#$ . 6997)]) #@183 Insert the file names (only) in FILE-ALIST into the current buffer. Format in columns, sorted vertically, following GNU ls -C. Responds to the window width as ls should but may not! (defalias 'ls-lisp-column-format #[(file-alist) "\306\211\211\211\307\211\306\211\203> T\211@@)\211 BAG\211V\203\202* \237\310\\\311\312\"\313 \245 \245 \n _V\203_\nT\307\306\211\nW\205\234\211 W\203\210\311\f 8\"c\210\n\\\211\202p`\314\306x\210`|\210\315c\210T\211\202f.\207" [colwid nfiles collen ncols fmt files nil 0 2 format "%%-%ds" window-width " " 10 len file file-alist x j i] 7 (#$ . 8950)]) #@65 Delete all elements matching REGEXP from LIST, return new list. (defalias 'ls-lisp-delete-matching #[(regexp list) "\304 \203\305\n \211@@)\"\204 @B A\211\204)\207" [result list regexp x nil string-match] 4 (#$ . 9612)]) #@182 Return t if string S1 is less than string S2 in lexicographic order. Case is significant if `ls-lisp-ignore-case' is nil. Unibyte strings are converted to multibyte for comparison. (defalias 'ls-lisp-string-lessp #[(s1 s2) "\304\305\306 \305\306\n&\211\247\205 \305W)\207" [s1 s2 ls-lisp-ignore-case u compare-strings 0 nil] 9 (#$ . 9852)]) (put 'ls-lisp-string-lessp 'byte-optimizer 'byte-compile-inline-expand) #@119 Return new FILE-ALIST sorted according to SWITCHES. SWITCHES is a list of characters. Default sorting is alphabetic. (defalias 'ls-lisp-handle-switches #[(file-alist switches) "\306>\204 \307\310\311\217\210\312>\203\313\314 \"\n\203m\315\211\211 \203\\ @\211\211A@)\316=\204J \211A@);\203Q\317 \211A@)!\203Q \fB\202U B A\211\204$\306>\203h\f \244\202k \f\244+\306>?\320>?=\n=\203~ \237\207 \207" [switches file-alist ls-lisp-dirs-first files dirs el 85 err (byte-code "\303\304\305 !\306\n>\203\307\202'\310\n!\211\203\311\202'\312\n>\203&\313\202'\314\")\303\207" [index file-alist switches nil sort copy-sequence 83 #[(x y) "\302A8\302 A8W\207" [y x 7] 3] ls-lisp-time-index #[(x y) "\303 A8\nA8\"\207" [index y x ls-lisp-time-lessp] 4] 88 #[(x y) "\306@!\306 @!\307 \310\311\n\310\311\f&\211\247\205 \310W+\207" [x y s2 s1 ls-lisp-ignore-case u ls-lisp-extension compare-strings 0 nil] 9] #[(x y) "@ @\306 \307\310\n\307\310\f&\211\247\205 \307W+\207" [x y s2 s1 ls-lisp-ignore-case u compare-strings 0 nil] 9]] 4) ((error (byte-code "\301\302\303!\"\210\304 \210\305\306!\207" [err message "Unsorted (ls-lisp sorting error) - %s" error-message-string ding sit-for 2] 4))) 70 mapcar ls-lisp-classify nil t file-directory-p 114 x] 4 (#$ . 10277)]) #@439 Append a character to each file name indicating the file type. Also, for regular files that are executable, append `*'. The file type indicators are `/' for directories, `@' for symbolic links, `|' for FIFOs, `=' for sockets, and nothing for regular files. [But FIFOs and sockets are not recognized.] FILEDATA has the form (filename . `file-attributes'). Its `cadr' is t for directory, string (name linked to) for symbolic link, or nil. (defalias 'ls-lisp-classify #[(filedata) "@\211A@)\n\203! \n\304=\203\305\202\306PAB\2024\307\310\3118\"\2033 \312PAB\2024*\207" [filedata x type file-name t "/" "@" string-match "x" 9 "*"] 5 (#$ . 11599)]) #@127 Return extension of FILENAME (ignoring any version extension) FOLLOWED by null and full filename, SOLELY for full alpha sort. (defalias 'ls-lisp-extension #[(filename) "G\303 SH\304U\203\305\202` S\211\306Y\203# H\304U\203 \306W\203-\307\202` TH\310U\204> T\303O\202`  S\211\306Y\203Q H\304U\203@ \306W\203[\307\202` T\nO*\305Q\207" [filename i end nil 46 "" 0 "" 126] 3 (#$ . 12268)]) #@52 Return t if time TIME0 is earlier than time TIME1. (defalias 'ls-lisp-time-lessp #[(time0 time1) "@ @\211\nW\206 \nU\205\211A@) \211A@)W*\207" [time0 time1 hi1 hi0 x] 3 (#$ . 12690)]) #@186 Format one line of long ls output for file FILE-NAME. FILE-ATTR and FILE-SIZE give the file's attributes and size. SWITCHES, TIME-INDEX and NOW give the full switch list and time data. (defalias 'ls-lisp-format #[(file-name file-attr file-size switches time-index now) "@\3068\307 >\205\310\311\3128\"\313 >\205!\310\314\315\f\316\245!\" \317 >\205.\310\320A@\"\321 >\205I\3228\310;\203D\323\202E\324\")\325 >?\205q\326 >\204\\\327 >\205q\3308\310;\203l\323\202m\324\")\331\f\332 >\"\333\334\"##\333\335$\336\337#\n;\205\216\340\nP\341\260 *\207" [file-attr drwxrwxrwx file-type switches file-size ls-lisp-verbosity 8 105 format " %6d" 10 115 " %4.0f" fceiling 1024.0 links " %3d" uid 2 " %-8s" " %-8d" 71 103 gid 3 ls-lisp-format-file-size 104 " " ls-lisp-format-time propertize dired-filename t " -> " "\n" time-index now file-name] 14 (#$ . 12891)]) #@107 Return time index into file-attributes according to ls SWITCHES list. Return nil if no time switch found. (defalias 'ls-lisp-time-index #[(switches) "\301>\203\302\207\303>\203\304\207\305>\205\306\207" [switches 99 6 116 5 117 4] 2 (#$ . 13788)]) #@42 Convert TIME to a floating point number. (defalias 'ls-lisp-time-to-seconds #[(time) "@\302_\211A@)\\\3038\206\304\305\245\\\207" [time x 65536.0 2 0 1000000.0] 4 (#$ . 14051)]) #@248 Format time for file with attributes FILE-ATTR according to TIME-INDEX. Use the same method as ls to decide whether to show time-of-day or year, depending on distance between file date and NOW. All ls time options, namely c, t and u, are handled. (defalias 'ls-lisp-format-time #[(file-attr time-index now) "\206\306 8\307\n!\307 !Z\310\311\312\313\217+\207" [time-index file-attr time now diff past-cutoff 5 ls-lisp-time-to-seconds -15778476 nil (byte-code "\211\204\306\307\n@!\211\204\nA\211\204) \310\235\203!\311\312 \fX\203@\f\313X\203@ \203: \204:\314\202P@\202P \203L \204L\315\202PA@\")\207" [system-time-locale locale vars past-cutoff diff ls-lisp-use-localized-time-format ("LC_ALL" "LC_TIME" "LANG") getenv ("C" "POSIX") nil format-time-string 0 "%m-%d %H:%M" "%Y-%m-%d " ls-lisp-format-time-list time] 4) ((error "Unk 0 0000"))] 3 (#$ . 14242)]) (defalias 'ls-lisp-format-file-size #[(file-size human-readable) "\203\n \303W\203\304\305 !\203\306\202\307 \"\207 \310\245\311\312\313\314\315\316\257 \303W\2046 \317\245\nA\202&\304\320 \n@#*\207" [human-readable file-size post-fixes 1024 format floatp " %9.0f" " %9d" 1024.0 "k" "M" "G" "T" "P" "E" 1024.0 " %8.0f%s"] 7]) (provide 'ls-lisp)