annotate lisp/eshell/esh-util.el @ 71614:07e63b17c925

(symbol-at-point): Don't use `form-at-point' which fails if the symbol contains chars like ( or '. (bounds-of-thing-at-point): Remove unused vars `end' and `beg'. (thing-at-point-bounds-of-url-at-point): Remove unused vars `url' and `short'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 04 Jul 2006 20:27:49 +0000
parents 067115a6e738
children 7a3f13e2dd57 c5406394f567
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: 37664
diff changeset
1 ;;; esh-util.el --- general utilities
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64701
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
68648
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65168
diff changeset
4 ;; 2005, 2006 Free Software Foundation, Inc.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
32526
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 32470
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 32470
diff changeset
7
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
ccc03e321fdf *** 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
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62915
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62915
diff changeset
23 ;; Boston, MA 02110-1301, USA.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 (provide 'esh-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 (eval-when-compile (require 'esh-maint))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 (defgroup eshell-util nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 "This is general utility code, meant for use by Eshell itself."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 :tag "General utilities"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 :group 'eshell)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;; Commentary:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 (require 'pp)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;; User Variables:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
40 (defcustom eshell-stringify-t t
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
41 "*If non-nil, the string representation of t is 't'.
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
42 If nil, t will be represented only in the exit code of the function,
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
43 and not printed as a string. This causes Lisp functions to behave
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
44 similarly to external commands, as far as successful result output."
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
45 :type 'boolean
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
46 :group 'eshell-util)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
47
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 (defcustom eshell-group-file "/etc/group"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 "*If non-nil, the name of the group file on your system."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 :type '(choice (const :tag "No group file" nil) file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (defcustom eshell-passwd-file "/etc/passwd"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 "*If non-nil, the name of the passwd file on your system."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 :type '(choice (const :tag "No passwd file" nil) file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 (defcustom eshell-hosts-file "/etc/hosts"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 "*The name of the /etc/hosts file."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 :type '(choice (const :tag "No hosts file" nil) file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 (defcustom eshell-handle-errors t
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 "*If non-nil, Eshell will handle errors itself.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 Setting this to nil is offered as an aid to debugging only."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 :type 'boolean
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 (defcustom eshell-private-file-modes 384 ; umask 177
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 "*The file-modes value to use for creating \"private\" files."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 :type 'integer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 (defcustom eshell-private-directory-modes 448 ; umask 077
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 "*The file-modes value to use for creating \"private\" directories."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 :type 'integer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 (defcustom eshell-tar-regexp
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 "\\.t\\(ar\\(\\.\\(gz\\|bz2\\|Z\\)\\)?\\|gz\\|a[zZ]\\|z2\\)\\'"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 "*Regular expression used to match tar file names."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 :type 'regexp
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (defcustom eshell-convert-numeric-arguments t
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 "*If non-nil, converting arguments of numeric form to Lisp numbers.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 Numeric form is tested using the regular expression
37664
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
88 `eshell-number-regexp'.
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
89
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
90 NOTE: If you find that numeric conversions are intefering with the
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
91 specification of filenames (for example, in calling `find-file', or
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
92 some other Lisp function that deals with files, not numbers), add the
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
93 following in your .emacs file:
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
94
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
95 (put 'find-file 'eshell-no-numeric-conversions t)
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
96
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
97 Any function with the property `eshell-no-numeric-conversions' set to
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
98 a non-nil value, will be passed strings, not numbers, even when an
74b3a3b5aa87 (eshell-convert-numeric-arguments): Annotated the documentation string
John Wiegley <johnw@newartisans.com>
parents: 37659
diff changeset
99 argument matches `eshell-number-regexp'."
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 :type 'boolean
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102
37659
7dc0e015c205 (eshell-number-regexp): Now that number conversions only happen for
John Wiegley <johnw@newartisans.com>
parents: 35588
diff changeset
103 (defcustom eshell-number-regexp "-?\\([0-9]*\\.\\)?[0-9]+\\(e[-0-9.]+\\)?"
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 "*Regular expression used to match numeric arguments.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 If `eshell-convert-numeric-arguments' is non-nil, and an argument
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 matches this regexp, it will be converted to a Lisp number, using the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 function `string-to-number'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 :type 'regexp
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 :group 'eshell-util)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
111 (defcustom eshell-ange-ls-uids nil
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
112 "*List of user/host/id strings, used to determine remote ownership."
35588
31904bdf4350 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 35209
diff changeset
113 :type '(repeat (cons :tag "Host for User/UID map"
31904bdf4350 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 35209
diff changeset
114 (string :tag "Hostname")
31904bdf4350 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 35209
diff changeset
115 (repeat (cons :tag "User/UID List"
31904bdf4350 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 35209
diff changeset
116 (string :tag "Username")
31904bdf4350 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 35209
diff changeset
117 (repeat :tag "UIDs" string)))))
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
118 :group 'eshell-util)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
119
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 ;;; Internal Variables:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (defvar eshell-group-names nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 "A cache to hold the names of groups.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (defvar eshell-group-timestamp nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 "A timestamp of when the group file was read.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (defvar eshell-user-names nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 "A cache to hold the names of users.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (defvar eshell-user-timestamp nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 "A timestamp of when the user file was read.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (defvar eshell-host-names nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 "A cache the names of frequently accessed hosts.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (defvar eshell-host-timestamp nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 "A timestamp of when the hosts file was read.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 ;;; Functions:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (defsubst eshell-under-xemacs-p ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 "Return non-nil if we are running under XEmacs."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (boundp 'xemacs-logo))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (defsubst eshell-under-windows-p ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 "Return non-nil if we are running under MS-DOS/Windows."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (memq system-type '(ms-dos windows-nt)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (defmacro eshell-condition-case (tag form &rest handlers)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 "Like `condition-case', but only if `eshell-pass-through-errors' is nil."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 (if eshell-handle-errors
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 `(condition-case ,tag
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 ,form
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 ,@handlers)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 form))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (put 'eshell-condition-case 'lisp-indent-function 2)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (defmacro eshell-deftest (module name label &rest forms)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 (if (and (fboundp 'cl-compiling-file) (cl-compiling-file))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (let ((fsym (intern (concat "eshell-test--" (symbol-name name)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 `(eval-when-compile
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (ignore
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (defun ,fsym () ,label
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (eshell-run-test (quote ,module) (quote ,fsym) ,label
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (quote (progn ,@forms)))))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 (put 'eshell-deftest 'lisp-indent-function 2)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (defun eshell-find-delimiter
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (open close &optional bound reverse-p backslash-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 "From point, find the CLOSE delimiter corresponding to OPEN.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 The matching is bounded by BOUND.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 If REVERSE-P is non-nil, process the region backwards.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 If BACKSLASH-P is non-nil, and OPEN and CLOSE are the same character,
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 then quoting is done by a backslash, rather than a doubled delimiter."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (let ((depth 1)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 (bound (or bound (point-max))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (if (if reverse-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (eq (char-before) close)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (eq (char-after) open))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (forward-char (if reverse-p -1 1)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (while (and (> depth 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 (funcall (if reverse-p '> '<) (point) bound))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (let ((c (if reverse-p (char-before) (char-after))) nc)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 (cond ((and (not reverse-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (or (not (eq open close))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 backslash-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 (eq c ?\\)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (setq nc (char-after (1+ (point))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 (or (eq nc open) (eq nc close)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (forward-char 1))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 ((and reverse-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 (or (not (eq open close))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 backslash-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 (or (eq c open) (eq c close))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (eq (char-before (1- (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 ?\\))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (forward-char -1))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 ((eq open close)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 (if (eq c open)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (if (and (not backslash-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (eq (if reverse-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (char-before (1- (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (char-after (1+ (point)))) open))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (forward-char (if reverse-p -1 1))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (setq depth (1- depth)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 ((= c open)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (setq depth (+ depth (if reverse-p -1 1))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 ((= c close)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 (setq depth (+ depth (if reverse-p 1 -1))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (forward-char (if reverse-p -1 1)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (if (= depth 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (if reverse-p (point) (1- (point)))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (defun eshell-convert (string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 "Convert STRING into a more native looking Lisp object."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (if (not (stringp string))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 string
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (let ((len (length string)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (if (= len 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 string
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (if (eq (aref string (1- len)) ?\n)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (setq string (substring string 0 (1- len))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (if (string-match "\n" string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (split-string string "\n")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (if (and eshell-convert-numeric-arguments
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (string-match
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (concat "\\`\\s-*" eshell-number-regexp
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "\\s-*\\'") string))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (string-to-number string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 string))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (defun eshell-sublist (l &optional n m)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 "Return from LIST the N to M elements.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 If N or M is nil, it means the end of the list."
45736
fa968fe464d3 (eshell-copy-list): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 38414
diff changeset
240 (let* ((a (copy-sequence l))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 result)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 (if (and m (consp (nthcdr m a)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 (setcdr (nthcdr m a) nil))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (if n
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (setq a (nthcdr n a))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (setq n (1- (length a))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 a (last a)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 a))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (defun eshell-split-path (path)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 "Split a path into multiple subparts."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (let ((len (length path))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (i 0) (li 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 parts)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (if (and (eshell-under-windows-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (> len 2)
62915
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
257 (eq (aref path 0) ?/)
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
258 (eq (aref path 1) ?/))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (setq i 2))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (while (< i len)
62915
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
261 (if (and (eq (aref path i) ?/)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (not (get-text-property i 'escaped path)))
62915
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
263 (setq parts (cons (if (= li i) "/"
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (substring path li (1+ i))) parts)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 li (1+ i)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (setq i (1+ i)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (if (< li i)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (setq parts (cons (substring path li i) parts)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (if (and (eshell-under-windows-p)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (string-match "\\`[A-Za-z]:\\'" (car (last parts))))
62915
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
271 (setcar (last parts) (concat (car (last parts)) "/")))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (nreverse parts)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (defun eshell-to-flat-string (value)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 "Make value a string. If separated by newlines change them to spaces."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (let ((text (eshell-stringify value)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (if (string-match "\n+\\'" text)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (setq text (replace-match "" t t text)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (while (string-match "\n+" text)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 (setq text (replace-match " " t t text)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 text))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (defmacro eshell-for (for-var for-list &rest forms)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 "Iterate through a list"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 `(let ((list-iter ,for-list))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (while list-iter
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (let ((,for-var (car list-iter)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 ,@forms)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (setq list-iter (cdr list-iter)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (put 'eshell-for 'lisp-indent-function 2)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31240
diff changeset
293 (defun eshell-flatten-list (args)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 "Flatten any lists within ARGS, so that there are no sublists."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (let ((new-list (list t)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (eshell-for a args
65168
b93526432c17 *** empty log message ***
John Wiegley <johnw@newartisans.com>
parents: 65164
diff changeset
297 (if (and (listp a)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (listp (cdr a)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (nconc new-list (eshell-flatten-list a))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (nconc new-list (list a))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (cdr new-list)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (defun eshell-uniqify-list (l)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 "Remove occurring multiples in L. You probably want to sort first."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (let ((m l))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (while m
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (while (and (cdr m)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (string= (car m)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (cadr m)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (setcdr m (cddr m)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (setq m (cdr m))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 l)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (defun eshell-stringify (object)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 "Convert OBJECT into a string value."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (cond
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 ((stringp object) object)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 ((and (listp object)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (not (eq object nil)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (let ((string (pp-to-string object)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (substring string 0 (1- (length string)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 ((numberp object)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (number-to-string object))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (t
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
325 (unless (and (eq object t)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
326 (not eshell-stringify-t))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
327 (pp-to-string object)))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (defsubst eshell-stringify-list (args)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 "Convert each element of ARGS into a string value."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (mapcar 'eshell-stringify args))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (defsubst eshell-flatten-and-stringify (&rest args)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 "Flatten and stringify all of the ARGS into a single string."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (mapconcat 'eshell-stringify (eshell-flatten-list args) " "))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 ;; the next two are from GNUS, and really should be made part of Emacs
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 ;; some day
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (defsubst eshell-time-less-p (t1 t2)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 "Say whether time T1 is less than time T2."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (or (< (car t1) (car t2))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (and (= (car t1) (car t2))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (< (nth 1 t1) (nth 1 t2)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (defsubst eshell-time-to-seconds (time)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 "Convert TIME to a floating point number."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (+ (* (car time) 65536.0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (cadr time)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (/ (or (car (cdr (cdr time))) 0) 1000000.0)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (defsubst eshell-directory-files (regexp &optional directory)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 "Return a list of files in the given DIRECTORY matching REGEXP."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (directory-files (or directory default-directory)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 directory regexp))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (defun eshell-regexp-arg (prompt)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 "Return list of regexp and prefix arg using PROMPT."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (let* (;; Don't clobber this.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (last-command last-command)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (regexp (read-from-minibuffer prompt nil nil nil
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 'minibuffer-history-search-history)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (list (if (string-equal regexp "")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (setcar minibuffer-history-search-history
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (nth 1 minibuffer-history-search-history))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 regexp)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (prefix-numeric-value current-prefix-arg))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (defun eshell-printable-size (filesize &optional human-readable
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 block-size use-colors)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 "Return a printable FILESIZE."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (let ((size (float (or filesize 0))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (if human-readable
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (if (< size human-readable)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (if (= (round size) 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 "0"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (if block-size
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 "1.0k"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (format "%.0f" size)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (setq size (/ size human-readable))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (if (< size human-readable)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (if (<= size 9.94)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (format "%.1fk" size)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (format "%.0fk" size))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (setq size (/ size human-readable))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (if (< size human-readable)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (let ((str (if (<= size 9.94)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (format "%.1fM" size)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (format "%.0fM" size))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (if use-colors
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (put-text-property 0 (length str)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 'face 'bold str))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 str)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (setq size (/ size human-readable))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (if (< size human-readable)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (let ((str (if (<= size 9.94)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (format "%.1fG" size)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (format "%.0fG" size))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (if use-colors
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (put-text-property 0 (length str)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 'face 'bold-italic str))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 str)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (if block-size
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (setq size (/ size block-size)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (format "%.0f" size))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (defun eshell-winnow-list (entries exclude &optional predicates)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 "Pare down the ENTRIES list using the EXCLUDE regexp, and PREDICATES.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 The original list is not affected. If the result is only one element
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 long, it will be returned itself, rather than returning a one-element
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 list."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (let ((flist (list t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 valid p listified)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (unless (listp entries)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (setq entries (list entries)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 listified t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (eshell-for entry entries
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (unless (and exclude (string-match exclude entry))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (setq p predicates valid (null p))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (while p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (if (funcall (car p) entry)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (setq valid t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (setq p nil valid nil))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (setq p (cdr p)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (when valid
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (nconc flist (list entry)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (if listified
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (cadr flist)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (cdr flist))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (defsubst eshell-redisplay ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 "Allow Emacs to redisplay buffers."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 ;; for some strange reason, Emacs 21 is prone to trigger an
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 ;; "args out of range" error in `sit-for', if this function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 ;; runs while point is in the minibuffer and the users attempt
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 ;; to use completion. Don't ask me.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (ignore-errors (sit-for 0 0)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (defun eshell-read-passwd-file (file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 "Return an alist correlating gids to group names in FILE."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (let (names)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (when (file-readable-p file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (with-temp-buffer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (insert-file-contents file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (goto-char (point-min))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (while (not (eobp))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (let* ((fields
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (split-string (buffer-substring
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (point) (progn (end-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (point))) ":")))
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
450 (if (and (and fields (nth 0 fields) (nth 2 fields))
62915
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
451 (not (assq (string-to-number (nth 2 fields)) names)))
b89e30bcd2bb Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
452 (setq names (cons (cons (string-to-number (nth 2 fields))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (nth 0 fields))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 names))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (forward-line))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 names))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (defun eshell-read-passwd (file result-var timestamp-var)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 "Read the contents of /etc/passwd for user names."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (if (or (not (symbol-value result-var))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (not (symbol-value timestamp-var))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (eshell-time-less-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (symbol-value timestamp-var)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (nth 5 (file-attributes file))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (progn
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (set result-var (eshell-read-passwd-file file))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (set timestamp-var (current-time))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (symbol-value result-var))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (defun eshell-read-group-names ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 "Read the contents of /etc/group for group names."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (if eshell-group-file
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (eshell-read-passwd eshell-group-file 'eshell-group-names
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 'eshell-group-timestamp)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (defsubst eshell-group-id (name)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 "Return the user id for user NAME."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (car (rassoc name (eshell-read-group-names))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (defsubst eshell-group-name (gid)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 "Return the group name for the given GID."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (cdr (assoc gid (eshell-read-group-names))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (defun eshell-read-user-names ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 "Read the contents of /etc/passwd for user names."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (if eshell-passwd-file
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (eshell-read-passwd eshell-passwd-file 'eshell-user-names
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 'eshell-user-timestamp)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (defsubst eshell-user-id (name)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 "Return the user id for user NAME."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (car (rassoc name (eshell-read-user-names))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 (defalias 'eshell-user-name 'user-login-name)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 (defun eshell-read-hosts-file (filename)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 "Read in the hosts from the /etc/hosts file."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (let (hosts)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (with-temp-buffer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (insert-file-contents eshell-hosts-file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (goto-char (point-min))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (while (re-search-forward
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 "^\\(\\S-+\\)\\s-+\\(\\S-+\\)\\(\\s-*\\(\\S-+\\)\\)?" nil t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (if (match-string 1)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (add-to-list 'hosts (match-string 1)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (if (match-string 2)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (add-to-list 'hosts (match-string 2)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (if (match-string 4)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (add-to-list 'hosts (match-string 4)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (sort hosts 'string-lessp)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (defun eshell-read-hosts (file result-var timestamp-var)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 "Read the contents of /etc/passwd for user names."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (if (or (not (symbol-value result-var))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (not (symbol-value timestamp-var))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (eshell-time-less-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (symbol-value timestamp-var)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (nth 5 (file-attributes file))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (progn
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (set result-var (eshell-read-hosts-file file))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (set timestamp-var (current-time))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (symbol-value result-var))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (defun eshell-read-host-names ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 "Read the contents of /etc/hosts for host names."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (if eshell-hosts-file
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (eshell-read-hosts eshell-hosts-file 'eshell-host-names
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 'eshell-host-timestamp)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (unless (fboundp 'line-end-position)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (defsubst line-end-position (&optional N)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (save-excursion (end-of-line N) (point))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (unless (fboundp 'line-beginning-position)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (defsubst line-beginning-position (&optional N)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (save-excursion (beginning-of-line N) (point))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (unless (fboundp 'subst-char-in-string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (defun subst-char-in-string (fromchar tochar string &optional inplace)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 Unless optional argument INPLACE is non-nil, return a new string."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (let ((i (length string))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (newstr (if inplace string (copy-sequence string))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (while (> i 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (setq i (1- i))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (if (eq (aref newstr i) fromchar)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (aset newstr i tochar)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 newstr)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (defsubst eshell-copy-environment ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 "Return an unrelated copy of `process-environment'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (mapcar 'concat process-environment))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (defun eshell-subgroups (groupsym)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 "Return all of the subgroups of GROUPSYM."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (let ((subgroups (get groupsym 'custom-group))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (subg (list t)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (while subgroups
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (if (eq (cadr (car subgroups)) 'custom-group)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (nconc subg (list (caar subgroups))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (setq subgroups (cdr subgroups)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (cdr subg)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 (defmacro eshell-with-file-modes (modes &rest forms)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 "Evaluate, with file-modes set to MODES, the given FORMS."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 `(let ((modes (default-file-modes)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (set-default-file-modes ,modes)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (unwind-protect
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (progn ,@forms)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 (set-default-file-modes modes))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 (defmacro eshell-with-private-file-modes (&rest forms)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 "Evaluate FORMS with private file modes set."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 `(eshell-with-file-modes ,eshell-private-file-modes ,@forms))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (defsubst eshell-make-private-directory (dir &optional parents)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 "Make DIR with file-modes set to `eshell-private-directory-modes'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (eshell-with-file-modes eshell-private-directory-modes
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (make-directory dir parents)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (defsubst eshell-substring (string sublen)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 "Return the beginning of STRING, up to SUBLEN bytes."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (if string
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (if (> (length string) sublen)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (substring string 0 sublen)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 string)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (unless (fboundp 'directory-files-and-attributes)
47963
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
589 (defun directory-files-and-attributes (directory &optional full match nosort)
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
590 "Return a list of names of files and their attributes in DIRECTORY.
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
591 There are three optional arguments:
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
592 If FULL is non-nil, return absolute file names. Otherwise return names
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
593 that are relative to the specified directory.
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
594 If MATCH is non-nil, mention only file names that match the regexp MATCH.
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
595 If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
596 NOSORT is useful if you plan to sort the result yourself."
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
597 (let ((directory (expand-file-name directory)) ange-cache)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (mapcar
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (lambda (file)
47963
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
601 (cons file (eshell-file-attributes (expand-file-name file directory)))))
39dffdbc6892 (directory-files-and-attributes): Copy docstring from Emacs 21. Arg DIR renamed
Juanma Barranquero <lekktu@gmail.com>
parents: 46852
diff changeset
602 (directory-files directory full match nosort)))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
604 (eval-when-compile
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
605 (defvar ange-cache))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
606
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 (defun eshell-directory-files-and-attributes (dir &optional full match nosort)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 "Make sure to use the handler for `directory-file-and-attributes'."
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
609 (let* ((dir (expand-file-name dir))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
610 (dfh (find-file-name-handler dir 'directory-files)))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 (if (not dfh)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 (directory-files-and-attributes dir full match nosort)
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
613 (let ((files (funcall dfh 'directory-files dir full match nosort))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
614 (fah (find-file-name-handler dir 'file-attributes)))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 (mapcar
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 (lambda (file)
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
618 (cons file (if fah
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
619 (eshell-file-attributes
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
620 (expand-file-name file dir))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
621 (file-attributes (expand-file-name file dir))))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 files)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
624 (defun eshell-current-ange-uids ()
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
625 (if (string-match "/\\([^@]+\\)@\\([^:]+\\):" default-directory)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
626 (let* ((host (match-string 2 default-directory))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
627 (user (match-string 1 default-directory))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
628 (host-users (assoc host eshell-ange-ls-uids)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
629 (when host-users
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
630 (setq host-users (cdr host-users))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
631 (cdr (assoc user host-users))))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
632
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
633 ;; Add an autoload for parse-time-string
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
634 (if (and (not (fboundp 'parse-time-string))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
635 (locate-library "parse-time"))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
636 (autoload 'parse-time-string "parse-time"))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
637
32470
b338a85bdffc Added a missing `require' form.
John Wiegley <johnw@newartisans.com>
parents: 32446
diff changeset
638 (eval-when-compile
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
639 (load "ange-ftp" t))
32470
b338a85bdffc Added a missing `require' form.
John Wiegley <johnw@newartisans.com>
parents: 32446
diff changeset
640
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
641 (defun eshell-parse-ange-ls (dir)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
642 (let (entry)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
643 (with-temp-buffer
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
644 (insert (ange-ftp-ls dir "-la" nil))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
645 (goto-char (point-min))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
646 (if (looking-at "^total [0-9]+$")
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
647 (forward-line 1))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
648 ;; Some systems put in a blank line here.
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
649 (if (eolp) (forward-line 1))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
650 (while (looking-at
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
651 `,(concat "\\([dlscb-][rwxst-]+\\)"
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
652 "\\s-*" "\\([0-9]+\\)" "\\s-+"
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
653 "\\(\\S-+\\)" "\\s-+"
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
654 "\\(\\S-+\\)" "\\s-+"
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
655 "\\([0-9]+\\)" "\\s-+" "\\(.*\\)"))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
656 (let* ((perms (match-string 1))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
657 (links (string-to-number (match-string 2)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
658 (user (match-string 3))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
659 (group (match-string 4))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
660 (size (string-to-number (match-string 5)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
661 (mtime
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
662 (if (fboundp 'parse-time-string)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
663 (let ((moment (parse-time-string
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
664 (match-string 6))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
665 (if (nth 0 moment)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
666 (setcar (nthcdr 5 moment)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
667 (nth 5 (decode-time (current-time))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
668 (setcar (nthcdr 0 moment) 0)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
669 (setcar (nthcdr 1 moment) 0)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
670 (setcar (nthcdr 2 moment) 0))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
671 (apply 'encode-time moment))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
672 (ange-ftp-file-modtime (expand-file-name name dir))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
673 (name (ange-ftp-parse-filename))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
674 symlink)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
675 (if (string-match "\\(.+\\) -> \\(.+\\)" name)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
676 (setq symlink (match-string 2 name)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
677 name (match-string 1 name)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
678 (setq entry
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
679 (cons
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
680 (cons name
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
681 (list (if (eq (aref perms 0) ?d)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
682 t
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
683 symlink)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
684 links user group
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
685 nil mtime nil
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
686 size perms nil nil)) entry)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
687 (forward-line)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
688 entry))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
689
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
690 (defun eshell-file-attributes (file)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
691 "Return the attributes of FILE, playing tricks if it's over ange-ftp."
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
692 (let* ((file (expand-file-name file))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
693 (handler (find-file-name-handler file 'file-attributes))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
694 entry)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
695 (if (not handler)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
696 (file-attributes file)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
697 (if (eq (find-file-name-handler (file-name-directory file)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
698 'directory-files)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
699 'ange-ftp-hook-function)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
700 (let ((base (file-name-nondirectory file))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
701 (dir (file-name-directory file)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
702 (if (boundp 'ange-cache)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
703 (setq entry (cdr (assoc base (cdr (assoc dir ange-cache))))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
704 (unless entry
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
705 (setq entry (eshell-parse-ange-ls dir))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
706 (if (boundp 'ange-cache)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
707 (setq ange-cache
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
708 (cons (cons dir entry)
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
709 ange-cache)))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
710 (if entry
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
711 (let ((fentry (assoc base (cdr entry))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
712 (if fentry
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
713 (setq entry (cdr fentry))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
714 (setq entry nil)))))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
715 (or entry (funcall handler 'file-attributes file)))))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
716
45741
b2a7c08cddcf (eshell-copy-tree): Make it an alias for copy-tree.
Richard M. Stallman <rms@gnu.org>
parents: 45736
diff changeset
717 (defalias 'eshell-copy-tree 'copy-tree)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
719 (defsubst eshell-processp (proc)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
720 "If the `processp' function does not exist, PROC is not a process."
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
721 (and (fboundp 'processp) (processp proc)))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
722
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 ; (defun eshell-copy-file
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 ; (file newname &optional ok-if-already-exists keep-date)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 ; "Copy FILE to NEWNAME. See docs for `copy-file'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 ; (let (copied)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 ; (if (string-match "\\`\\([^:]+\\):\\(.*\\)" file)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 ; (let ((front (match-string 1 file))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 ; (back (match-string 2 file))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 ; buffer)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 ; (if (and front (string-match eshell-tar-regexp front)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 ; (setq buffer (find-file-noselect front)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 ; (with-current-buffer buffer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 ; (goto-char (point-min))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 ; (if (re-search-forward (concat " " (regexp-quote back)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 ; "$") nil t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 ; (progn
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 ; (tar-copy (if (file-directory-p newname)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 ; (expand-file-name
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 ; (file-name-nondirectory back) newname)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 ; newname))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 ; (setq copied t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 ; (error "%s not found in tar file %s" back front))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 ; (unless copied
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 ; (copy-file file newname ok-if-already-exists keep-date))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 ; (defun eshell-file-attributes (filename)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 ; "Return a list of attributes of file FILENAME.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 ; See the documentation for `file-attributes'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 ; (let (result)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 ; (when (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" filename)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 ; (let ((front (match-string 1 filename))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 ; (back (match-string 2 filename))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 ; buffer)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 ; (when (and front (string-match eshell-tar-regexp front)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 ; (setq buffer (find-file-noselect front)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 ; (with-current-buffer buffer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 ; (goto-char (point-min))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 ; (when (re-search-forward (concat " " (regexp-quote back)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 ; "\\s-*$") nil t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 ; (let* ((descrip (tar-current-descriptor))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 ; (tokens (tar-desc-tokens descrip)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 ; (setq result
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 ; (list
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 ; (cond
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 ; ((eq (tar-header-link-type tokens) 5)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 ; t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 ; ((eq (tar-header-link-type tokens) t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 ; (tar-header-link-name tokens)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 ; 1
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 ; (tar-header-uid tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 ; (tar-header-gid tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773 ; (tar-header-date tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774 ; (tar-header-date tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 ; (tar-header-date tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 ; (tar-header-size tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 ; (concat
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 ; (cond
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 ; ((eq (tar-header-link-type tokens) 5) "d")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780 ; ((eq (tar-header-link-type tokens) t) "l")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 ; (t "-"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782 ; (tar-grind-file-mode (tar-header-mode tokens)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 ; (make-string 9 ? ) 0))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 ; nil nil nil))))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 ; (or result
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 ; (file-attributes filename))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788 ;;; Code:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 47963
diff changeset
790 ;;; arch-tag: 70159778-5c7a-480a-bae4-3ad332fca19d
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791 ;;; esh-util.el ends here