diff options
| -rw-r--r-- | lisp/eshell/esh-cmd.el | 89 |
1 files changed, 46 insertions, 43 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 8738ceb39b6..247d6c74604 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el | |||
| @@ -22,18 +22,6 @@ | |||
| 22 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 22 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 23 | ;; Boston, MA 02110-1301, USA. | 23 | ;; Boston, MA 02110-1301, USA. |
| 24 | 24 | ||
| 25 | (provide 'esh-cmd) | ||
| 26 | |||
| 27 | (eval-when-compile (require 'esh-maint)) | ||
| 28 | |||
| 29 | (defgroup eshell-cmd nil | ||
| 30 | "Executing an Eshell command is as simple as typing it in and | ||
| 31 | pressing <RET>. There are several different kinds of commands, | ||
| 32 | however." | ||
| 33 | :tag "Command invocation" | ||
| 34 | ;; :link '(info-link "(eshell)Command invocation") | ||
| 35 | :group 'eshell) | ||
| 36 | |||
| 37 | ;;; Commentary: | 25 | ;;; Commentary: |
| 38 | 26 | ||
| 39 | ;;;_* Invoking external commands | 27 | ;;;_* Invoking external commands |
| @@ -64,11 +52,6 @@ however." | |||
| 64 | ;; functions always take precedence, set | 52 | ;; functions always take precedence, set |
| 65 | ;; `eshell-prefer-lisp-functions' to t. | 53 | ;; `eshell-prefer-lisp-functions' to t. |
| 66 | 54 | ||
| 67 | (defcustom eshell-prefer-lisp-functions nil | ||
| 68 | "*If non-nil, prefer Lisp functions to external commands." | ||
| 69 | :type 'boolean | ||
| 70 | :group 'eshell-cmd) | ||
| 71 | |||
| 72 | ;;;_* Alias functions | 55 | ;;;_* Alias functions |
| 73 | ;; | 56 | ;; |
| 74 | ;; Whenever a command is specified using a simple name, such as 'ls', | 57 | ;; Whenever a command is specified using a simple name, such as 'ls', |
| @@ -112,17 +95,44 @@ however." | |||
| 112 | ;; | 95 | ;; |
| 113 | ;; Lisp arguments are identified using the following regexp: | 96 | ;; Lisp arguments are identified using the following regexp: |
| 114 | 97 | ||
| 98 | ;;;_* Command hooks | ||
| 99 | ;; | ||
| 100 | ;; There are several hooks involved with command execution, which can | ||
| 101 | ;; be used either to change or augment Eshell's behavior. | ||
| 102 | |||
| 103 | |||
| 104 | ;;; Code: | ||
| 105 | |||
| 106 | (require 'esh-util) | ||
| 107 | (unless (featurep 'xemacs) | ||
| 108 | (require 'eldoc)) | ||
| 109 | (require 'esh-arg) | ||
| 110 | (require 'esh-proc) | ||
| 111 | (require 'esh-ext) | ||
| 112 | |||
| 113 | (eval-when-compile | ||
| 114 | (require 'pcomplete)) | ||
| 115 | |||
| 116 | |||
| 117 | (defgroup eshell-cmd nil | ||
| 118 | "Executing an Eshell command is as simple as typing it in and | ||
| 119 | pressing <RET>. There are several different kinds of commands, | ||
| 120 | however." | ||
| 121 | :tag "Command invocation" | ||
| 122 | ;; :link '(info-link "(eshell)Command invocation") | ||
| 123 | :group 'eshell) | ||
| 124 | |||
| 125 | (defcustom eshell-prefer-lisp-functions nil | ||
| 126 | "*If non-nil, prefer Lisp functions to external commands." | ||
| 127 | :type 'boolean | ||
| 128 | :group 'eshell-cmd) | ||
| 129 | |||
| 115 | (defcustom eshell-lisp-regexp "\\([(`]\\|#'\\)" | 130 | (defcustom eshell-lisp-regexp "\\([(`]\\|#'\\)" |
| 116 | "*A regexp which, if matched at beginning of an argument, means Lisp. | 131 | "*A regexp which, if matched at beginning of an argument, means Lisp. |
| 117 | Such arguments will be passed to `read', and then evaluated." | 132 | Such arguments will be passed to `read', and then evaluated." |
| 118 | :type 'regexp | 133 | :type 'regexp |
| 119 | :group 'eshell-cmd) | 134 | :group 'eshell-cmd) |
| 120 | 135 | ||
| 121 | ;;;_* Command hooks | ||
| 122 | ;; | ||
| 123 | ;; There are several hooks involved with command execution, which can | ||
| 124 | ;; be used either to change or augment Eshell's behavior. | ||
| 125 | |||
| 126 | (defcustom eshell-pre-command-hook nil | 136 | (defcustom eshell-pre-command-hook nil |
| 127 | "*A hook run before each interactive command is invoked." | 137 | "*A hook run before each interactive command is invoked." |
| 128 | :type 'hook | 138 | :type 'hook |
| @@ -219,15 +229,6 @@ return non-nil if the command is complex." | |||
| 219 | (function :tag "Predicate"))) | 229 | (function :tag "Predicate"))) |
| 220 | :group 'eshell-cmd) | 230 | :group 'eshell-cmd) |
| 221 | 231 | ||
| 222 | ;;; Code: | ||
| 223 | |||
| 224 | (require 'esh-util) | ||
| 225 | (unless (featurep 'xemacs) | ||
| 226 | (require 'eldoc)) | ||
| 227 | (require 'esh-arg) | ||
| 228 | (require 'esh-proc) | ||
| 229 | (require 'esh-ext) | ||
| 230 | |||
| 231 | ;;; User Variables: | 232 | ;;; User Variables: |
| 232 | 233 | ||
| 233 | (defcustom eshell-cmd-load-hook '(eshell-cmd-initialize) | 234 | (defcustom eshell-cmd-load-hook '(eshell-cmd-initialize) |
| @@ -394,6 +395,18 @@ hooks should be run before and after the command." | |||
| 394 | (list 'eshell-commands commands) | 395 | (list 'eshell-commands commands) |
| 395 | commands))) | 396 | commands))) |
| 396 | 397 | ||
| 398 | (defun eshell-debug-command (tag subform) | ||
| 399 | "Output a debugging message to '*eshell last cmd*'." | ||
| 400 | (let ((buf (get-buffer-create "*eshell last cmd*")) | ||
| 401 | (text (eshell-stringify eshell-current-command))) | ||
| 402 | (save-excursion | ||
| 403 | (set-buffer buf) | ||
| 404 | (if (not tag) | ||
| 405 | (erase-buffer) | ||
| 406 | (insert "\n\C-l\n" tag "\n\n" text | ||
| 407 | (if subform | ||
| 408 | (concat "\n\n" (eshell-stringify subform)) "")))))) | ||
| 409 | |||
| 397 | (defun eshell-debug-show-parsed-args (terms) | 410 | (defun eshell-debug-show-parsed-args (terms) |
| 398 | "Display parsed arguments in the debug buffer." | 411 | "Display parsed arguments in the debug buffer." |
| 399 | (ignore | 412 | (ignore |
| @@ -956,18 +969,6 @@ at the moment are: | |||
| 956 | "Completion for the `debug' command." | 969 | "Completion for the `debug' command." |
| 957 | (while (pcomplete-here '("errors" "commands")))) | 970 | (while (pcomplete-here '("errors" "commands")))) |
| 958 | 971 | ||
| 959 | (defun eshell-debug-command (tag subform) | ||
| 960 | "Output a debugging message to '*eshell last cmd*'." | ||
| 961 | (let ((buf (get-buffer-create "*eshell last cmd*")) | ||
| 962 | (text (eshell-stringify eshell-current-command))) | ||
| 963 | (save-excursion | ||
| 964 | (set-buffer buf) | ||
| 965 | (if (not tag) | ||
| 966 | (erase-buffer) | ||
| 967 | (insert "\n\C-l\n" tag "\n\n" text | ||
| 968 | (if subform | ||
| 969 | (concat "\n\n" (eshell-stringify subform)) "")))))) | ||
| 970 | |||
| 971 | (defun eshell-invoke-directly (command input) | 972 | (defun eshell-invoke-directly (command input) |
| 972 | (let ((base (cadr (nth 2 (nth 2 (cadr command))))) name) | 973 | (let ((base (cadr (nth 2 (nth 2 (cadr command))))) name) |
| 973 | (if (and (eq (car base) 'eshell-trap-errors) | 974 | (if (and (eq (car base) 'eshell-trap-errors) |
| @@ -1418,5 +1419,7 @@ messages, and errors." | |||
| 1418 | 1419 | ||
| 1419 | (defalias 'eshell-lisp-command* 'eshell-lisp-command) | 1420 | (defalias 'eshell-lisp-command* 'eshell-lisp-command) |
| 1420 | 1421 | ||
| 1422 | (provide 'esh-cmd) | ||
| 1423 | |||
| 1421 | ;;; arch-tag: 8e4f3867-a0c5-441f-96ba-ddd142d94366 | 1424 | ;;; arch-tag: 8e4f3867-a0c5-441f-96ba-ddd142d94366 |
| 1422 | ;;; esh-cmd.el ends here | 1425 | ;;; esh-cmd.el ends here |