summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/em-cmpl.el2
-rw-r--r--lisp/eshell/em-ls.el22
-rw-r--r--lisp/eshell/em-tramp.el143
-rw-r--r--lisp/eshell/em-unix.el84
-rw-r--r--lisp/eshell/esh-proc.el67
-rw-r--r--lisp/eshell/esh-util.el1
6 files changed, 195 insertions, 124 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index 8520a9c83d2..91311deffcf 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -63,7 +63,7 @@
;; The list of possible completions can be viewed at any point by
;; pressing <M-?>.
;;
-;; Finally, context-related help can be accessed by pressing <C-c i>.
+;; Finally, context-related help can be accessed by pressing <C-c M-h>.
;; This only works well if the completion function has provided Eshell
;; with sufficient pointers to locate the relevant help text.
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index eec932103ee..73ed617b871 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -26,9 +26,8 @@
;;; Code:
-(eval-when-compile
- (require 'cl-lib)
- (require 'eshell))
+(eval-when-compile (require 'eshell))
+(require 'cl-lib)
(require 'esh-util)
(require 'esh-opt)
@@ -328,6 +327,7 @@ instead."
(defvar numeric-uid-gid)
(defvar reverse-list)
(defvar show-all)
+(defvar show-almost-all)
(defvar show-recursive)
(defvar show-size)
(defvar sort-method)
@@ -337,13 +337,15 @@ instead."
(defun eshell-do-ls (&rest args)
"Implementation of \"ls\" in Lisp, passing ARGS."
(funcall flush-func -1)
- ;; process the command arguments, and begin listing files
+ ;; Process the command arguments, and begin listing files.
(eshell-eval-using-options
"ls" (if eshell-ls-initial-args
(list eshell-ls-initial-args args)
args)
`((?a "all" nil show-all
- "show all files in directory")
+ "do not ignore entries starting with .")
+ (?A "almost-all" nil show-almost-all
+ "do not list implied . and ..")
(?c nil by-ctime sort-method
"sort by last status change time")
(?d "directory" nil dir-literal
@@ -558,7 +560,15 @@ relative to that directory."
;; later when we are going to
;; display user and group names.
(if numeric-uid-gid 'integer 'string))))
- (when (and (not show-all) eshell-ls-exclude-regexp)
+ (when (and show-almost-all
+ (not show-all))
+ (setq entries
+ (cl-remove-if
+ (lambda (entry)
+ (member (caar entry) '("." "..")))
+ entries)))
+ (when (and (not show-all)
+ eshell-ls-exclude-regexp)
(while (and entries (string-match eshell-ls-exclude-regexp
(caar entries)))
(setq entries (cdr entries)))
diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el
new file mode 100644
index 00000000000..c60d0e6395f
--- /dev/null
+++ b/lisp/eshell/em-tramp.el
@@ -0,0 +1,143 @@
+;;; em-tramp.el --- Eshell features that require TRAMP
+
+;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
+
+;; Author: Aidan Gauland <aidalgol@no8wireless.co.nz>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Eshell features that require TRAMP.
+
+;;; Code:
+
+(eval-when-compile
+ (require 'esh-mode)
+ (require 'eshell)
+ (require 'tramp))
+
+(require 'esh-util)
+
+;;;###autoload
+(progn
+ (defgroup eshell-tramp nil
+ "This module defines commands that use TRAMP in a way that is
+ not transparent to the user. So far, this includes only the
+ built-in su and sudo commands, which are not compatible with
+ the full, external su and sudo commands, and require the user
+ to understand how to use the TRAMP sudo method."
+ :tag "TRAMP Eshell features"
+ :group 'eshell-module))
+
+(defun eshell-tramp-initialize ()
+ "Initialize the TRAMP-using commands code."
+ (when (eshell-using-module 'eshell-cmpl)
+ (add-hook 'pcomplete-try-first-hook
+ 'eshell-complete-host-reference nil t))
+ (make-local-variable 'eshell-complex-commands)
+ (setq eshell-complex-commands
+ (append '("su" "sudo")
+ eshell-complex-commands)))
+
+(defun eshell/su (&rest args)
+ "Alias \"su\" to call TRAMP.
+
+Uses the system su through TRAMP's su method."
+ (setq args (eshell-stringify-list (eshell-flatten-list args)))
+ (let ((orig-args (copy-tree args)))
+ (eshell-eval-using-options
+ "su" args
+ '((?h "help" nil nil "show this usage screen")
+ (?l "login" nil login "provide a login environment")
+ (? nil nil login "provide a login environment")
+ :usage "[- | -l | --login] [USER]
+Become another USER during a login session.")
+ (throw 'eshell-replace-command
+ (let ((user "root")
+ (host (or (file-remote-p default-directory 'host)
+ "localhost"))
+ (dir (or (file-remote-p default-directory 'localname)
+ (expand-file-name default-directory)))
+ (prefix (file-remote-p default-directory)))
+ (dolist (arg args)
+ (if (string-equal arg "-") (setq login t) (setq user arg)))
+ ;; `eshell-eval-using-options' does not handle "-".
+ (if (member "-" orig-args) (setq login t))
+ (if login (setq dir "~/"))
+ (if (and prefix
+ (or
+ (not (string-equal
+ "su" (file-remote-p default-directory 'method)))
+ (not (string-equal
+ user (file-remote-p default-directory 'user)))))
+ (eshell-parse-command
+ "cd" (list (format "%s|su:%s@%s:%s"
+ (substring prefix 0 -1) user host dir)))
+ (eshell-parse-command
+ "cd" (list (format "/su:%s@%s:%s" user host dir)))))))))
+
+(put 'eshell/su 'eshell-no-numeric-conversions t)
+
+(defun eshell/sudo (&rest args)
+ "Alias \"sudo\" to call Tramp.
+
+Uses the system sudo through TRAMP's sudo method."
+ (setq args (eshell-stringify-list (eshell-flatten-list args)))
+ (let ((orig-args (copy-tree args)))
+ (eshell-eval-using-options
+ "sudo" args
+ '((?h "help" nil nil "show this usage screen")
+ (?u "user" t user "execute a command as another USER")
+ :show-usage
+ :usage "[(-u | --user) USER] COMMAND
+Execute a COMMAND as the superuser or another USER.")
+ (throw 'eshell-external
+ (let ((user (or user "root"))
+ (host (or (file-remote-p default-directory 'host)
+ "localhost"))
+ (dir (or (file-remote-p default-directory 'localname)
+ (expand-file-name default-directory)))
+ (prefix (file-remote-p default-directory)))
+ ;; `eshell-eval-using-options' reads options of COMMAND.
+ (while (and (stringp (car orig-args))
+ (member (car orig-args) '("-u" "--user")))
+ (setq orig-args (cddr orig-args)))
+ (let ((default-directory
+ (if (and prefix
+ (or
+ (not
+ (string-equal
+ "sudo"
+ (file-remote-p default-directory 'method)))
+ (not
+ (string-equal
+ user
+ (file-remote-p default-directory 'user)))))
+ (format "%s|sudo:%s@%s:%s"
+ (substring prefix 0 -1) user host dir)
+ (format "/sudo:%s@%s:%s" user host dir))))
+ (eshell-named-command (car orig-args) (cdr orig-args))))))))
+
+(put 'eshell/sudo 'eshell-no-numeric-conversions t)
+
+(provide 'em-tramp)
+
+;; Local Variables:
+;; generated-autoload-file: "esh-groups.el"
+;; End:
+
+;;; em-tramp.el ends here
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index b387a8ba974..60caf38710a 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -148,7 +148,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
(make-local-variable 'eshell-complex-commands)
(setq eshell-complex-commands
(append '("grep" "egrep" "fgrep" "agrep" "glimpse" "locate"
- "cat" "time" "cp" "mv" "make" "du" "diff" "su" "sudo")
+ "cat" "time" "cp" "mv" "make" "du" "diff")
eshell-complex-commands)))
(defalias 'eshell/date 'current-time-string)
@@ -306,12 +306,13 @@ Remove (unlink) the FILE(s).")
(eshell-eval-using-options
"mkdir" args
'((?h "help" nil nil "show this usage screen")
+ (?p "parents" nil em-parents "make parent directories as needed")
:external "mkdir"
:show-usage
:usage "[OPTION] DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.")
(while args
- (eshell-funcalln 'make-directory (car args))
+ (eshell-funcalln 'make-directory (car args) em-parents)
(setq args (cdr args)))
nil))
@@ -1037,85 +1038,6 @@ Show wall-clock time elapsed during execution of COMMAND.")
(put 'eshell/occur 'eshell-no-numeric-conversions t)
-(defun eshell/su (&rest args)
- "Alias \"su\" to call Tramp."
- (require 'tramp)
- (setq args (eshell-stringify-list (eshell-flatten-list args)))
- (let ((orig-args (copy-tree args)))
- (eshell-eval-using-options
- "su" args
- '((?h "help" nil nil "show this usage screen")
- (?l "login" nil login "provide a login environment")
- (? nil nil login "provide a login environment")
- :usage "[- | -l | --login] [USER]
-Become another USER during a login session.")
- (throw 'eshell-replace-command
- (let ((user "root")
- (host (or (file-remote-p default-directory 'host)
- "localhost"))
- (dir (or (file-remote-p default-directory 'localname)
- (expand-file-name default-directory)))
- (prefix (file-remote-p default-directory)))
- (dolist (arg args)
- (if (string-equal arg "-") (setq login t) (setq user arg)))
- ;; `eshell-eval-using-options' does not handle "-".
- (if (member "-" orig-args) (setq login t))
- (if login (setq dir "~/"))
- (if (and prefix
- (or
- (not (string-equal
- "su" (file-remote-p default-directory 'method)))
- (not (string-equal
- user (file-remote-p default-directory 'user)))))
- (eshell-parse-command
- "cd" (list (format "%s|su:%s@%s:%s"
- (substring prefix 0 -1) user host dir)))
- (eshell-parse-command
- "cd" (list (format "/su:%s@%s:%s" user host dir)))))))))
-
-(put 'eshell/su 'eshell-no-numeric-conversions t)
-
-(defun eshell/sudo (&rest args)
- "Alias \"sudo\" to call Tramp."
- (require 'tramp)
- (setq args (eshell-stringify-list (eshell-flatten-list args)))
- (let ((orig-args (copy-tree args)))
- (eshell-eval-using-options
- "sudo" args
- '((?h "help" nil nil "show this usage screen")
- (?u "user" t user "execute a command as another USER")
- :show-usage
- :usage "[(-u | --user) USER] COMMAND
-Execute a COMMAND as the superuser or another USER.")
- (throw 'eshell-external
- (let ((user (or user "root"))
- (host (or (file-remote-p default-directory 'host)
- "localhost"))
- (dir (or (file-remote-p default-directory 'localname)
- (expand-file-name default-directory)))
- (prefix (file-remote-p default-directory)))
- ;; `eshell-eval-using-options' reads options of COMMAND.
- (while (and (stringp (car orig-args))
- (member (car orig-args) '("-u" "--user")))
- (setq orig-args (cddr orig-args)))
- (let ((default-directory
- (if (and prefix
- (or
- (not
- (string-equal
- "sudo"
- (file-remote-p default-directory 'method)))
- (not
- (string-equal
- user
- (file-remote-p default-directory 'user)))))
- (format "%s|sudo:%s@%s:%s"
- (substring prefix 0 -1) user host dir)
- (format "/sudo:%s@%s:%s" user host dir))))
- (eshell-named-command (car orig-args) (cdr orig-args))))))))
-
-(put 'eshell/sudo 'eshell-no-numeric-conversions t)
-
(provide 'em-unix)
;; Local Variables:
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 406822367d1..aa630dc87aa 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -165,43 +165,38 @@ The signals which will cause this to happen are matched by
(list-processes)))
(defun eshell/kill (&rest args)
- "Kill processes, buffers, symbol or files."
- (let ((ptr args)
- (signum 'SIGINT))
- (while ptr
- (if (or (eshell-processp (car ptr))
- (and (stringp (car ptr))
- (string-match "^[A-Za-z/][A-Za-z0-9<>/]+$"
- (car ptr))))
- ;; What about when $lisp-variable is possible here?
- ;; It could very well name a process.
- (setcar ptr (get-process (car ptr))))
- (setq ptr (cdr ptr)))
+ "Kill processes.
+Usage: kill [-<signal>] <pid>|<process> ...
+Accepts PIDs and process objects."
+ ;; If the first argument starts with a dash, treat it as the signal
+ ;; specifier.
+ (let ((signum 'SIGINT))
+ (let ((arg (car args))
+ (case-fold-search nil))
+ (when (stringp arg)
+ (cond
+ ((string-match "\\`-[[:digit:]]+\\'" arg)
+ (setq signum (abs (string-to-number arg))))
+ ((string-match "\\`-\\([[:upper:]]+\\|[[:lower:]]+\\)\\'" arg)
+ (setq signum (abs (string-to-number arg)))))
+ (setq args (cdr args))))
(while args
- (let ((id (if (eshell-processp (car args))
- (process-id (car args))
- (car args))))
- (when id
- (cond
- ((null id)
- (error "kill: bad signal spec"))
- ((and (numberp id) (= id 0))
- (error "kill: bad signal spec `%d'" id))
- ((and (stringp id)
- (string-match "^-?[0-9]+$" id))
- (setq signum (abs (string-to-number id))))
- ((stringp id)
- (let (case-fold-search)
- (if (string-match "^-\\([A-Z]+[12]?\\)$" id)
- (setq signum
- (intern (concat "SIG" (match-string 1 id))))
- (error "kill: bad signal spec `%s'" id))))
- ((< id 0)
- (setq signum (abs id)))
- (t
- (signal-process id signum)))))
- (setq args (cdr args)))
- nil))
+ (let ((arg (if (eshell-processp (car args))
+ (process-id (car args))
+ (car args))))
+ (when arg
+ (cond
+ ((null arg)
+ (error "kill: null pid. Process may actually be a network connection."))
+ ((not (numberp arg))
+ (error "kill: invalid argument type: %s" (type-of arg)))
+ ((and (numberp arg)
+ (<= arg 0))
+ (error "kill: bad pid: %d" arg))
+ (t
+ (signal-process arg signum)))))
+ (setq args (cdr args))))
+ nil)
(defun eshell-read-process-name (prompt)
"Read the name of a process from the minibuffer, using completion.
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 2f49a21e76c..f9b86219e9b 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -229,6 +229,7 @@ If N or M is nil, it means the end of the list."
"Content of $PATH.
It might be different from \(getenv \"PATH\"\), when
`default-directory' points to a remote host.")
+(make-variable-buffer-local 'eshell-path-env)
(defun eshell-parse-colon-path (path-env)
"Split string with `parse-colon-path'.