Mercurial > emacs
annotate lisp/eshell/em-unix.el @ 111447:c4afb802863e
* lisp/progmodes/meta-mode.el: (meta-indent-line): Simplify.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 09 Nov 2010 00:00:46 -0800 |
parents | f349e65969e5 |
children | f21190964294 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37661
diff
changeset
|
1 ;;; em-unix.el --- UNIX command aliases |
29876 | 2 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
29876 | 5 |
32526 | 6 ;; Author: John Wiegley <johnw@gnu.org> |
7 | |
29876 | 8 ;; This file is part of GNU Emacs. |
9 | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
29876 | 11 ;; it under the terms of the GNU General Public License as published by |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
29876 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
29876 | 22 |
87076
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
23 ;;; Commentary: |
29876 | 24 |
87076
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
25 ;; This file contains implementations of several UNIX command in Emacs |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
26 ;; Lisp, for several reasons: |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
27 ;; |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
28 ;; 1) it makes them available on all platforms where the Lisp |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
29 ;; functions used are available |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
30 ;; |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
31 ;; 2) it makes their functionality accessible and modified by the |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
32 ;; Lisp programmer. |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
33 ;; |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
34 ;; 3) it allows Eshell to refrain from having to invoke external |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
35 ;; processes for common operations. |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
36 |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
37 ;;; Code: |
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
38 |
55195
f243dc772a99
Add "(require 'eshell)", to get necessary features
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
39 (require 'eshell) |
106390 | 40 (require 'esh-opt) |
41 (require 'pcomplete) | |
29876 | 42 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
43 ;;;###autoload |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
44 (eshell-defgroup eshell-unix nil |
29876 | 45 "This module defines many of the more common UNIX utilities as |
46 aliases implemented in Lisp. These include mv, ln, cp, rm, etc. If | |
47 the user passes arguments which are too complex, or are unrecognized | |
48 by the Lisp variant, the external version will be called (if | |
49 available). The only reason not to use them would be because they are | |
50 usually much slower. But in several cases their tight integration | |
51 with Eshell makes them more versatile than their traditional cousins | |
52 \(such as being able to use `kill' to kill Eshell background processes | |
53 by name)." | |
54 :tag "UNIX commands in Lisp" | |
55 :group 'eshell-module) | |
56 | |
57 (defcustom eshell-unix-load-hook '(eshell-unix-initialize) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
58 "A list of functions to run when `eshell-unix' is loaded." |
29876 | 59 :type 'hook |
60 :group 'eshell-unix) | |
61 | |
62 (defcustom eshell-plain-grep-behavior nil | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
63 "If non-nil, standalone \"grep\" commands will behave normally. |
29876 | 64 Standalone in this context means not redirected, and not on the |
65 receiving side of a command pipeline." | |
66 :type 'boolean | |
67 :group 'eshell-unix) | |
68 | |
69 (defcustom eshell-no-grep-available (not (eshell-search-path "grep")) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
70 "If non-nil, no grep is available on the current machine." |
29876 | 71 :type 'boolean |
72 :group 'eshell-unix) | |
73 | |
74 (defcustom eshell-plain-diff-behavior nil | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
75 "If non-nil, standalone \"diff\" commands will behave normally. |
29876 | 76 Standalone in this context means not redirected, and not on the |
77 receiving side of a command pipeline." | |
78 :type 'boolean | |
79 :group 'eshell-unix) | |
80 | |
86202
794e428cd497
* eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86106
diff
changeset
|
81 (defcustom eshell-plain-locate-behavior (featurep 'xemacs) |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
82 "If non-nil, standalone \"locate\" commands will behave normally. |
29876 | 83 Standalone in this context means not redirected, and not on the |
84 receiving side of a command pipeline." | |
85 :type 'boolean | |
86 :group 'eshell-unix) | |
87 | |
88 (defcustom eshell-rm-removes-directories nil | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
89 "If non-nil, `rm' will remove directory entries. |
29876 | 90 Otherwise, `rmdir' is required." |
91 :type 'boolean | |
92 :group 'eshell-unix) | |
93 | |
94 (defcustom eshell-rm-interactive-query (= (user-uid) 0) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
95 "If non-nil, `rm' will query before removing anything." |
29876 | 96 :type 'boolean |
97 :group 'eshell-unix) | |
98 | |
99 (defcustom eshell-mv-interactive-query (= (user-uid) 0) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
100 "If non-nil, `mv' will query before overwriting anything." |
29876 | 101 :type 'boolean |
102 :group 'eshell-unix) | |
103 | |
104 (defcustom eshell-mv-overwrite-files t | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
105 "If non-nil, `mv' will overwrite files without warning." |
29876 | 106 :type 'boolean |
107 :group 'eshell-unix) | |
108 | |
109 (defcustom eshell-cp-interactive-query (= (user-uid) 0) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
110 "If non-nil, `cp' will query before overwriting anything." |
29876 | 111 :type 'boolean |
112 :group 'eshell-unix) | |
113 | |
114 (defcustom eshell-cp-overwrite-files t | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
115 "If non-nil, `cp' will overwrite files without warning." |
29876 | 116 :type 'boolean |
117 :group 'eshell-unix) | |
118 | |
119 (defcustom eshell-ln-interactive-query (= (user-uid) 0) | |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
120 "If non-nil, `ln' will query before overwriting anything." |
29876 | 121 :type 'boolean |
122 :group 'eshell-unix) | |
123 | |
31241 | 124 (defcustom eshell-ln-overwrite-files nil |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
125 "If non-nil, `ln' will overwrite files without warning." |
29876 | 126 :type 'boolean |
127 :group 'eshell-unix) | |
128 | |
33020 | 129 (defcustom eshell-default-target-is-dot nil |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
130 "If non-nil, the default destination for cp, mv or ln is `.'." |
33020 | 131 :type 'boolean |
132 :group 'eshell-unix) | |
133 | |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
134 (defcustom eshell-du-prefer-over-ange nil |
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
135 "Use Eshell's du in ange-ftp remote directories. |
32493
34d5d8707722
(eshell-du-prefer-over-ange): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
32446
diff
changeset
|
136 Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine." |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
137 :type 'boolean |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
138 :group 'eshell-unix) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
139 |
29876 | 140 ;;; Functions: |
141 | |
142 (defun eshell-unix-initialize () | |
143 "Initialize the UNIX support/emulation code." | |
144 (when (eshell-using-module 'eshell-cmpl) | |
145 (add-hook 'pcomplete-try-first-hook | |
33020 | 146 'eshell-complete-host-reference nil t)) |
147 (make-local-variable 'eshell-complex-commands) | |
148 (setq eshell-complex-commands | |
149 (append '("grep" "egrep" "fgrep" "agrep" "glimpse" "locate" | |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
150 "cat" "time" "cp" "mv" "make" "du" "diff" "su" "sudo") |
33020 | 151 eshell-complex-commands))) |
29876 | 152 |
153 (defalias 'eshell/date 'current-time-string) | |
154 (defalias 'eshell/basename 'file-name-nondirectory) | |
155 (defalias 'eshell/dirname 'file-name-directory) | |
156 | |
95619
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
157 (defvar interactive) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
158 (defvar preview) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
159 (defvar recursive) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
160 (defvar verbose) |
29876 | 161 |
162 (defun eshell/man (&rest args) | |
163 "Invoke man, flattening the arguments appropriately." | |
164 (funcall 'man (apply 'eshell-flatten-and-stringify args))) | |
165 | |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
166 (put 'eshell/man 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
167 |
83810
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
168 (defun eshell/info (&rest args) |
86106
29738c3df361
(eshell/info): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
85660
diff
changeset
|
169 "Run the info command in-frame with the same behavior as command-line `info', ie: |
83810
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
170 'info' => goes to top info window |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
171 'info arg1' => IF arg1 is a file, then visits arg1 |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
172 'info arg1' => OTHERWISE goes to top info window and then menu item arg1 |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
173 'info arg1 arg2' => does action for arg1 (either visit-file or menu-item) and then menu item arg2 |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
174 etc." |
85503
59ee4068f60b
* progmodes/gud.el (gud-target-name): Move definition before use.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
83839
diff
changeset
|
175 (eval-and-compile (require 'info)) |
83810
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
176 (let ((file (cond |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
177 ((not (stringp (car args))) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
178 nil) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
179 ((file-exists-p (expand-file-name (car args))) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
180 (expand-file-name (car args))) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
181 ((file-exists-p (concat (expand-file-name (car args)) ".info")) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
182 (concat (expand-file-name (car args)) ".info"))))) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
183 |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
184 ;; If the first arg is a file, then go to that file's Top node |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
185 ;; Otherwise, go to the global directory |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
186 (if file |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
187 (progn |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
188 (setq args (cdr args)) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
189 (Info-find-node file "Top")) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
190 (Info-directory)) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
191 |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
192 ;; Treat all remaining args as menu references |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
193 (while args |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
194 (Info-menu (car args)) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
195 (setq args (cdr args))))) |
5ad1e235d4fa
James Wright <james at chumsley.org>
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
196 |
29876 | 197 (defun eshell-remove-entries (path files &optional top-level) |
33020 | 198 "From PATH, remove all of the given FILES, perhaps interactively." |
29876 | 199 (while files |
200 (if (string-match "\\`\\.\\.?\\'" | |
201 (file-name-nondirectory (car files))) | |
202 (if top-level | |
203 (eshell-error "rm: cannot remove `.' or `..'\n")) | |
204 (if (and (file-directory-p (car files)) | |
205 (not (file-symlink-p (car files)))) | |
111144
f349e65969e5
Use recursive-trash feature for eshell deletion (Bug#7011).
Chong Yidong <cyd@stupidchicken.com>
parents:
110580
diff
changeset
|
206 (progn |
29876 | 207 (if verbose |
208 (eshell-printn (format "rm: removing directory `%s'" | |
209 (car files)))) | |
210 (unless | |
211 (or preview | |
212 (and interactive | |
213 (not (y-or-n-p | |
214 (format "rm: remove directory `%s'? " | |
215 (car files)))))) | |
111144
f349e65969e5
Use recursive-trash feature for eshell deletion (Bug#7011).
Chong Yidong <cyd@stupidchicken.com>
parents:
110580
diff
changeset
|
216 (eshell-funcalln 'delete-directory (car files) t t))) |
29876 | 217 (if verbose |
218 (eshell-printn (format "rm: removing file `%s'" | |
219 (car files)))) | |
220 (unless (or preview | |
221 (and interactive | |
222 (not (y-or-n-p | |
223 (format "rm: remove `%s'? " | |
224 (car files)))))) | |
111144
f349e65969e5
Use recursive-trash feature for eshell deletion (Bug#7011).
Chong Yidong <cyd@stupidchicken.com>
parents:
110580
diff
changeset
|
225 (eshell-funcalln 'delete-file (car files) t)))) |
29876 | 226 (setq files (cdr files)))) |
227 | |
228 (defun eshell/rm (&rest args) | |
229 "Implementation of rm in Lisp. | |
230 This is implemented to call either `delete-file', `kill-buffer', | |
231 `kill-process', or `unintern', depending on the nature of the | |
232 argument." | |
233 (setq args (eshell-flatten-list args)) | |
234 (eshell-eval-using-options | |
235 "rm" args | |
236 '((?h "help" nil nil "show this usage screen") | |
237 (?f "force" nil force-removal "force removal") | |
238 (?i "interactive" nil interactive "prompt before any removal") | |
239 (?n "preview" nil preview "don't change anything on disk") | |
240 (?r "recursive" nil recursive | |
241 "remove the contents of directories recursively") | |
242 (?R nil nil recursive "(same)") | |
243 (?v "verbose" nil verbose "explain what is being done") | |
244 :preserve-args | |
245 :external "rm" | |
246 :show-usage | |
247 :usage "[OPTION]... FILE... | |
248 Remove (unlink) the FILE(s).") | |
249 (unless interactive | |
250 (setq interactive eshell-rm-interactive-query)) | |
251 (if (and force-removal interactive) | |
252 (setq interactive nil)) | |
253 (while args | |
254 (let ((entry (if (stringp (car args)) | |
255 (directory-file-name (car args)) | |
256 (if (numberp (car args)) | |
257 (number-to-string (car args)) | |
258 (car args))))) | |
259 (cond | |
260 ((bufferp entry) | |
261 (if verbose | |
262 (eshell-printn (format "rm: removing buffer `%s'" entry))) | |
263 (unless (or preview | |
264 (and interactive | |
265 (not (y-or-n-p (format "rm: delete buffer `%s'? " | |
266 entry))))) | |
267 (eshell-funcalln 'kill-buffer entry))) | |
31241 | 268 ((eshell-processp entry) |
29876 | 269 (if verbose |
270 (eshell-printn (format "rm: killing process `%s'" entry))) | |
271 (unless (or preview | |
272 (and interactive | |
273 (not (y-or-n-p (format "rm: kill process `%s'? " | |
274 entry))))) | |
275 (eshell-funcalln 'kill-process entry))) | |
276 ((symbolp entry) | |
277 (if verbose | |
278 (eshell-printn (format "rm: uninterning symbol `%s'" entry))) | |
279 (unless | |
280 (or preview | |
281 (and interactive | |
282 (not (y-or-n-p (format "rm: unintern symbol `%s'? " | |
283 entry))))) | |
284 (eshell-funcalln 'unintern entry))) | |
285 ((stringp entry) | |
286 (if (and (file-directory-p entry) | |
287 (not (file-symlink-p entry))) | |
288 (if (or recursive | |
289 eshell-rm-removes-directories) | |
290 (if (or preview | |
291 (not interactive) | |
292 (y-or-n-p | |
293 (format "rm: descend into directory `%s'? " | |
294 entry))) | |
295 (eshell-remove-entries nil (list entry) t)) | |
296 (eshell-error (format "rm: %s: is a directory\n" entry))) | |
297 (eshell-remove-entries nil (list entry) t))))) | |
298 (setq args (cdr args))) | |
299 nil)) | |
300 | |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
301 (put 'eshell/rm 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
302 |
29876 | 303 (defun eshell/mkdir (&rest args) |
304 "Implementation of mkdir in Lisp." | |
305 (eshell-eval-using-options | |
306 "mkdir" args | |
307 '((?h "help" nil nil "show this usage screen") | |
308 :external "mkdir" | |
309 :show-usage | |
310 :usage "[OPTION] DIRECTORY... | |
311 Create the DIRECTORY(ies), if they do not already exist.") | |
312 (while args | |
313 (eshell-funcalln 'make-directory (car args)) | |
314 (setq args (cdr args))) | |
315 nil)) | |
316 | |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
317 (put 'eshell/mkdir 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
318 |
29876 | 319 (defun eshell/rmdir (&rest args) |
320 "Implementation of rmdir in Lisp." | |
321 (eshell-eval-using-options | |
322 "rmdir" args | |
323 '((?h "help" nil nil "show this usage screen") | |
324 :external "rmdir" | |
325 :show-usage | |
326 :usage "[OPTION] DIRECTORY... | |
327 Remove the DIRECTORY(ies), if they are empty.") | |
328 (while args | |
329 (eshell-funcalln 'delete-directory (car args)) | |
330 (setq args (cdr args))) | |
331 nil)) | |
332 | |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
333 (put 'eshell/rmdir 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
334 |
95619
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
335 (defvar no-dereference) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
336 (defvar preview) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
337 (defvar verbose) |
29876 | 338 |
339 (defvar eshell-warn-dot-directories t) | |
340 | |
341 (defun eshell-shuffle-files (command action files target func deep &rest args) | |
342 "Shuffle around some filesystem entries, using FUNC to do the work." | |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
343 (let ((attr-target (eshell-file-attributes target)) |
29876 | 344 (is-dir (or (file-directory-p target) |
345 (and preview (not eshell-warn-dot-directories)))) | |
346 attr) | |
347 (if (and (not preview) (not is-dir) | |
348 (> (length files) 1)) | |
349 (error "%s: when %s multiple files, last argument must be a directory" | |
350 command action)) | |
351 (while files | |
352 (setcar files (directory-file-name (car files))) | |
353 (cond | |
354 ((string-match "\\`\\.\\.?\\'" | |
355 (file-name-nondirectory (car files))) | |
356 (if eshell-warn-dot-directories | |
357 (eshell-error (format "%s: %s: omitting directory\n" | |
358 command (car files))))) | |
359 ((and attr-target | |
30269
30829e002c1b
(eshell-shuffle-files): Don't disable
Eli Zaretskii <eliz@gnu.org>
parents:
29934
diff
changeset
|
360 (or (not (eshell-under-windows-p)) |
30829e002c1b
(eshell-shuffle-files): Don't disable
Eli Zaretskii <eliz@gnu.org>
parents:
29934
diff
changeset
|
361 (eq system-type 'ms-dos)) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
362 (setq attr (eshell-file-attributes (car files))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
363 (nth 10 attr-target) (nth 10 attr) |
39293
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
364 ;; Use equal, not -, since the inode and the device could |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
365 ;; cons cells. |
39235
f3a553d88ab7
(eshell-shuffle-files): Compare inodes with
Eli Zaretskii <eliz@gnu.org>
parents:
38414
diff
changeset
|
366 (equal (nth 10 attr-target) (nth 10 attr)) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
367 (nth 11 attr-target) (nth 11 attr) |
39293
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
368 (equal (nth 11 attr-target) (nth 11 attr))) |
29876 | 369 (eshell-error (format "%s: `%s' and `%s' are the same file\n" |
370 command (car files) target))) | |
371 (t | |
372 (let ((source (car files)) | |
373 (target (if is-dir | |
374 (expand-file-name | |
375 (file-name-nondirectory (car files)) target) | |
376 target)) | |
377 link) | |
378 (if (and (file-directory-p source) | |
379 (or (not no-dereference) | |
380 (not (file-symlink-p source))) | |
381 (not (memq func '(make-symbolic-link | |
382 add-name-to-file)))) | |
383 (if (and (eq func 'copy-file) | |
384 (not recursive)) | |
385 (eshell-error (format "%s: %s: omitting directory\n" | |
386 command (car files))) | |
387 (let (eshell-warn-dot-directories) | |
388 (if (and (not deep) | |
389 (eq func 'rename-file) | |
39293
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
390 ;; Use equal, since the device might be a |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
391 ;; cons cell. |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
392 (equal (nth 11 (eshell-file-attributes |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
393 (file-name-directory |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
394 (directory-file-name |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
395 (expand-file-name source))))) |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
396 (nth 11 (eshell-file-attributes |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
397 (file-name-directory |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
398 (directory-file-name |
1e91a5f60ae6
(eshell-shuffle-files, eshell-shuffle-files):
Eli Zaretskii <eliz@gnu.org>
parents:
39235
diff
changeset
|
399 (expand-file-name target))))))) |
29876 | 400 (apply 'eshell-funcalln func source target args) |
401 (unless (file-directory-p target) | |
402 (if verbose | |
403 (eshell-printn | |
404 (format "%s: making directory %s" | |
405 command target))) | |
406 (unless preview | |
407 (eshell-funcalln 'make-directory target))) | |
31241 | 408 (apply 'eshell-shuffle-files |
409 command action | |
410 (mapcar | |
411 (function | |
412 (lambda (file) | |
413 (concat source "/" file))) | |
414 (directory-files source)) | |
415 target func t args) | |
29876 | 416 (when (eq func 'rename-file) |
417 (if verbose | |
418 (eshell-printn | |
419 (format "%s: deleting directory %s" | |
420 command source))) | |
421 (unless preview | |
422 (eshell-funcalln 'delete-directory source)))))) | |
423 (if verbose | |
424 (eshell-printn (format "%s: %s -> %s" command | |
425 source target))) | |
426 (unless preview | |
427 (if (and no-dereference | |
428 (setq link (file-symlink-p source))) | |
429 (progn | |
430 (apply 'eshell-funcalln 'make-symbolic-link | |
431 link target args) | |
432 (if (eq func 'rename-file) | |
433 (if (and (file-directory-p source) | |
434 (not (file-symlink-p source))) | |
435 (eshell-funcalln 'delete-directory source) | |
436 (eshell-funcalln 'delete-file source)))) | |
437 (apply 'eshell-funcalln func source target args))))))) | |
438 (setq files (cdr files))))) | |
439 | |
440 (defun eshell-shorthand-tar-command (command args) | |
441 "Rewrite `cp -v dir a.tar.gz' to `tar cvzf a.tar.gz dir'." | |
442 (let* ((archive (car (last args))) | |
443 (tar-args | |
444 (cond ((string-match "z2" archive) "If") | |
445 ((string-match "gz" archive) "zf") | |
446 ((string-match "\\(az\\|Z\\)" archive) "Zf") | |
447 (t "f")))) | |
448 (if (file-exists-p archive) | |
449 (setq tar-args (concat "u" tar-args)) | |
450 (setq tar-args (concat "c" tar-args))) | |
451 (if verbose | |
452 (setq tar-args (concat "v" tar-args))) | |
453 (if (equal command "mv") | |
454 (setq tar-args (concat "--remove-files -" tar-args))) | |
455 ;; truncate the archive name from the arguments | |
456 (setcdr (last args 2) nil) | |
457 (throw 'eshell-replace-command | |
458 (eshell-parse-command | |
459 (format "tar %s %s" tar-args archive) args)))) | |
460 | |
461 ;; this is to avoid duplicating code... | |
33020 | 462 (defmacro eshell-mvcpln-template (command action func query-var |
463 force-var &optional preserve) | |
464 `(let ((len (length args))) | |
465 (if (or (= len 0) | |
466 (and (= len 1) (null eshell-default-target-is-dot))) | |
467 (error "%s: missing destination file or directory" ,command)) | |
468 (if (= len 1) | |
469 (nconc args '("."))) | |
470 (setq args (eshell-stringify-list (eshell-flatten-list args))) | |
471 (if (and ,(not (equal command "ln")) | |
472 (string-match eshell-tar-regexp (car (last args))) | |
473 (or (> (length args) 2) | |
474 (and (file-directory-p (car args)) | |
475 (or (not no-dereference) | |
476 (not (file-symlink-p (car args))))))) | |
477 (eshell-shorthand-tar-command ,command args) | |
478 (let ((target (car (last args))) | |
479 ange-cache) | |
480 (setcdr (last args 2) nil) | |
481 (eshell-shuffle-files | |
482 ,command ,action args target ,func nil | |
483 ,@(append | |
484 `((if (and (or interactive | |
485 ,query-var) | |
486 (not force)) | |
487 1 (or force ,force-var))) | |
488 (if preserve | |
489 (list preserve))))) | |
490 nil))) | |
29876 | 491 |
492 (defun eshell/mv (&rest args) | |
493 "Implementation of mv in Lisp." | |
494 (eshell-eval-using-options | |
495 "mv" args | |
496 '((?f "force" nil force | |
497 "remove existing destinations, never prompt") | |
498 (?i "interactive" nil interactive | |
499 "request confirmation if target already exists") | |
500 (?n "preview" nil preview | |
501 "don't change anything on disk") | |
502 (?v "verbose" nil verbose | |
503 "explain what is being done") | |
504 (nil "help" nil nil "show this usage screen") | |
33020 | 505 :preserve-args |
29876 | 506 :external "mv" |
507 :show-usage | |
508 :usage "[OPTION]... SOURCE DEST | |
509 or: mv [OPTION]... SOURCE... DIRECTORY | |
510 Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. | |
511 \[OPTION] DIRECTORY...") | |
512 (let ((no-dereference t)) | |
33020 | 513 (eshell-mvcpln-template "mv" "moving" 'rename-file |
514 eshell-mv-interactive-query | |
515 eshell-mv-overwrite-files)))) | |
29876 | 516 |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
517 (put 'eshell/mv 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
518 |
29876 | 519 (defun eshell/cp (&rest args) |
520 "Implementation of cp in Lisp." | |
521 (eshell-eval-using-options | |
522 "cp" args | |
523 '((?a "archive" nil archive | |
524 "same as -dpR") | |
525 (?d "no-dereference" nil no-dereference | |
526 "preserve links") | |
527 (?f "force" nil force | |
528 "remove existing destinations, never prompt") | |
529 (?i "interactive" nil interactive | |
530 "request confirmation if target already exists") | |
531 (?n "preview" nil preview | |
532 "don't change anything on disk") | |
533 (?p "preserve" nil preserve | |
534 "preserve file attributes if possible") | |
535 (?R "recursive" nil recursive | |
536 "copy directories recursively") | |
537 (?v "verbose" nil verbose | |
538 "explain what is being done") | |
539 (nil "help" nil nil "show this usage screen") | |
33020 | 540 :preserve-args |
29876 | 541 :external "cp" |
542 :show-usage | |
543 :usage "[OPTION]... SOURCE DEST | |
544 or: cp [OPTION]... SOURCE... DIRECTORY | |
545 Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.") | |
546 (if archive | |
547 (setq preserve t no-dereference t recursive t)) | |
33020 | 548 (eshell-mvcpln-template "cp" "copying" 'copy-file |
549 eshell-cp-interactive-query | |
550 eshell-cp-overwrite-files preserve))) | |
29876 | 551 |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
552 (put 'eshell/cp 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
553 |
29876 | 554 (defun eshell/ln (&rest args) |
555 "Implementation of ln in Lisp." | |
556 (eshell-eval-using-options | |
557 "ln" args | |
558 '((?h "help" nil nil "show this usage screen") | |
559 (?s "symbolic" nil symbolic | |
560 "make symbolic links instead of hard links") | |
33020 | 561 (?i "interactive" nil interactive |
562 "request confirmation if target already exists") | |
29876 | 563 (?f "force" nil force "remove existing destinations, never prompt") |
564 (?n "preview" nil preview | |
565 "don't change anything on disk") | |
566 (?v "verbose" nil verbose "explain what is being done") | |
33020 | 567 :preserve-args |
29876 | 568 :external "ln" |
569 :show-usage | |
570 :usage "[OPTION]... TARGET [LINK_NAME] | |
571 or: ln [OPTION]... TARGET... DIRECTORY | |
572 Create a link to the specified TARGET with optional LINK_NAME. If there is | |
573 more than one TARGET, the last argument must be a directory; create links | |
574 in DIRECTORY to each TARGET. Create hard links by default, symbolic links | |
575 with '--symbolic'. When creating hard links, each TARGET must exist.") | |
33020 | 576 (let ((no-dereference t)) |
577 (eshell-mvcpln-template "ln" "linking" | |
578 (if symbolic | |
579 'make-symbolic-link | |
580 'add-name-to-file) | |
581 eshell-ln-interactive-query | |
582 eshell-ln-overwrite-files)))) | |
29876 | 583 |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
584 (put 'eshell/ln 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
585 |
29876 | 586 (defun eshell/cat (&rest args) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
587 "Implementation of cat in Lisp. |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
588 If in a pipeline, or the file is not a regular file, directory or |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
589 symlink, then revert to the system's definition of cat." |
33020 | 590 (setq args (eshell-stringify-list (eshell-flatten-list args))) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
591 (if (or eshell-in-pipeline-p |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
592 (catch 'special |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
593 (eshell-for arg args |
39985
3a906538d254
(eshell/cat): Do a quick test if something is a regular file, before
John Wiegley <johnw@newartisans.com>
parents:
39293
diff
changeset
|
594 (unless (or (and (stringp arg) |
3a906538d254
(eshell/cat): Do a quick test if something is a regular file, before
John Wiegley <johnw@newartisans.com>
parents:
39293
diff
changeset
|
595 (> (length arg) 0) |
3a906538d254
(eshell/cat): Do a quick test if something is a regular file, before
John Wiegley <johnw@newartisans.com>
parents:
39293
diff
changeset
|
596 (eq (aref arg 0) ?-)) |
3a906538d254
(eshell/cat): Do a quick test if something is a regular file, before
John Wiegley <johnw@newartisans.com>
parents:
39293
diff
changeset
|
597 (let ((attrs (eshell-file-attributes arg))) |
3a906538d254
(eshell/cat): Do a quick test if something is a regular file, before
John Wiegley <johnw@newartisans.com>
parents:
39293
diff
changeset
|
598 (and attrs (memq (aref (nth 8 attrs) 0) |
3a906538d254
(eshell/cat): Do a quick test if something is a regular file, before
John Wiegley <johnw@newartisans.com>
parents:
39293
diff
changeset
|
599 '(?d ?l ?-))))) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
600 (throw 'special t))))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
601 (let ((ext-cat (eshell-search-path "cat"))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
602 (if ext-cat |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
603 (throw 'eshell-replace-command |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
604 (eshell-parse-command ext-cat args)) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
605 (if eshell-in-pipeline-p |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
606 (error "Eshell's `cat' does not work in pipelines") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
607 (error "Eshell's `cat' cannot display one of the files given")))) |
29876 | 608 (eshell-init-print-buffer) |
609 (eshell-eval-using-options | |
610 "cat" args | |
611 '((?h "help" nil nil "show this usage screen") | |
612 :external "cat" | |
613 :show-usage | |
614 :usage "[OPTION] FILE... | |
615 Concatenate FILE(s), or standard input, to standard output.") | |
616 (eshell-for file args | |
617 (if (string= file "-") | |
618 (throw 'eshell-external | |
619 (eshell-external-command "cat" args)))) | |
620 (let ((curbuf (current-buffer))) | |
621 (eshell-for file args | |
622 (with-temp-buffer | |
623 (insert-file-contents file) | |
624 (goto-char (point-min)) | |
625 (while (not (eobp)) | |
626 (let ((str (buffer-substring | |
627 (point) (min (1+ (line-end-position)) | |
628 (point-max))))) | |
629 (with-current-buffer curbuf | |
630 (eshell-buffered-print str))) | |
631 (forward-line))))) | |
632 (eshell-flush) | |
633 ;; if the file does not end in a newline, do not emit one | |
634 (setq eshell-ensure-newline-p nil)))) | |
635 | |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
636 (put 'eshell/cat 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
637 |
29876 | 638 ;; special front-end functions for compilation-mode buffers |
639 | |
640 (defun eshell/make (&rest args) | |
641 "Use `compile' to do background makes." | |
642 (if (and eshell-current-subjob-p | |
643 (eshell-interactive-output-p)) | |
644 (let ((compilation-process-setup-function | |
645 (list 'lambda nil | |
646 (list 'setq 'process-environment | |
647 (list 'quote (eshell-copy-environment)))))) | |
648 (compile (concat "make " (eshell-flatten-and-stringify args)))) | |
649 (throw 'eshell-replace-command | |
33020 | 650 (eshell-parse-command "*make" (eshell-stringify-list |
651 (eshell-flatten-list args)))))) | |
29876 | 652 |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
653 (put 'eshell/make 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
654 |
29876 | 655 (defun eshell-occur-mode-goto-occurrence () |
656 "Go to the occurrence the current line describes." | |
657 (interactive) | |
658 (let ((pos (occur-mode-find-occurrence))) | |
659 (pop-to-buffer (marker-buffer pos)) | |
660 (goto-char (marker-position pos)))) | |
661 | |
662 (defun eshell-occur-mode-mouse-goto (event) | |
663 "In Occur mode, go to the occurrence whose line you click on." | |
664 (interactive "e") | |
47597
8094bb2ffe5b
(eshell-occur-mode-mouse-goto, eshell-poor-mans-grep): Remove references to
Juanma Barranquero <lekktu@gmail.com>
parents:
45734
diff
changeset
|
665 (let (pos) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
666 (with-current-buffer (window-buffer (posn-window (event-end event))) |
29876 | 667 (save-excursion |
668 (goto-char (posn-point (event-end event))) | |
47597
8094bb2ffe5b
(eshell-occur-mode-mouse-goto, eshell-poor-mans-grep): Remove references to
Juanma Barranquero <lekktu@gmail.com>
parents:
45734
diff
changeset
|
669 (setq pos (occur-mode-find-occurrence)))) |
29876 | 670 (pop-to-buffer (marker-buffer pos)) |
671 (goto-char (marker-position pos)))) | |
672 | |
673 (defun eshell-poor-mans-grep (args) | |
674 "A poor version of grep that opens every file and uses `occur'. | |
675 This eats up memory, since it leaves the buffers open (to speed future | |
676 searches), and it's very slow. But, if your system has no grep | |
677 available..." | |
678 (save-selected-window | |
679 (let ((default-dir default-directory)) | |
680 (with-current-buffer (get-buffer-create "*grep*") | |
681 (let ((inhibit-read-only t) | |
682 (default-directory default-dir)) | |
683 (erase-buffer) | |
684 (occur-mode) | |
33020 | 685 (let ((files (eshell-stringify-list |
686 (eshell-flatten-list (cdr args)))) | |
29876 | 687 (inhibit-redisplay t) |
688 string) | |
689 (when (car args) | |
690 (if (get-buffer "*Occur*") | |
691 (kill-buffer (get-buffer "*Occur*"))) | |
692 (setq string nil) | |
693 (while files | |
694 (with-current-buffer (find-file-noselect (car files)) | |
695 (save-excursion | |
696 (ignore-errors | |
697 (occur (car args)))) | |
698 (if (get-buffer "*Occur*") | |
699 (with-current-buffer (get-buffer "*Occur*") | |
700 (setq string (buffer-string)) | |
701 (kill-buffer (current-buffer))))) | |
702 (if string (insert string)) | |
703 (setq string nil | |
704 files (cdr files))))) | |
705 (local-set-key [mouse-2] 'eshell-occur-mode-mouse-goto) | |
706 (local-set-key [(control ?c) (control ?c)] | |
707 'eshell-occur-mode-goto-occurrence) | |
708 (local-set-key [(control ?m)] | |
709 'eshell-occur-mode-goto-occurrence) | |
710 (local-set-key [return] 'eshell-occur-mode-goto-occurrence) | |
711 (pop-to-buffer (current-buffer) t) | |
712 (goto-char (point-min)) | |
713 (resize-temp-buffer-window)))))) | |
714 | |
715 (defun eshell-grep (command args &optional maybe-use-occur) | |
716 "Generic service function for the various grep aliases. | |
717 It calls Emacs' grep utility if the command is not redirecting output, | |
718 and if it's not part of a command pipeline. Otherwise, it calls the | |
719 external command." | |
720 (if (and maybe-use-occur eshell-no-grep-available) | |
721 (eshell-poor-mans-grep args) | |
722 (if (or eshell-plain-grep-behavior | |
723 (not (and (eshell-interactive-output-p) | |
724 (not eshell-in-pipeline-p) | |
725 (not eshell-in-subcommand-p)))) | |
726 (throw 'eshell-replace-command | |
31241 | 727 (eshell-parse-command (concat "*" command) |
33020 | 728 (eshell-stringify-list |
729 (eshell-flatten-list args)))) | |
57604
c72da3dd9a8d
(eshell-grep): Don't bind compilation-process-setup-function.
Richard M. Stallman <rms@gnu.org>
parents:
55195
diff
changeset
|
730 (let* ((args (mapconcat 'identity |
29876 | 731 (mapcar 'shell-quote-argument |
33020 | 732 (eshell-stringify-list |
733 (eshell-flatten-list args))) | |
29876 | 734 " ")) |
735 (cmd (progn | |
736 (set-text-properties 0 (length args) | |
737 '(invisible t) args) | |
738 (format "%s -n %s" command args))) | |
739 compilation-scroll-output) | |
740 (grep cmd))))) | |
741 | |
742 (defun eshell/grep (&rest args) | |
743 "Use Emacs grep facility instead of calling external grep." | |
744 (eshell-grep "grep" args t)) | |
745 | |
746 (defun eshell/egrep (&rest args) | |
747 "Use Emacs grep facility instead of calling external egrep." | |
748 (eshell-grep "egrep" args t)) | |
749 | |
750 (defun eshell/fgrep (&rest args) | |
751 "Use Emacs grep facility instead of calling external fgrep." | |
752 (eshell-grep "fgrep" args t)) | |
753 | |
754 (defun eshell/agrep (&rest args) | |
755 "Use Emacs grep facility instead of calling external agrep." | |
756 (eshell-grep "agrep" args)) | |
757 | |
758 (defun eshell/glimpse (&rest args) | |
759 "Use Emacs grep facility instead of calling external glimpse." | |
760 (let (null-device) | |
761 (eshell-grep "glimpse" (append '("-z" "-y") args)))) | |
762 | |
763 ;; completions rules for some common UNIX commands | |
764 | |
765 (defsubst eshell-complete-hostname () | |
766 "Complete a command that wants a hostname for an argument." | |
767 (pcomplete-here (eshell-read-host-names))) | |
768 | |
769 (defun eshell-complete-host-reference () | |
770 "If there is a host reference, complete it." | |
771 (let ((arg (pcomplete-actual-arg)) | |
772 index) | |
773 (when (setq index (string-match "@[a-z.]*\\'" arg)) | |
774 (setq pcomplete-stub (substring arg (1+ index)) | |
775 pcomplete-last-completion-raw t) | |
776 (throw 'pcomplete-completions (eshell-read-host-names))))) | |
777 | |
778 (defalias 'pcomplete/ftp 'eshell-complete-hostname) | |
779 (defalias 'pcomplete/ncftp 'eshell-complete-hostname) | |
780 (defalias 'pcomplete/ping 'eshell-complete-hostname) | |
781 (defalias 'pcomplete/rlogin 'eshell-complete-hostname) | |
782 | |
783 (defun pcomplete/telnet () | |
784 (require 'pcmpl-unix) | |
785 (pcomplete-opt "xl(pcmpl-unix-user-names)") | |
786 (eshell-complete-hostname)) | |
787 | |
788 (defun pcomplete/rsh () | |
789 "Complete `rsh', which, after the user and hostname, is like xargs." | |
790 (require 'pcmpl-unix) | |
791 (pcomplete-opt "l(pcmpl-unix-user-names)") | |
792 (eshell-complete-hostname) | |
793 (pcomplete-here (funcall pcomplete-command-completion-function)) | |
794 (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1)) | |
795 pcomplete-default-completion-function))) | |
796 | |
797 (defalias 'pcomplete/ssh 'pcomplete/rsh) | |
798 | |
95619
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
799 (defvar block-size) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
800 (defvar by-bytes) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
801 (defvar dereference-links) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
802 (defvar grand-total) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
803 (defvar human-readable) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
804 (defvar max-depth) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
805 (defvar only-one-filesystem) |
45dbb3c749a6
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95152
diff
changeset
|
806 (defvar show-all) |
29876 | 807 |
808 (defsubst eshell-du-size-string (size) | |
809 (let* ((str (eshell-printable-size size human-readable block-size t)) | |
810 (len (length str))) | |
811 (concat str (if (< len 8) | |
812 (make-string (- 8 len) ? ))))) | |
813 | |
814 (defun eshell-du-sum-directory (path depth) | |
815 "Summarize PATH, and its member directories." | |
816 (let ((entries (eshell-directory-files-and-attributes path)) | |
817 (size 0.0)) | |
818 (while entries | |
819 (unless (string-match "\\`\\.\\.?\\'" (caar entries)) | |
57742
7e9025771254
(eshell-du-sum-directory): Don't use directory-sep-char.
Richard M. Stallman <rms@gnu.org>
parents:
57604
diff
changeset
|
820 (let* ((entry (concat path "/" |
29876 | 821 (caar entries))) |
822 (symlink (and (stringp (cadr (car entries))) | |
823 (cadr (car entries))))) | |
824 (unless (or (and symlink (not dereference-links)) | |
825 (and only-one-filesystem | |
31241 | 826 (/= only-one-filesystem |
827 (nth 12 (car entries))))) | |
29876 | 828 (if symlink |
829 (setq entry symlink)) | |
830 (setq size | |
831 (+ size | |
832 (if (eq t (cadr (car entries))) | |
833 (eshell-du-sum-directory entry (1+ depth)) | |
834 (let ((file-size (nth 8 (car entries)))) | |
835 (prog1 | |
836 file-size | |
837 (if show-all | |
838 (eshell-print | |
839 (concat (eshell-du-size-string file-size) | |
840 entry "\n"))))))))))) | |
841 (setq entries (cdr entries))) | |
842 (if (or (not max-depth) | |
843 (= depth max-depth) | |
844 (= depth 0)) | |
845 (eshell-print (concat (eshell-du-size-string size) | |
846 (directory-file-name path) "\n"))) | |
847 size)) | |
848 | |
849 (defun eshell/du (&rest args) | |
31241 | 850 "Implementation of \"du\" in Lisp, passing ARGS." |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
851 (setq args (if args |
33020 | 852 (eshell-stringify-list (eshell-flatten-list args)) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
853 '("."))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
854 (let ((ext-du (eshell-search-path "du"))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
855 (if (and ext-du |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
856 (not (catch 'have-ange-path |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
857 (eshell-for arg args |
106219
16b061d2742d
Improve handling of processes on remote hosts.
Michael Albinus <michael.albinus@gmx.de>
parents:
105829
diff
changeset
|
858 (if (string-equal |
16b061d2742d
Improve handling of processes on remote hosts.
Michael Albinus <michael.albinus@gmx.de>
parents:
105829
diff
changeset
|
859 (file-remote-p (expand-file-name arg) 'method) "ftp") |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
860 (throw 'have-ange-path t)))))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
861 (throw 'eshell-replace-command |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
862 (eshell-parse-command ext-du args)) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
863 (eshell-eval-using-options |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
864 "du" args |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
865 '((?a "all" nil show-all |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
866 "write counts for all files, not just directories") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
867 (nil "block-size" t block-size |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
868 "use SIZE-byte blocks (i.e., --block-size SIZE)") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
869 (?b "bytes" nil by-bytes |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
870 "print size in bytes") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
871 (?c "total" nil grand-total |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
872 "produce a grand total") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
873 (?d "max-depth" t max-depth |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
874 "display data only this many levels of data") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
875 (?h "human-readable" 1024 human-readable |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
876 "print sizes in human readable format") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
877 (?H "is" 1000 human-readable |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
878 "likewise, but use powers of 1000 not 1024") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
879 (?k "kilobytes" 1024 block-size |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
880 "like --block-size 1024") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
881 (?L "dereference" nil dereference-links |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
882 "dereference all symbolic links") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
883 (?m "megabytes" 1048576 block-size |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
884 "like --block-size 1048576") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
885 (?s "summarize" 0 max-depth |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
886 "display only a total for each argument") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
887 (?x "one-file-system" nil only-one-filesystem |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
888 "skip directories on different filesystems") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
889 (nil "help" nil nil |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
890 "show this usage screen") |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
891 :external "du" |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
892 :usage "[OPTION]... FILE... |
29876 | 893 Summarize disk usage of each FILE, recursively for directories.") |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
894 (unless by-bytes |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
895 (setq block-size (or block-size 1024))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
896 (if (and max-depth (stringp max-depth)) |
62915
b89e30bcd2bb
Changed all uses of `directory-sep-char' to ?/, and all uses of
John Wiegley <johnw@newartisans.com>
parents:
57742
diff
changeset
|
897 (setq max-depth (string-to-number max-depth))) |
32446
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
898 ;; filesystem support means nothing under Windows |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
899 (if (eshell-under-windows-p) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
900 (setq only-one-filesystem nil)) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
901 (let ((size 0.0) 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
|
902 (while args |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
903 (if only-one-filesystem |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
904 (setq only-one-filesystem |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
905 (nth 11 (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
|
906 (file-name-as-directory (car args)))))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
907 (setq size (+ size (eshell-du-sum-directory |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
908 (directory-file-name (car args)) 0))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
909 (setq args (cdr args))) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
910 (if grand-total |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
911 (eshell-print (concat (eshell-du-size-string size) |
aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents:
31241
diff
changeset
|
912 "total\n")))))))) |
29876 | 913 |
914 (defvar eshell-time-start nil) | |
915 | |
916 (defun eshell-show-elapsed-time () | |
917 (let ((elapsed (format "%.3f secs\n" | |
918 (- (eshell-time-to-seconds (current-time)) | |
919 eshell-time-start)))) | |
920 (set-text-properties 0 (length elapsed) '(face bold) elapsed) | |
921 (eshell-interactive-print elapsed)) | |
922 (remove-hook 'eshell-post-command-hook 'eshell-show-elapsed-time t)) | |
923 | |
924 (defun eshell/time (&rest args) | |
925 "Implementation of \"time\" in Lisp." | |
926 (let ((time-args (copy-alist args)) | |
927 (continue t) | |
928 last-arg) | |
929 (while (and continue args) | |
930 (if (not (string-match "^-" (car args))) | |
931 (progn | |
932 (if last-arg | |
933 (setcdr last-arg nil) | |
934 (setq args '(""))) | |
935 (setq continue nil)) | |
936 (setq last-arg args | |
937 args (cdr args)))) | |
938 (eshell-eval-using-options | |
939 "time" args | |
940 '((?h "help" nil nil "show this usage screen") | |
941 :external "time" | |
942 :show-usage | |
943 :usage "COMMAND... | |
944 Show wall-clock time elapsed during execution of COMMAND.") | |
945 (setq eshell-time-start (eshell-time-to-seconds (current-time))) | |
946 (add-hook 'eshell-post-command-hook 'eshell-show-elapsed-time nil t) | |
947 ;; after setting | |
948 (throw 'eshell-replace-command | |
78715
eae42b4923bd
(eshell/time): Stringify and flatten the non-command arguments.
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
949 (eshell-parse-command (car time-args) |
eae42b4923bd
(eshell/time): Stringify and flatten the non-command arguments.
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
950 ;;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-08/msg00205.html |
eae42b4923bd
(eshell/time): Stringify and flatten the non-command arguments.
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
951 (eshell-stringify-list |
eae42b4923bd
(eshell/time): Stringify and flatten the non-command arguments.
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
952 (eshell-flatten-list (cdr time-args)))))))) |
29876 | 953 |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
954 (defun eshell/whoami (&rest args) |
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
955 "Make \"whoami\" Tramp aware." |
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
956 (or (file-remote-p default-directory 'user) (user-login-name))) |
29876 | 957 |
958 (defvar eshell-diff-window-config nil) | |
959 | |
960 (defun eshell-diff-quit () | |
961 "Restore the window configuration previous to diff'ing." | |
962 (interactive) | |
963 (if eshell-diff-window-config | |
964 (set-window-configuration eshell-diff-window-config))) | |
965 | |
85660
7dd9ef0af1e0
(nil-blank-string): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
85659
diff
changeset
|
966 (defun nil-blank-string (string) |
7dd9ef0af1e0
(nil-blank-string): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
85659
diff
changeset
|
967 "Return STRING, or nil if STRING contains only non-blank characters." |
85659
be317780de60
2007-10-26 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
85503
diff
changeset
|
968 (cond |
85660
7dd9ef0af1e0
(nil-blank-string): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
85659
diff
changeset
|
969 ((string-match "[^[:blank:]]" string) string) |
7dd9ef0af1e0
(nil-blank-string): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
85659
diff
changeset
|
970 (nil))) |
85659
be317780de60
2007-10-26 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
85503
diff
changeset
|
971 |
29876 | 972 (defun eshell/diff (&rest args) |
973 "Alias \"diff\" to call Emacs `diff' function." | |
33020 | 974 (let ((orig-args (eshell-stringify-list (eshell-flatten-list args)))) |
31241 | 975 (if (or eshell-plain-diff-behavior |
976 (not (and (eshell-interactive-output-p) | |
977 (not eshell-in-pipeline-p) | |
978 (not eshell-in-subcommand-p)))) | |
979 (throw 'eshell-replace-command | |
980 (eshell-parse-command "*diff" orig-args)) | |
45734
72f226ee8247
(eshell/diff): Use copy-sequence.
Richard M. Stallman <rms@gnu.org>
parents:
43334
diff
changeset
|
981 (setq args (copy-sequence orig-args)) |
31241 | 982 (if (< (length args) 2) |
983 (throw 'eshell-replace-command | |
984 (eshell-parse-command "*diff" orig-args))) | |
985 (let ((old (car (last args 2))) | |
986 (new (car (last args))) | |
987 (config (current-window-configuration))) | |
988 (if (= (length args) 2) | |
989 (setq args nil) | |
990 (setcdr (last args 3) nil)) | |
991 (with-current-buffer | |
992 (condition-case err | |
85659
be317780de60
2007-10-26 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
85503
diff
changeset
|
993 (diff old new |
be317780de60
2007-10-26 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
85503
diff
changeset
|
994 (nil-blank-string (eshell-flatten-and-stringify args))) |
31241 | 995 (error |
996 (throw 'eshell-replace-command | |
997 (eshell-parse-command "*diff" orig-args)))) | |
998 (when (fboundp 'diff-mode) | |
37441
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
999 (make-local-variable 'compilation-finish-functions) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1000 (add-hook |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1001 'compilation-finish-functions |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1002 `(lambda (buff msg) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1003 (with-current-buffer buff |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1004 (diff-mode) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1005 (set (make-local-variable 'eshell-diff-window-config) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1006 ,config) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1007 (local-set-key [?q] 'eshell-diff-quit) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1008 (if (fboundp 'turn-on-font-lock-if-enabled) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1009 (turn-on-font-lock-if-enabled)) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1010 (goto-char (point-min)))))) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1011 (pop-to-buffer (current-buffer)))))) |
565e55bc8630
(eshell/diff): Fixed problems that were occurring with Emacs 21's
John Wiegley <johnw@newartisans.com>
parents:
35588
diff
changeset
|
1012 nil) |
29876 | 1013 |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
1014 (put 'eshell/diff 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
1015 |
29876 | 1016 (defun eshell/locate (&rest args) |
1017 "Alias \"locate\" to call Emacs `locate' function." | |
1018 (if (or eshell-plain-locate-behavior | |
1019 (not (and (eshell-interactive-output-p) | |
1020 (not eshell-in-pipeline-p) | |
1021 (not eshell-in-subcommand-p))) | |
1022 (and (stringp (car args)) | |
1023 (string-match "^-" (car args)))) | |
1024 (throw 'eshell-replace-command | |
33020 | 1025 (eshell-parse-command "*locate" (eshell-stringify-list |
1026 (eshell-flatten-list args)))) | |
29876 | 1027 (save-selected-window |
1028 (let ((locate-history-list (list (car args)))) | |
1029 (locate-with-filter (car args) (cadr args)))))) | |
1030 | |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
1031 (put 'eshell/locate 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
1032 |
29876 | 1033 (defun eshell/occur (&rest args) |
1034 "Alias \"occur\" to call Emacs `occur' function." | |
1035 (let ((inhibit-read-only t)) | |
35588 | 1036 (if (> (length args) 2) |
1037 (error "usage: occur: (REGEXP &optional NLINES)") | |
1038 (apply 'occur args)))) | |
29876 | 1039 |
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
1040 (put 'eshell/occur 'eshell-no-numeric-conversions t) |
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
37655
diff
changeset
|
1041 |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1042 ;; Pacify the byte-compiler. |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1043 (defvar tramp-default-proxies-alist) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1044 |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1045 (defun eshell/su (&rest args) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1046 "Alias \"su\" to call Tramp." |
106390 | 1047 (require 'tramp) |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1048 (setq args (eshell-stringify-list (eshell-flatten-list args))) |
106390 | 1049 (let ((orig-args (copy-tree args))) |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1050 (eshell-eval-using-options |
106390 | 1051 "su" args |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1052 '((?h "help" nil nil "show this usage screen") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1053 (?l "login" nil login "provide a login environment") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1054 (? nil nil login "provide a login environment") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1055 :usage "[- | -l | --login] [USER] |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1056 Become another USER during a login session.") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1057 (throw 'eshell-replace-command |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1058 (let ((user "root") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1059 (host (or (file-remote-p default-directory 'host) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1060 "localhost")) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1061 (dir (or (file-remote-p default-directory 'localname) |
106390 | 1062 (expand-file-name default-directory)))) |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1063 (eshell-for arg args |
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1064 (if (string-equal arg "-") (setq login t) (setq user arg))) |
106390 | 1065 ;; `eshell-eval-using-options' does not handle "-". |
1066 (if (member "-" orig-args) (setq login t)) | |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1067 (if login (setq dir "~/")) |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1068 (if (and (file-remote-p default-directory) |
106390 | 1069 (or |
1070 (not (string-equal | |
1071 "su" (file-remote-p default-directory 'method))) | |
1072 (not (string-equal | |
1073 user (file-remote-p default-directory 'user))))) | |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1074 (add-to-list |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1075 'tramp-default-proxies-alist |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1076 (list host user (file-remote-p default-directory)))) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1077 (eshell-parse-command |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1078 "cd" (list (format "/su:%s@%s:%s" user host dir)))))))) |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1079 |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1080 (put 'eshell/su 'eshell-no-numeric-conversions t) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1081 |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1082 (defun eshell/sudo (&rest args) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1083 "Alias \"sudo\" to call Tramp." |
106390 | 1084 (require 'tramp) |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1085 (setq args (eshell-stringify-list (eshell-flatten-list args))) |
106390 | 1086 (let ((orig-args (copy-tree args))) |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1087 (eshell-eval-using-options |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1088 "sudo" args |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1089 '((?h "help" nil nil "show this usage screen") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1090 (?u "user" t user "execute a command as another USER") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1091 :show-usage |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1092 :usage "[(-u | --user) USER] COMMAND |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1093 Execute a COMMAND as the superuser or another USER.") |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1094 (throw 'eshell-external |
106390 | 1095 (let ((user (or user "root")) |
1096 (host (or (file-remote-p default-directory 'host) | |
1097 "localhost")) | |
1098 (dir (or (file-remote-p default-directory 'localname) | |
1099 (expand-file-name default-directory)))) | |
1100 ;; `eshell-eval-using-options' reads options of COMMAND. | |
1101 (while (and (stringp (car orig-args)) | |
1102 (member (car orig-args) '("-u" "--user"))) | |
1103 (setq orig-args (cddr orig-args))) | |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1104 (if (and (file-remote-p default-directory) |
106390 | 1105 (or |
1106 (not (string-equal | |
1107 "sudo" (file-remote-p default-directory 'method))) | |
1108 (not (string-equal | |
1109 user (file-remote-p default-directory 'user))))) | |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1110 (add-to-list |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1111 'tramp-default-proxies-alist |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1112 (list host user (file-remote-p default-directory)))) |
106311
12c2a6b10caf
* eshell/em-unix (eshell/whoami): Make it a defun but a defalias.
Michael Albinus <michael.albinus@gmx.de>
parents:
106286
diff
changeset
|
1113 (let ((default-directory (format "/sudo:%s@%s:%s" user host dir))) |
106390 | 1114 (eshell-named-command (car orig-args) (cdr orig-args)))))))) |
106286
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1115 |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1116 (put 'eshell/sudo 'eshell-no-numeric-conversions t) |
69ba8f3430e1
* eshell/em-unix.el (eshell/su, eshell/sudo): New defuns,
Michael Albinus <michael.albinus@gmx.de>
parents:
106219
diff
changeset
|
1117 |
87076
9b97b187c7e2
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
86202
diff
changeset
|
1118 (provide 'em-unix) |
29876 | 1119 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
1120 ;; Local Variables: |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
1121 ;; generated-autoload-file: "esh-groups.el" |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
1122 ;; End: |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
1123 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
1124 ;; arch-tag: 2462edd2-a76a-4cf2-897d-92e9a82ac1c9 |
29876 | 1125 ;;; em-unix.el ends here |