annotate lisp/eshell/em-ls.el @ 110596:415e87a42437

mail-source.el (mail-source-value): Revert previous patch. gnus-picon.el: Inhibit showing picons for top level domains. gnus-art.el (gnus-article-treat-body-boundary): Fix length computing. gnus-news.texi: Mention nnimap-inbox. nnimap.el (nnimap-request-expire-articles): Compress ranges before deletion. nnimap.el (nnimap-retrieve-headers): Don't select the group, because that's already done by nnimap-possibly-change-group. gnus-html.el (gnus-html-show-images): Fix gnus-html-display-image arguments. gnus-html.el (gnus-html-wash-images): Fix spec computing to include start/end. nnimap.el: Store the IMAP greeting, so that we can tell what kind of server we're talking to. gnus.el (gnus): Give a final warning after startup. gnus-ems.el (gnus-create-image): Ignore all image-creation errors. nndraft.el (nndraft-request-expire-articles): Fetch the expiry target for the correct group. nnmh.el (nnmh-request-expire-articles): Don't try to fetch the expiry target here, because we don't know the Gnus name of the group. nnimap.el (nnimap-get-whole-article): Remove the data that may have arrived before the FETCH data. gnus-agent.el (gnus-agent-retrieve-headers): Don't propagate `fetch-old'. gnus-agent.el (gnus-agent-read-servers-validate): Change the level for the "Ignoring disappeared server" to something low. nndoc.el (nndoc-request-list): Return success always.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sun, 26 Sep 2010 23:01:31 +0000
parents f57f72bb4757
children 646142bd4c38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37661
diff changeset
1 ;;; em-ls.el --- implementation of ls in Lisp
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
95152
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104783
diff changeset
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
32526
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 32446
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 32446
diff changeset
7
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
94661
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94661
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; (at your option) any later version.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94661
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
87069
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
23 ;;; Commentary:
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
24
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
25 ;; Most of the command switches recognized by GNU's ls utility are
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
26 ;; supported ([(fileutils)ls invocation]).
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
87069
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
28 ;;; Code:
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
29
98564
f79ec7c34dc5 Sven Joachim <svenjoac at gmx.de>
Glenn Morris <rgm@gnu.org>
parents: 97484
diff changeset
30 (eval-when-compile
f79ec7c34dc5 Sven Joachim <svenjoac at gmx.de>
Glenn Morris <rgm@gnu.org>
parents: 97484
diff changeset
31 (require 'cl)
f79ec7c34dc5 Sven Joachim <svenjoac at gmx.de>
Glenn Morris <rgm@gnu.org>
parents: 97484
diff changeset
32 (require 'eshell))
87069
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
33 (require 'esh-util)
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
34 (require 'esh-opt)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35
95152
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
36 ;;;###autoload
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
37 (eshell-defgroup eshell-ls nil
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 "This module implements the \"ls\" utility fully in Lisp. If it is
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 passed any unrecognized command switches, it will revert to the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 operating system's version. This version of \"ls\" uses text
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 properties to colorize its output based on the setting of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 `eshell-ls-use-colors'."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 :tag "Implementation of `ls' in Lisp"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 :group 'eshell-module)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;;; User Variables:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 (defvar eshell-ls-orig-insert-directory
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (symbol-function 'insert-directory)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 "Preserve the original definition of `insert-directory'.")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 (defcustom eshell-ls-unload-hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (list
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 (function
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 (lambda ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 (fset 'insert-directory eshell-ls-orig-insert-directory))))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
57 "When unloading `eshell-ls', restore the definition of `insert-directory'."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 :type 'hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
61 (defcustom eshell-ls-initial-args nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
62 "If non-nil, this list of args is included before any call to `ls'.
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
63 This is useful for enabling human-readable format (-h), for example."
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
64 :type '(repeat :tag "Arguments" string)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
65 :group 'eshell-ls)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
66
39984
5e4848f89017 (eshell-ls-dired-initial-args): Added an extra customization variable,
John Wiegley <johnw@newartisans.com>
parents: 38414
diff changeset
67 (defcustom eshell-ls-dired-initial-args nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
68 "If non-nil, args is included before any call to `ls' in Dired.
39984
5e4848f89017 (eshell-ls-dired-initial-args): Added an extra customization variable,
John Wiegley <johnw@newartisans.com>
parents: 38414
diff changeset
69 This is useful for enabling human-readable format (-h), for example."
5e4848f89017 (eshell-ls-dired-initial-args): Added an extra customization variable,
John Wiegley <johnw@newartisans.com>
parents: 38414
diff changeset
70 :type '(repeat :tag "Arguments" string)
5e4848f89017 (eshell-ls-dired-initial-args): Added an extra customization variable,
John Wiegley <johnw@newartisans.com>
parents: 38414
diff changeset
71 :group 'eshell-ls)
5e4848f89017 (eshell-ls-dired-initial-args): Added an extra customization variable,
John Wiegley <johnw@newartisans.com>
parents: 38414
diff changeset
72
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 (defcustom eshell-ls-use-in-dired nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
74 "If non-nil, use `eshell-ls' to read directories in Dired."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 :set (lambda (symbol value)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (if value
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (unless (and (boundp 'eshell-ls-use-in-dired)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 eshell-ls-use-in-dired)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 (fset 'insert-directory 'eshell-ls-insert-directory))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (when (and (boundp 'eshell-ls-insert-directory)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 eshell-ls-use-in-dired)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (fset 'insert-directory eshell-ls-orig-insert-directory)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 (setq eshell-ls-use-in-dired value))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :type 'boolean
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 :require 'em-ls
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (defcustom eshell-ls-default-blocksize 1024
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
89 "The default blocksize to use when display file sizes with -s."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 :type 'integer
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
93 (defcustom eshell-ls-exclude-regexp nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
94 "Unless -a is specified, files matching this regexp will not be shown."
35718
96d933eb13f4 (eshell-ls-exclude-regexp): Fix :type.
Dave Love <fx@gnu.org>
parents: 33020
diff changeset
95 :type '(choice regexp (const nil))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
98 (defcustom eshell-ls-exclude-hidden t
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
99 "Unless -a is specified, files beginning with . will not be shown.
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
100 Using this boolean, instead of `eshell-ls-exclude-regexp', is both
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
101 faster and conserves more memory."
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
102 :type 'boolean
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
103 :group 'eshell-ls)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
104
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (defcustom eshell-ls-use-colors t
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
106 "If non-nil, use colors in file listings."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 :type 'boolean
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
110 (defface eshell-ls-directory
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
111 '((((class color) (background light)) (:foreground "Blue" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
112 (((class color) (background dark)) (:foreground "SkyBlue" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
113 (t (:weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
114 "The face used for highlight directories."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
116 (define-obsolete-face-alias 'eshell-ls-directory-face
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
117 'eshell-ls-directory "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
119 (defface eshell-ls-symlink
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
120 '((((class color) (background light)) (:foreground "Dark Cyan" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
121 (((class color) (background dark)) (:foreground "Cyan" :weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
122 "The face used for highlight symbolic links."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
124 (define-obsolete-face-alias 'eshell-ls-symlink-face 'eshell-ls-symlink "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
126 (defface eshell-ls-executable
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
127 '((((class color) (background light)) (:foreground "ForestGreen" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
128 (((class color) (background dark)) (:foreground "Green" :weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
129 "The face used for highlighting executables (not directories, though)."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
131 (define-obsolete-face-alias 'eshell-ls-executable-face
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
132 'eshell-ls-executable "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
134 (defface eshell-ls-readonly
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 '((((class color) (background light)) (:foreground "Brown"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (((class color) (background dark)) (:foreground "Pink")))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
137 "The face used for highlighting read-only files."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
139 (define-obsolete-face-alias 'eshell-ls-readonly-face 'eshell-ls-readonly "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
141 (defface eshell-ls-unreadable
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 '((((class color) (background light)) (:foreground "Grey30"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (((class color) (background dark)) (:foreground "DarkGrey")))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
144 "The face used for highlighting unreadable files."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
146 (define-obsolete-face-alias 'eshell-ls-unreadable-face
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
147 'eshell-ls-unreadable "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
149 (defface eshell-ls-special
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
150 '((((class color) (background light)) (:foreground "Magenta" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
151 (((class color) (background dark)) (:foreground "Magenta" :weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
152 "The face used for highlighting non-regular files."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
154 (define-obsolete-face-alias 'eshell-ls-special-face 'eshell-ls-special "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
156 (defface eshell-ls-missing
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
157 '((((class color) (background light)) (:foreground "Red" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
158 (((class color) (background dark)) (:foreground "Red" :weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
159 "The face used for highlighting non-existent file names."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
161 (define-obsolete-face-alias 'eshell-ls-missing-face 'eshell-ls-missing "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (defcustom eshell-ls-archive-regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (concat "\\.\\(t\\(a[rz]\\|gz\\)\\|arj\\|lzh\\|"
110579
5fabe7db5188 Add more xz compression support.
Glenn Morris <rgm@gnu.org>
parents: 107115
diff changeset
165 "zip\\|[zZ]\\|gz\\|bz2\\|xz\\|deb\\|rpm\\)\\'")
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
166 "A regular expression that matches names of file archives.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 This typically includes both traditional archives and compressed
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 files."
110579
5fabe7db5188 Add more xz compression support.
Glenn Morris <rgm@gnu.org>
parents: 107115
diff changeset
169 :version "24.1" ; added xz
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 :type 'regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
173 (defface eshell-ls-archive
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
174 '((((class color) (background light)) (:foreground "Orchid" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
175 (((class color) (background dark)) (:foreground "Orchid" :weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
176 "The face used for highlighting archived and compressed file names."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
178 (define-obsolete-face-alias 'eshell-ls-archive-face 'eshell-ls-archive "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (defcustom eshell-ls-backup-regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 "\\(\\`\\.?#\\|\\(\\.bak\\|~\\)\\'\\)"
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
182 "A regular expression that matches names of backup files."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 :type 'regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
186 (defface eshell-ls-backup
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 '((((class color) (background light)) (:foreground "OrangeRed"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (((class color) (background dark)) (:foreground "LightSalmon")))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
189 "The face used for highlighting backup file names."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
191 (define-obsolete-face-alias 'eshell-ls-backup-face 'eshell-ls-backup "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (defcustom eshell-ls-product-regexp
48704
18ebc473a07d (eshell-ls-product-regexp): Fix typo.
Andreas Schwab <schwab@suse.de>
parents: 46853
diff changeset
194 "\\.\\(elc\\|o\\(bj\\)?\\|a\\|lib\\|res\\)\\'"
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
195 "A regular expression that matches names of product files.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 Products are files that get generated from a source file, and hence
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 ought to be recreatable if they are deleted."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 :type 'regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
201 (defface eshell-ls-product
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 '((((class color) (background light)) (:foreground "OrangeRed"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (((class color) (background dark)) (:foreground "LightSalmon")))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
204 "The face used for highlighting files that are build products."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
206 (define-obsolete-face-alias 'eshell-ls-product-face 'eshell-ls-product "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (defcustom eshell-ls-clutter-regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 "\\(^texput\\.log\\|^core\\)\\'"
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
210 "A regular expression that matches names of junk files.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 These are mainly files that get created for various reasons, but don't
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 really need to stick around for very long."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 :type 'regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
216 (defface eshell-ls-clutter
42456
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
217 '((((class color) (background light)) (:foreground "OrangeRed" :weight bold))
8a4077ab418c (various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents: 39984
diff changeset
218 (((class color) (background dark)) (:foreground "OrangeRed" :weight bold)))
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
219 "The face used for highlighting junk file names."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 :group 'eshell-ls)
104783
ddf360111014 Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents: 102678
diff changeset
221 (define-obsolete-face-alias 'eshell-ls-clutter-face 'eshell-ls-clutter "22.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (defsubst eshell-ls-filetype-p (attrs type)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 "Test whether ATTRS specifies a directory."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (if (nth 8 attrs)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (eq (aref (nth 8 attrs) 0) type)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (defmacro eshell-ls-applicable (attrs index func file)
107115
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
229 "Test whether, for ATTRS, the user can do what corresponds to INDEX.
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
230 ATTRS is a string of file modes. See `file-attributes'.
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
231 If we cannot determine the answer using ATTRS (e.g., if we need
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
232 to know what group the user is in), compute the return value by
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
233 calling FUNC with FILE as an argument."
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
234 `(let ((owner (nth 2 ,attrs))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
235 (modes (nth 8 ,attrs)))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
236 (cond ((cond ((numberp owner)
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
237 (= owner (user-uid)))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
238 ((stringp owner)
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
239 (or (string-equal owner (user-login-name))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
240 (member owner (eshell-current-ange-uids)))))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
241 ;; The user owns this file.
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
242 (not (eq (aref modes ,index) ?-)))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
243 ((eq (aref modes (+ ,index 3))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
244 (aref modes (+ ,index 6)))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
245 ;; If the "group" and "other" fields give identical
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
246 ;; results, use that.
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
247 (not (eq (aref modes (+ ,index 3)) ?-)))
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
248 (t
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
249 ;; Otherwise call FUNC.
4f195898e986 * eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Chong Yidong <cyd@stupidchicken.com>
parents: 107103
diff changeset
250 (,(eval func) ,file)))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (defcustom eshell-ls-highlight-alist nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 110579
diff changeset
253 "This alist correlates test functions to color.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 The format of the members of this alist is
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (TEST-SEXP . FACE)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 If TEST-SEXP evals to non-nil, that face will be used to highlight the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 name of the file. The first match wins. `file' and `attrs' are in
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 scope during the evaluation of TEST-SEXP."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 :type '(repeat (cons function face))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 :group 'eshell-ls)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 ;;; Functions:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (defun eshell-ls-insert-directory
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (file switches &optional wildcard full-directory-p)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 "Insert directory listing for FILE, formatted according to SWITCHES.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 Leaves point after the inserted text.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 SWITCHES may be a string of options, or a list of strings.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 Optional third arg WILDCARD means treat FILE as shell wildcard.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 Optional fourth arg FULL-DIRECTORY-P means file is a directory and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 switches do not contain `d', so that a full listing is expected.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 This version of the function uses `eshell/ls'. If any of the switches
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 passed are not recognized, the operating system's version will be used
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 instead."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (let ((handler (find-file-name-handler file 'insert-directory)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (if handler
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 (funcall handler 'insert-directory file switches
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 wildcard full-directory-p)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (if (stringp switches)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (setq switches (split-string switches)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (let (eshell-current-handles
66589
8c8902a666bf (eshell-do-ls): Added no-op support for --dired flag, to prevent
John Wiegley <johnw@newartisans.com>
parents: 64701
diff changeset
285 eshell-current-subjob-p
8c8902a666bf (eshell-do-ls): Added no-op support for --dired flag, to prevent
John Wiegley <johnw@newartisans.com>
parents: 64701
diff changeset
286 font-lock-mode)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 ;; use the fancy highlighting in `eshell-ls' rather than font-lock
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (when (and eshell-ls-use-colors
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (featurep 'font-lock))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (font-lock-mode -1)
37326
19d97e9f6689 (eshell-ls-insert-directory): Set font-lock-defaults to nil, to
John Wiegley <johnw@newartisans.com>
parents: 35718
diff changeset
291 (setq font-lock-defaults nil)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (if (boundp 'font-lock-buffers)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (set 'font-lock-buffers
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (delq (current-buffer)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (symbol-value 'font-lock-buffers)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (let ((insert-func 'insert)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (error-func 'insert)
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
298 (flush-func 'ignore)
39984
5e4848f89017 (eshell-ls-dired-initial-args): Added an extra customization variable,
John Wiegley <johnw@newartisans.com>
parents: 38414
diff changeset
299 eshell-ls-dired-initial-args)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (eshell-do-ls (append switches (list file))))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (defsubst eshell/ls (&rest args)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 "An alias version of `eshell-do-ls'."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (let ((insert-func 'eshell-buffered-print)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (error-func 'eshell-error)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (flush-func 'eshell-flush))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (eshell-do-ls args)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
37661
6d7c89c79996 Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents: 37326
diff changeset
309 (put 'eshell/ls 'eshell-no-numeric-conversions t)
6d7c89c79996 Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents: 37326
diff changeset
310
95619
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
311 (defvar block-size)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
312 (defvar dereference-links)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
313 (defvar dir-literal)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
314 (defvar error-func)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
315 (defvar flush-func)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
316 (defvar human-readable)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
317 (defvar ignore-pattern)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
318 (defvar insert-func)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
319 (defvar listing-style)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
320 (defvar numeric-uid-gid)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
321 (defvar reverse-list)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
322 (defvar show-all)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
323 (defvar show-recursive)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
324 (defvar show-size)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
325 (defvar sort-method)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
326 (defvar ange-cache)
45dbb3c749a6 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 95152
diff changeset
327 (defvar dired-flag)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (defun eshell-do-ls (&rest args)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 "Implementation of \"ls\" in Lisp, passing ARGS."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (funcall flush-func -1)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 ;; process the command arguments, and begin listing files
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (eshell-eval-using-options
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
334 "ls" (if eshell-ls-initial-args
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
335 (list eshell-ls-initial-args args)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
336 args)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
337 `((?a "all" nil show-all
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
338 "show all files in directory")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (?c nil by-ctime sort-method
66589
8c8902a666bf (eshell-do-ls): Added no-op support for --dired flag, to prevent
John Wiegley <johnw@newartisans.com>
parents: 64701
diff changeset
340 "sort by last status change time")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (?d "directory" nil dir-literal
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 "list directory entries instead of contents")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (?k "kilobytes" 1024 block-size
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
344 "using 1024 as the block size")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (?h "human-readable" 1024 human-readable
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 "print sizes in human readable format")
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
347 (?H "si" 1000 human-readable
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
348 "likewise, but use powers of 1000 not 1024")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (?I "ignore" t ignore-pattern
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 "do not list implied entries matching pattern")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (?l nil long-listing listing-style
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 "use a long listing format")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (?n "numeric-uid-gid" nil numeric-uid-gid
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 "list numeric UIDs and GIDs instead of names")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (?r "reverse" nil reverse-list
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 "reverse order while sorting")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (?s "size" nil show-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 "print size of each file, in blocks")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (?t nil by-mtime sort-method
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 "sort by modification time")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (?u nil by-atime sort-method
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 "sort by last access time")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (?x nil by-lines listing-style
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 "list entries by lines instead of by columns")
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
365 (?C nil by-columns listing-style
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
366 "list entries by columns")
102678
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
367 (?L "dereference" nil dereference-links
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
368 "list entries pointed to by symbolic links")
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
369 (?R "recursive" nil show-recursive
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
370 "list subdirectories recursively")
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
371 (?S nil by-size sort-method
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
372 "sort by file size")
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
373 (?U nil unsorted sort-method
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
374 "do not sort; list entries in directory order")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (?X nil by-extension sort-method
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 "sort alphabetically by entry extension")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (?1 nil single-column listing-style
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 "list one file per line")
66589
8c8902a666bf (eshell-do-ls): Added no-op support for --dired flag, to prevent
John Wiegley <johnw@newartisans.com>
parents: 64701
diff changeset
379 (nil "dired" nil dired-flag
8c8902a666bf (eshell-do-ls): Added no-op support for --dired flag, to prevent
John Wiegley <johnw@newartisans.com>
parents: 64701
diff changeset
380 "Here for compatibility with GNU ls.")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (nil "help" nil nil
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
382 "show this usage display")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 :external "ls"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 :usage "[OPTION]... [FILE]...
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 List information about the FILEs (the current directory by default).
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
386 Sort entries alphabetically across.")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 ;; setup some defaults, based on what the user selected
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (unless block-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (setq block-size eshell-ls-default-blocksize))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (unless listing-style
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (setq listing-style 'by-columns))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (unless args
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (setq args (list ".")))
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
394 (let ((eshell-ls-exclude-regexp eshell-ls-exclude-regexp) ange-cache)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
395 (when ignore-pattern
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (unless (eshell-using-module 'eshell-glob)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (error (concat "-I option requires that `eshell-glob'"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 " be a member of `eshell-modules-list'")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (set-text-properties 0 (length ignore-pattern) nil ignore-pattern)
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
400 (setq eshell-ls-exclude-regexp
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
401 (if eshell-ls-exclude-regexp
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (concat "\\(" eshell-ls-exclude-regexp "\\|"
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
403 (eshell-glob-regexp ignore-pattern) "\\)")
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
404 (eshell-glob-regexp ignore-pattern))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 ;; list the files!
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (eshell-ls-entries
107103
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
407 (mapcar (lambda (arg)
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
408 (cons (if (and (eshell-under-windows-p)
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
409 (file-name-absolute-p arg))
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
410 (expand-file-name arg)
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
411 arg)
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
412 (eshell-file-attributes
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
413 arg (if numeric-uid-gid 'integer 'string))))
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
414 args)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 t (expand-file-name default-directory)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (funcall flush-func)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (defsubst eshell-ls-printable-size (filesize &optional by-blocksize)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 "Return a printable FILESIZE."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (eshell-printable-size filesize human-readable
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (and by-blocksize block-size)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 eshell-ls-use-colors))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (defsubst eshell-ls-size-string (attrs size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 "Return the size string for ATTRS length, using SIZE-WIDTH."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (let* ((str (eshell-ls-printable-size (nth 7 attrs) t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (len (length str)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (if (< len size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (concat (make-string (- size-width len) ? ) str)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 str)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (defun eshell-ls-annotate (fileinfo)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 "Given a FILEINFO object, return a resolved, decorated FILEINFO.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 This means resolving any symbolic links, determining what face the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 name should be displayed as, etc. Think of it as cooking a FILEINFO."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (if (not (and (stringp (cadr fileinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (or dereference-links
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (eq listing-style 'long-listing))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (setcar fileinfo (eshell-ls-decorated-name fileinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (let (dir attr)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (unless (file-name-absolute-p (cadr fileinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (setq dir (file-truename
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (file-name-directory
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (expand-file-name (car fileinfo))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (setq attr
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
446 (eshell-file-attributes
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (let ((target (if dir
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (expand-file-name (cadr fileinfo) dir)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (cadr fileinfo))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (if dereference-links
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (file-truename target)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 target))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (if (or dereference-links
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (string-match "^\\.\\.?$" (car fileinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (progn
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (setcdr fileinfo attr)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (setcar fileinfo (eshell-ls-decorated-name fileinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (assert (eq listing-style 'long-listing))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (setcar fileinfo
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (concat (eshell-ls-decorated-name fileinfo) " -> "
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (eshell-ls-decorated-name
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (cons (cadr fileinfo) attr)))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 fileinfo)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (defun eshell-ls-file (fileinfo &optional size-width copy-fileinfo)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 "Output FILE in long format.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 FILE may be a string, or a cons cell whose car is the filename and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 whose cdr is the list of file attributes."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (if (not (cdr fileinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (funcall error-func (format "%s: No such file or directory\n"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (car fileinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (setq fileinfo
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (eshell-ls-annotate (if copy-fileinfo
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (cons (car fileinfo)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (cdr fileinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 fileinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (let ((file (car fileinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (attrs (cdr fileinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (if (not (eq listing-style 'long-listing))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (if show-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (funcall insert-func (eshell-ls-size-string attrs size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 " " file "\n")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (funcall insert-func file "\n"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (let ((line
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (concat
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (if show-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (concat (eshell-ls-size-string attrs size-width) " "))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (format
102678
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
489 (if numeric-uid-gid
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
490 "%s%4d %-8s %-8s "
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
491 "%s%4d %-14s %-8s ")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (or (nth 8 attrs) "??????????")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (or (nth 1 attrs) 0)
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
494 (or (let ((user (nth 2 attrs)))
102678
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
495 (and (stringp user)
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
496 (eshell-substring user 14)))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (nth 2 attrs)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 "")
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
499 (or (let ((group (nth 3 attrs)))
102678
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
500 (and (stringp group)
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
501 (eshell-substring group 8)))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (nth 3 attrs)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 ""))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (let* ((str (eshell-ls-printable-size (nth 7 attrs)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (len (length str)))
102675
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
506 ;; Let file sizes shorter than 9 align neatly.
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
507 (if (< len (or size-width 8))
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
508 (concat (make-string (- (or size-width 8) len) ? ) str)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 str))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 " " (format-time-string
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
511 (concat
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
512 "%b %e "
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
513 (if (= (nth 5 (decode-time (current-time)))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
514 (nth 5 (decode-time
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
515 (nth (cond
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
516 ((eq sort-method 'by-atime) 4)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
517 ((eq sort-method 'by-ctime) 6)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
518 (t 5)) attrs))))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
519 "%H:%M"
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
520 " %Y")) (nth (cond
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
521 ((eq sort-method 'by-atime) 4)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
522 ((eq sort-method 'by-ctime) 6)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
523 (t 5)) attrs)) " ")))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (funcall insert-func line file "\n"))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (defun eshell-ls-dir (dirinfo &optional insert-name root-dir size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 "Output the entries in DIRINFO.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 If INSERT-NAME is non-nil, the name of DIRINFO will be output. If
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 ROOT-DIR is also non-nil, and a directory name, DIRINFO will be output
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 relative to that directory."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (let ((dir (car dirinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (if (not (cdr dirinfo))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (funcall error-func (format "%s: No such file or directory\n" dir))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (if dir-literal
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (eshell-ls-file dirinfo size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (if insert-name
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (funcall insert-func
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (eshell-ls-decorated-name
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (cons (concat
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (if root-dir
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (file-relative-name dir root-dir)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (expand-file-name dir)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (cdr dirinfo))) ":\n"))
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
544 (let ((entries (eshell-directory-files-and-attributes
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
545 dir nil (and (not show-all)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
546 eshell-ls-exclude-hidden
102678
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
547 "\\`[^.]") t
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
548 ;; Asking for UID and GID as
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
549 ;; strings saves another syscall
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
550 ;; later when we are going to
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
551 ;; display user and group names.
985635bb2d2c (eshell-ls-dir): Call eshell-directory-files-and-attributes with additional
Eli Zaretskii <eliz@gnu.org>
parents: 102675
diff changeset
552 (if numeric-uid-gid 'integer 'string))))
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
553 (when (and (not show-all) eshell-ls-exclude-regexp)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
554 (while (and entries (string-match eshell-ls-exclude-regexp
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
555 (caar entries)))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (setq entries (cdr entries)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (let ((e entries))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (while (cdr e)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (if (string-match eshell-ls-exclude-regexp (car (cadr e)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (setcdr e (cddr e))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (setq e (cdr e))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (when (or (eq listing-style 'long-listing) show-size)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 (let ((total 0.0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 (setq size-width 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (eshell-for e entries
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 (if (nth 7 (cdr e))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (setq total (+ total (nth 7 (cdr e)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 size-width
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (max size-width
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 (length (eshell-ls-printable-size
102675
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
571 (nth 7 (cdr e))
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
572 (not
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
573 ;; If we are under -l, count length
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
574 ;; of sizes in bytes, not in blocks.
c919d46e66e4 (eshell-ls-file): Enlarge default size-width to 8.
Eli Zaretskii <eliz@gnu.org>
parents: 100908
diff changeset
575 (eq listing-style 'long-listing))))))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (funcall insert-func "total "
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (eshell-ls-printable-size total t) "\n")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (let ((default-directory (expand-file-name dir)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (if show-recursive
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (eshell-ls-entries
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (let ((e entries) (good-entries (list t)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (while e
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (unless (let ((len (length (caar e))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (and (eq (aref (caar e) 0) ?.)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (or (= len 1)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (and (= len 2)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 (eq (aref (caar e) 1) ?.)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (nconc good-entries (list (car e))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 (setq e (cdr e)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (cdr good-entries))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 nil root-dir)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (eshell-ls-files (eshell-ls-sort-entries entries)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 size-width))))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (defsubst eshell-ls-compare-entries (l r inx func)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 "Compare the time of two files, L and R, the attribute indexed by INX."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 (let ((lt (nth inx (cdr l)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (rt (nth inx (cdr r))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 (if (equal lt rt)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (string-lessp (directory-file-name (car l))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 (directory-file-name (car r)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (funcall func rt lt))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 (defun eshell-ls-sort-entries (entries)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 "Sort the given ENTRIES, which may be files, directories or both.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 In Eshell's implementation of ls, ENTRIES is always reversed."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 (if (eq sort-method 'unsorted)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 (nreverse entries)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 (sort entries
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 (function
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 (lambda (l r)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 (let ((result
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 (cond
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 ((eq sort-method 'by-atime)
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
615 (eshell-ls-compare-entries l r 4 'eshell-time-less-p))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 ((eq sort-method 'by-mtime)
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
617 (eshell-ls-compare-entries l r 5 'eshell-time-less-p))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 ((eq sort-method 'by-ctime)
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
619 (eshell-ls-compare-entries l r 6 'eshell-time-less-p))
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
620 ((eq sort-method 'by-size)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
621 (eshell-ls-compare-entries l r 7 '<))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 ((eq sort-method 'by-extension)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 (let ((lx (file-name-extension
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 (directory-file-name (car l))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 (rx (file-name-extension
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 (directory-file-name (car r)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 (cond
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 ((or (and (not lx) (not rx))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 (equal lx rx))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 (string-lessp (directory-file-name (car l))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 (directory-file-name (car r))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 ((not lx) t)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 ((not rx) nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 (t
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 (string-lessp lx rx)))))
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
636 (t
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 (string-lessp (directory-file-name (car l))
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
638 (directory-file-name (car r)))))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 (if reverse-list
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 (not result)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 result)))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 (defun eshell-ls-files (files &optional size-width copy-fileinfo)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 "Output a list of FILES.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 Each member of FILES is either a string or a cons cell of the form
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 \(FILE . ATTRS)."
97484
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
647 ;; Mimic behavior of coreutils ls, which lists a single file per
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
648 ;; line when output is not a tty. Exceptions: if -x was supplied,
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
649 ;; or if we are the _last_ command in a pipeline.
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
650 ;; FIXME Not really the same since not testing output destination.
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
651 (if (or (and eshell-in-pipeline-p
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
652 (not (eq eshell-in-pipeline-p 'last))
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
653 (not (eq listing-style 'by-lines)))
ed4b73533ff6 (eshell-ls-files): List one per line in a pipeline, unless at the end
Glenn Morris <rgm@gnu.org>
parents: 95619
diff changeset
654 (memq listing-style '(long-listing single-column)))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 (eshell-for file files
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 (if file
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 (eshell-ls-file file size-width copy-fileinfo)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 (let ((f files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 last-f
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 display-files
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 ignore)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 (while f
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 (if (cdar f)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 (setq last-f f
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 f (cdr f))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 (unless ignore
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 (funcall error-func
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 (format "%s: No such file or directory\n" (caar f))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 (if (eq f files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 (setq files (cdr files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 f files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 (if (not (cdr f))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 (progn
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 (setcdr last-f nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 (setq f nil))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 (setcar f (cadr f))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 (setcdr f (cddr f))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 (if (not show-size)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 (setq display-files (mapcar 'eshell-ls-annotate files))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 (eshell-for file files
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 (let* ((str (eshell-ls-printable-size (nth 7 (cdr file)) t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 (len (length str)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 (if (< len size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 (setq str (concat (make-string (- size-width len) ? ) str)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 (setq file (eshell-ls-annotate file)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 display-files (cons (cons (concat str " " (car file))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 (cdr file))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 display-files))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 (setq display-files (nreverse display-files)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 (let* ((col-vals
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 (if (eq listing-style 'by-columns)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 (eshell-ls-find-column-lengths display-files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 (assert (eq listing-style 'by-lines))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 (eshell-ls-find-column-widths display-files)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 (col-widths (car col-vals))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 (display-files (cdr col-vals))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 (columns (length col-widths))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 (col-index 1)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 need-return)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 (eshell-for file display-files
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 (let ((name
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 (if (car file)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 (if show-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 (concat (substring (car file) 0 size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 (eshell-ls-decorated-name
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 (cons (substring (car file) size-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 (cdr file))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 (eshell-ls-decorated-name file))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 "")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 (if (< col-index columns)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 (setq need-return
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (concat need-return name
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (make-string
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (max 0 (- (aref col-widths
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 (1- col-index))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 (length name))) ? ))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 col-index (1+ col-index))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 (funcall insert-func need-return name "\n")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (setq col-index 1 need-return nil))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 (if need-return
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 (funcall insert-func need-return "\n"))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 (defun eshell-ls-entries (entries &optional separate root-dir)
107103
f2353518b994 Fix to uid/gid format in eshell's ls (Bug#5528).
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
724 "Output PATH's directory ENTRIES.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 Each member of ENTRIES may either be a string or a cons cell, the car
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 of which is the file name, and the cdr of which is the list of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 attributes.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 If SEPARATE is non-nil, directories name will be entirely separated
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 from the filenames. This is the normal behavior, except when doing a
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 recursive listing.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 ROOT-DIR, if non-nil, specifies the root directory of the listing, to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 which non-absolute directory names will be made relative if ever they
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 need to be printed."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 (let (dirs files show-names need-return (size-width 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (eshell-for entry entries
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (if (and (not dir-literal)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 (or (eshell-ls-filetype-p (cdr entry) ?d)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 (and (eshell-ls-filetype-p (cdr entry) ?l)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 (file-directory-p (car entry)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 (progn
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 (unless separate
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 (setq files (cons entry files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 size-width
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 (if show-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 (max size-width
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 (length (eshell-ls-printable-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 (nth 7 (cdr entry)) t))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 (setq dirs (cons entry dirs)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 (setq files (cons entry files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 size-width
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 (if show-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 (max size-width
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 (length (eshell-ls-printable-size
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 (nth 7 (cdr entry)) t)))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 (when files
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 (eshell-ls-files (eshell-ls-sort-entries files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 size-width show-recursive)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 (setq need-return t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 (setq show-names (or show-recursive
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 (> (+ (length files) (length dirs)) 1)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 (eshell-for dir (eshell-ls-sort-entries dirs)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 (if (and need-return (not dir-literal))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 (funcall insert-func "\n"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 (eshell-ls-dir dir show-names
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
765 (unless (file-name-absolute-p (car dir)) root-dir)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
766 size-width)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 (setq need-return t))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 (defun eshell-ls-find-column-widths (files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 "Find the best fitting column widths for FILES.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 It will be returned as a vector, whose length is the number of columns
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 to use, and each member of which is the width of that column
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773 \(including spacing)."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774 (let* ((numcols 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 (width 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 (widths
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 (mapcar
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 (function
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 (lambda (file)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780 (+ 2 (length (car file)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 files))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782 ;; must account for the added space...
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 (max-width (+ (window-width) 2))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 (best-width 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 col-widths)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787 ;; determine the largest number of columns in the first row
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788 (let ((w widths))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 (while (and w (< width max-width))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790 (setq width (+ width (car w))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791 numcols (1+ numcols)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792 w (cdr w))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794 ;; refine it based on the following rows
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795 (while (> numcols 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796 (let ((i 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 (colw (make-vector numcols 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 (w widths))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 (while w
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
800 (if (= i numcols)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
801 (setq i 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
802 (aset colw i (max (aref colw i) (car w)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
803 (setq w (cdr w) i (1+ i)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
804 (setq i 0 width 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
805 (while (< i numcols)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806 (setq width (+ width (aref colw i))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807 i (1+ i)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808 (if (and (< width max-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
809 (> width best-width))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 (setq col-widths colw
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811 best-width width)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
812 (setq numcols (1- numcols)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
813
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814 (cons (or col-widths (vector max-width)) files)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816 (defun eshell-ls-find-column-lengths (files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817 "Find the best fitting column lengths for FILES.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
818 It will be returned as a vector, whose length is the number of columns
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 to use, and each member of which is the width of that column
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820 \(including spacing)."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 (let* ((numcols 1)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
822 (width 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
823 (widths
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
824 (mapcar
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825 (function
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
826 (lambda (file)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 (+ 2 (length (car file)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828 files))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 (max-width (+ (window-width) 2))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830 col-widths
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 colw)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833 ;; refine it based on the following rows
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 (while numcols
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 (let* ((rows (ceiling (/ (length widths)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836 (float numcols))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (w widths)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 (len (* rows numcols))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 (index 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 (i 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 (setq width 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 (unless (or (= rows 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
843 (<= (/ (length widths) (float rows))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 (float (1- numcols))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845 (setq colw (make-vector numcols 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 (while (> len 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 (if (= i numcols)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 (setq i 0 index (1+ index)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 (aset colw i
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 (max (aref colw i)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 (or (nth (+ (* i rows) index) w) 0)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 (setq len (1- len) i (1+ i)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 (setq i 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 (while (< i numcols)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 (setq width (+ width (aref colw i))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 i (1+ i))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 (if (>= width max-width)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 (setq numcols nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 (if colw
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 (setq col-widths colw))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 (if (>= numcols (length widths))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 (setq numcols nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 (setq numcols (1+ numcols))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 (if (not col-widths)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 (cons (vector max-width) files)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867 (setq numcols (length col-widths))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 (let* ((rows (ceiling (/ (length widths)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 (float numcols))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 (len (* rows numcols))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 (newfiles (make-list len nil))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 (index 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 (i 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (j 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 (while (< j len)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (if (= i numcols)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 (setq i 0 index (1+ index)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 (setcar (nthcdr j newfiles)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 (nth (+ (* i rows) index) files))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 (setq j (1+ j) i (1+ i)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 (cons col-widths newfiles)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 (defun eshell-ls-decorated-name (file)
64560
8e6e95602853 (eshell-ls-decorated-name): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
884 "Return FILE, possibly decorated."
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
885 (if eshell-ls-use-colors
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
886 (let ((face
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
887 (cond
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
888 ((not (cdr file))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
889 'eshell-ls-missing)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
890
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
891 ((stringp (cadr file))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
892 'eshell-ls-symlink)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
893
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
894 ((eq (cadr file) t)
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
895 'eshell-ls-directory)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
897 ((not (eshell-ls-filetype-p (cdr file) ?-))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
898 'eshell-ls-special)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
900 ((and (/= (user-uid) 0) ; root can execute anything
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
901 (eshell-ls-applicable (cdr file) 3
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
902 'file-executable-p (car file)))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
903 'eshell-ls-executable)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
904
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
905 ((not (eshell-ls-applicable (cdr file) 1
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
906 'file-readable-p (car file)))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
907 'eshell-ls-unreadable)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
909 ((string-match eshell-ls-archive-regexp (car file))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
910 'eshell-ls-archive)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
911
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
912 ((string-match eshell-ls-backup-regexp (car file))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
913 'eshell-ls-backup)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
914
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
915 ((string-match eshell-ls-product-regexp (car file))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
916 'eshell-ls-product)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
917
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
918 ((string-match eshell-ls-clutter-regexp (car file))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
919 'eshell-ls-clutter)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
921 ((not (eshell-ls-applicable (cdr file) 2
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
922 'file-writable-p (car file)))
63533
b7ea6515f1ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents: 53080
diff changeset
923 'eshell-ls-readonly)
46853
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
924 (eshell-ls-highlight-alist
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
925 (let ((tests eshell-ls-highlight-alist)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
926 value)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
927 (while tests
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
928 (if (funcall (caar tests) (car file) (cdr file))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
929 (setq value (cdar tests) tests nil)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
930 (setq tests (cdr tests))))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
931 value)))))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
932 (if face
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
933 (add-text-properties 0 (length (car file))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
934 (list 'face face)
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
935 (car file)))))
cb339473da3b I did not mean to check in these changes yet, they are still
John Wiegley <johnw@newartisans.com>
parents: 46852
diff changeset
936 (car file))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
937
87069
592ff64540d2 Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
938 (provide 'em-ls)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
939
95152
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
940 ;; Local Variables:
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
941 ;; generated-autoload-file: "esh-groups.el"
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
942 ;; End:
ad5d26b1d5d1 Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents: 94661
diff changeset
943
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
944 ;; arch-tag: 9295181c-0cb2-499c-999b-89f5359842cb
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
945 ;;; em-ls.el ends here