diff options
| author | Michael Albinus | 2009-12-03 11:34:11 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-12-03 11:34:11 +0000 |
| commit | a09dc9bf9c3c40638d3fe6bf1905de05d7dac6fb (patch) | |
| tree | 8f271dddbc5629879fa1e0c6aa4dfb84dbaef5ab | |
| parent | 228fb9b59ea7328f34c799835ae6dd9310a49f25 (diff) | |
| download | emacs-a09dc9bf9c3c40638d3fe6bf1905de05d7dac6fb.tar.gz emacs-a09dc9bf9c3c40638d3fe6bf1905de05d7dac6fb.zip | |
Cleanup.
* eshell/em-unix.el (top): Require 'esh-opt and 'pcomplete.
(eshell/su, eshell/sudo): Require 'tramp. Fix problems reading
arguments. Expand `default-directory'.
* net/tramp.el (tramp-handle-file-remote-p): Expand FILENAME for
the benefit of returning an expanded localname.
(tramp-tramp-file-p): Handle the case NAME is not a string.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/eshell/em-unix.el | 44 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 6 |
3 files changed, 44 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 73e4706853a..6703d907753 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2009-12-03 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | Cleanup. | ||
| 4 | * eshell/em-unix.el (top): Require 'esh-opt and 'pcomplete. | ||
| 5 | (eshell/su, eshell/sudo): Require 'tramp. Fix problems reading | ||
| 6 | arguments. Expand `default-directory'. | ||
| 7 | |||
| 8 | * net/tramp.el (tramp-handle-file-remote-p): Expand FILENAME for | ||
| 9 | the benefit of returning an expanded localname. | ||
| 10 | (tramp-tramp-file-p): Handle the case NAME is not a string. | ||
| 11 | |||
| 1 | 2009-12-03 Dan Nicolaescu <dann@ics.uci.edu> | 12 | 2009-12-03 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 13 | ||
| 3 | Add support for bzr shelve/unshelve. | 14 | Add support for bzr shelve/unshelve. |
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el index dfd72f6b2ac..7de13d0b8ac 100644 --- a/lisp/eshell/em-unix.el +++ b/lisp/eshell/em-unix.el | |||
| @@ -37,6 +37,8 @@ | |||
| 37 | ;;; Code: | 37 | ;;; Code: |
| 38 | 38 | ||
| 39 | (require 'eshell) | 39 | (require 'eshell) |
| 40 | (require 'esh-opt) | ||
| 41 | (require 'pcomplete) | ||
| 40 | 42 | ||
| 41 | ;;;###autoload | 43 | ;;;###autoload |
| 42 | (eshell-defgroup eshell-unix nil | 44 | (eshell-defgroup eshell-unix nil |
| @@ -1048,10 +1050,11 @@ Show wall-clock time elapsed during execution of COMMAND.") | |||
| 1048 | 1050 | ||
| 1049 | (defun eshell/su (&rest args) | 1051 | (defun eshell/su (&rest args) |
| 1050 | "Alias \"su\" to call Tramp." | 1052 | "Alias \"su\" to call Tramp." |
| 1053 | (require 'tramp) | ||
| 1051 | (setq args (eshell-stringify-list (eshell-flatten-list args))) | 1054 | (setq args (eshell-stringify-list (eshell-flatten-list args))) |
| 1052 | (let (login) | 1055 | (let ((orig-args (copy-tree args))) |
| 1053 | (eshell-eval-using-options | 1056 | (eshell-eval-using-options |
| 1054 | "sudo" args | 1057 | "su" args |
| 1055 | '((?h "help" nil nil "show this usage screen") | 1058 | '((?h "help" nil nil "show this usage screen") |
| 1056 | (?l "login" nil login "provide a login environment") | 1059 | (?l "login" nil login "provide a login environment") |
| 1057 | (? nil nil login "provide a login environment") | 1060 | (? nil nil login "provide a login environment") |
| @@ -1062,13 +1065,18 @@ Become another USER during a login session.") | |||
| 1062 | (host (or (file-remote-p default-directory 'host) | 1065 | (host (or (file-remote-p default-directory 'host) |
| 1063 | "localhost")) | 1066 | "localhost")) |
| 1064 | (dir (or (file-remote-p default-directory 'localname) | 1067 | (dir (or (file-remote-p default-directory 'localname) |
| 1065 | default-directory))) | 1068 | (expand-file-name default-directory)))) |
| 1066 | (eshell-for arg args | 1069 | (eshell-for arg args |
| 1067 | (if (string-equal arg "-") (setq login t) (setq user arg))) | 1070 | (if (string-equal arg "-") (setq login t) (setq user arg))) |
| 1071 | ;; `eshell-eval-using-options' does not handle "-". | ||
| 1072 | (if (member "-" orig-args) (setq login t)) | ||
| 1068 | (if login (setq dir "~/")) | 1073 | (if login (setq dir "~/")) |
| 1069 | (if (and (file-remote-p default-directory) | 1074 | (if (and (file-remote-p default-directory) |
| 1070 | (not (string-equal | 1075 | (or |
| 1071 | user (file-remote-p default-directory 'user)))) | 1076 | (not (string-equal |
| 1077 | "su" (file-remote-p default-directory 'method))) | ||
| 1078 | (not (string-equal | ||
| 1079 | user (file-remote-p default-directory 'user))))) | ||
| 1072 | (add-to-list | 1080 | (add-to-list |
| 1073 | 'tramp-default-proxies-alist | 1081 | 'tramp-default-proxies-alist |
| 1074 | (list host user (file-remote-p default-directory)))) | 1082 | (list host user (file-remote-p default-directory)))) |
| @@ -1079,8 +1087,9 @@ Become another USER during a login session.") | |||
| 1079 | 1087 | ||
| 1080 | (defun eshell/sudo (&rest args) | 1088 | (defun eshell/sudo (&rest args) |
| 1081 | "Alias \"sudo\" to call Tramp." | 1089 | "Alias \"sudo\" to call Tramp." |
| 1090 | (require 'tramp) | ||
| 1082 | (setq args (eshell-stringify-list (eshell-flatten-list args))) | 1091 | (setq args (eshell-stringify-list (eshell-flatten-list args))) |
| 1083 | (let (user) | 1092 | (let ((orig-args (copy-tree args))) |
| 1084 | (eshell-eval-using-options | 1093 | (eshell-eval-using-options |
| 1085 | "sudo" args | 1094 | "sudo" args |
| 1086 | '((?h "help" nil nil "show this usage screen") | 1095 | '((?h "help" nil nil "show this usage screen") |
| @@ -1089,19 +1098,26 @@ Become another USER during a login session.") | |||
| 1089 | :usage "[(-u | --user) USER] COMMAND | 1098 | :usage "[(-u | --user) USER] COMMAND |
| 1090 | Execute a COMMAND as the superuser or another USER.") | 1099 | Execute a COMMAND as the superuser or another USER.") |
| 1091 | (throw 'eshell-external | 1100 | (throw 'eshell-external |
| 1092 | (let* ((user (or user "root")) | 1101 | (let ((user (or user "root")) |
| 1093 | (host (or (file-remote-p default-directory 'host) | 1102 | (host (or (file-remote-p default-directory 'host) |
| 1094 | "localhost")) | 1103 | "localhost")) |
| 1095 | (dir (or (file-remote-p default-directory 'localname) | 1104 | (dir (or (file-remote-p default-directory 'localname) |
| 1096 | default-directory))) | 1105 | (expand-file-name default-directory)))) |
| 1106 | ;; `eshell-eval-using-options' reads options of COMMAND. | ||
| 1107 | (while (and (stringp (car orig-args)) | ||
| 1108 | (member (car orig-args) '("-u" "--user"))) | ||
| 1109 | (setq orig-args (cddr orig-args))) | ||
| 1097 | (if (and (file-remote-p default-directory) | 1110 | (if (and (file-remote-p default-directory) |
| 1098 | (not (string-equal | 1111 | (or |
| 1099 | user (file-remote-p default-directory 'user)))) | 1112 | (not (string-equal |
| 1113 | "sudo" (file-remote-p default-directory 'method))) | ||
| 1114 | (not (string-equal | ||
| 1115 | user (file-remote-p default-directory 'user))))) | ||
| 1100 | (add-to-list | 1116 | (add-to-list |
| 1101 | 'tramp-default-proxies-alist | 1117 | 'tramp-default-proxies-alist |
| 1102 | (list host user (file-remote-p default-directory)))) | 1118 | (list host user (file-remote-p default-directory)))) |
| 1103 | (let ((default-directory (format "/sudo:%s@%s:%s" user host dir))) | 1119 | (let ((default-directory (format "/sudo:%s@%s:%s" user host dir))) |
| 1104 | (eshell-named-command (car args) (cdr args)))))))) | 1120 | (eshell-named-command (car orig-args) (cdr orig-args)))))))) |
| 1105 | 1121 | ||
| 1106 | (put 'eshell/sudo 'eshell-no-numeric-conversions t) | 1122 | (put 'eshell/sudo 'eshell-no-numeric-conversions t) |
| 1107 | 1123 | ||
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 678c8cc22e0..f3297ed13f5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -4629,7 +4629,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4629 | (defun tramp-handle-file-remote-p (filename &optional identification connected) | 4629 | (defun tramp-handle-file-remote-p (filename &optional identification connected) |
| 4630 | "Like `file-remote-p' for Tramp files." | 4630 | "Like `file-remote-p' for Tramp files." |
| 4631 | (when (tramp-tramp-file-p filename) | 4631 | (when (tramp-tramp-file-p filename) |
| 4632 | (with-parsed-tramp-file-name filename nil | 4632 | (with-parsed-tramp-file-name (expand-file-name filename) nil |
| 4633 | (and (or (not connected) | 4633 | (and (or (not connected) |
| 4634 | (let ((p (tramp-get-connection-process v))) | 4634 | (let ((p (tramp-get-connection-process v))) |
| 4635 | (and p (processp p) (memq (process-status p) '(run open))))) | 4635 | (and p (processp p) (memq (process-status p) '(run open))))) |
| @@ -7709,9 +7709,9 @@ Not actually used. Use `(format \"%o\" i)' instead?" | |||
| 7709 | (string-to-number (match-string 2 host)))))) | 7709 | (string-to-number (match-string 2 host)))))) |
| 7710 | 7710 | ||
| 7711 | (defun tramp-tramp-file-p (name) | 7711 | (defun tramp-tramp-file-p (name) |
| 7712 | "Return t if NAME is a Tramp file." | 7712 | "Return t if NAME is a string with Tramp file name syntax." |
| 7713 | (save-match-data | 7713 | (save-match-data |
| 7714 | (string-match tramp-file-name-regexp name))) | 7714 | (and (stringp name) (string-match tramp-file-name-regexp name)))) |
| 7715 | 7715 | ||
| 7716 | (defun tramp-find-method (method user host) | 7716 | (defun tramp-find-method (method user host) |
| 7717 | "Return the right method string to use. | 7717 | "Return the right method string to use. |